# File lib/rbreadline.rb, line 1675
  def expand_prompt(pmt)
    # Short-circuit if we can.
    if (@rl_byte_oriented && pmt[RL_PROMPT_START_IGNORE].nil?)
      r = pmt.dup
      lp = r.length
      lip = 0
      niflp = 0
      vlp = lp
      return [r,lp,lip,niflp,vlp]
    end

    l = pmt.length
    ret = ''
    invfl = 0    # invisible chars in first line of prompt
    invflset = 0    # we only want to set invfl once

    igstart = 0
    rl = 0
    ignoring = false
    last = ninvis = physchars = 0
    for pi in 0 ... pmt.length
      # This code strips the invisible character string markers
      #RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE
      if (!ignoring && pmt[pi,1] == RL_PROMPT_START_IGNORE)        # XXX - check ignoring?
        ignoring = true
        igstart = pi
        next
      elsif (ignoring && pmt[pi,1] == RL_PROMPT_END_IGNORE)
        ignoring = false
        if (pi != (igstart + 1))
          last = ret.length - 1
        end
        next
      else
        if !@rl_byte_oriented
          pind = pi
          ind = _rl_find_next_mbchar(pmt, pind, 1, MB_FIND_NONZERO)
          l = ind - pind
          while (l>0)
            l-=1
            ret << pmt[pi]
            pi += 1
          end
          if (!ignoring)
            rl += ind - pind
            physchars += _rl_col_width(pmt, pind, ind)
          else
            ninvis += ind - pind
          end
          pi-=1       # compensate for later increment
        else
          ret << pmt[pi]
          if (!ignoring)
            rl+=1            # visible length byte counter
            physchars+=1
          else
            ninvis+=1        # invisible chars byte counter
          end

          if (invflset == 0 && rl >= @_rl_screenwidth)
            invfl = ninvis
            invflset = 1
          end
        end
      end
    end

    if (rl < @_rl_screenwidth)
      invfl = ninvis
    end
    lp = rl
    lip = last
    niflp = invfl
    vlp = physchars
    return [ret,lp,lip,niflp,vlp]
  end