# File lib/rbreadline.rb, line 3875
  def rl_on_new_line_with_prompt()
    # Initialize visible_line and invisible_line to ensure that they can hold
    #   the already-displayed prompt.
    prompt_size = @rl_prompt.length + 1
    init_line_structures(prompt_size)

    # Make sure the line structures hold the already-displayed prompt for
    #   redisplay.
    lprompt = @local_prompt ? @local_prompt : @rl_prompt
    @visible_line[0,lprompt.length] = lprompt
    @invisible_line[0,lprompt.length] = lprompt

    # If the prompt contains newlines, take the last tail.
    prompt_last_line = rl_prompt.rindex("\n")
    if prompt_last_line.nil?
      prompt_last_line = @rl_prompt
    else
      prompt_last_line = @rl_prompt[prompt_last_line..-1]
    end
    l = prompt_last_line.length
    if !@rl_byte_oriented
      @_rl_last_c_pos = _rl_col_width(prompt_last_line, 0, l)
    else
      @_rl_last_c_pos = l
    end

    # Dissect prompt_last_line into screen lines. Note that here we have
    #   to use the real screenwidth. Readline's notion of screenwidth might be
    #   one less, see terminal.c.
    real_screenwidth = @_rl_screenwidth + (@_rl_term_autowrap ? 0 : 1)
    @_rl_last_v_pos = l / real_screenwidth
    # If the prompt length is a multiple of real_screenwidth, we don't know
    #   whether the cursor is at the end of the last line, or already at the
    #   beginning of the next line. Output a newline just to be safe.
    if (l > 0 && (l % real_screenwidth) == 0)
      _rl_output_some_chars("\n",0,1)
    end
    @last_lmargin = 0

    newlines = 0
    i = 0
    while (i <= l)
      @_rl_vis_botlin = newlines
      @vis_lbreaks[newlines] = i
      newlines += 1
      i += real_screenwidth
    end
    @vis_lbreaks[newlines] = l
    @visible_wrap_offset = 0

    @rl_display_prompt = @rl_prompt  # XXX - make sure it's set

    return 0
  end