class Byebug::RegularState


Controls state of Byebug’s REPL when in normal mode

def c_frame?(pos)

Parameters:
  • pos (Integer) -- Frame position.
def c_frame?(pos)
  context.frame_binding(pos).nil?
end

def frame_args(pos)

Parameters:
  • pos (Integer) -- Frame position.
def frame_args(pos)
  args = context.frame_args(pos)
  return '' if args.empty?
  locals = context.frame_locals(pos) unless Setting[:callstyle] == 'short'
  my_args = args.map do |arg|
    case arg[0]
    when :block then prefix, default = '&', 'block'
    when :rest then prefix, default = '*', 'args'
    else prefix, default = '', nil
    end
    kls = if Setting[:callstyle] == 'short' || arg[1].nil? || locals.empty?
            ''
          else
            "##{locals[arg[1]].class}"
          end
    "#{prefix}#{arg[1] || default}#{kls}"
  end
  "(#{my_args.join(', ')})"
end

def frame_block_and_method(pos)

Parameters:
  • pos (Integer) -- Frame position.
def frame_block_and_method(pos)
  deco_regexp = /((?:block(?: \(\d+ levels\))?|rescue) in )?(.+)/
  deco_method = "#{context.frame_method(pos)}"
  block_and_method = deco_regexp.match(deco_method)[1..2]
  block_and_method.map { |x| x.nil? ? '' : x }
end

def frame_call(pos)

Parameters:
  • pos (Integer) -- Frame position.
def frame_call(pos)
  block, method = frame_block_and_method(pos)
  block + frame_class(pos) + method + frame_args(pos)
end

def frame_class(pos)

Parameters:
  • pos (Integer) -- Frame position.
def frame_class(pos)
  return '' if Setting[:callstyle] == 'short'
  klass = context.frame_class(pos)
  return '' if klass.to_s.empty?
  "#{klass}."
end

def frame_file(pos)

Parameters:
  • pos (Integer) -- Frame position.
def frame_file(pos)
  fullpath = context.frame_file(pos)
  Setting[:fullpath] ? fullpath : shortpath(fullpath)
end

def frame_line(pos)

Parameters:
  • pos (Integer) -- Frame position.
def frame_line(pos)
  context.frame_line(pos)
end

def frame_mark(pos)

Parameters:
  • pos (Integer) -- Frame position.
def frame_mark(pos)
  mark = frame == pos ? '-->' : '   '
  c_frame?(pos) ? mark + ' ͱ--' : mark
end

def frame_pos(pos)

Parameters:
  • pos (Integer) -- Frame position.
def frame_pos(pos)
  format('%-2d', pos)
end

def initialize(context, display, file, interface, line)

def initialize(context, display, file, interface, line)
  super(interface)
  @context = context
  @display = display
  @file = file
  @frame = 0
  @line = line
  @prev_line = nil
  @proceed = false
end

def location


Current (formatted) location
def location
  l = "#{normalize(file)} @ #{line}\n"
  l += "#{get_line(file, line)}\n" unless %w((irb) -e').include?(file)
  l
end

def proceed


Signals the REPL that the execution can proceed
def proceed
  @proceed = true
end

def proceed?


Checks whether that execution can proceed
def proceed?
  @proceed
end

def shortpath(fullpath)

def shortpath(fullpath)
  components = Pathname(fullpath).each_filename.to_a
  return fullpath if components.size <= 2
  File.join('...', components[-3..-1])
end