Class: Byebug::LocalInterface

Inherits:
Interface show all
Defined in:
lib/byebug/interfaces/local_interface.rb

Constant Summary collapse

FILE_HISTORY =
".byebug_hist"

Instance Attribute Summary collapse

Attributes inherited from Interface

#have_readline

Instance Method Summary collapse

Methods inherited from Interface

#errmsg, #escape, #format

Constructor Details

#initializeLocalInterface

Returns a new instance of LocalInterface.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/byebug/interfaces/local_interface.rb', line 8

def initialize()
  super
  @command_queue = []
  @have_readline = false
  @history_save = true
  @history_length = ENV["HISTSIZE"] ? ENV["HISTSIZE"].to_i : 256
  @histfile = File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", FILE_HISTORY)
  open(@histfile, 'r') do |file|
    file.each do |line|
      line.chomp!
      Readline::HISTORY << line
    end
  end if File.exist?(@histfile)
  @restart_file = nil
end

Instance Attribute Details

#command_queueObject

Returns the value of attribute command_queue.



3
4
5
# File 'lib/byebug/interfaces/local_interface.rb', line 3

def command_queue
  @command_queue
end

#histfileObject

Returns the value of attribute histfile.



3
4
5
# File 'lib/byebug/interfaces/local_interface.rb', line 3

def histfile
  @histfile
end

#history_lengthObject

Returns the value of attribute history_length.



3
4
5
# File 'lib/byebug/interfaces/local_interface.rb', line 3

def history_length
  @history_length
end

#history_saveObject

Returns the value of attribute history_save.



3
4
5
# File 'lib/byebug/interfaces/local_interface.rb', line 3

def history_save
  @history_save
end

#restart_fileObject

Returns the value of attribute restart_file.



4
5
6
# File 'lib/byebug/interfaces/local_interface.rb', line 4

def restart_file
  @restart_file
end

Instance Method Details

#closeObject



36
37
# File 'lib/byebug/interfaces/local_interface.rb', line 36

def close
end

#confirm(prompt) ⇒ Object



28
29
30
# File 'lib/byebug/interfaces/local_interface.rb', line 28

def confirm(prompt)
  readline(prompt, false)
end

#finalizeObject

Things to do before quitting



40
41
42
43
44
# File 'lib/byebug/interfaces/local_interface.rb', line 40

def finalize
  if Byebug.respond_to?(:save_history)
    Byebug.save_history
  end
end


32
33
34
# File 'lib/byebug/interfaces/local_interface.rb', line 32

def print(*args)
  STDOUT.printf(escape(format(*args)))
end

#read_command(prompt) ⇒ Object



24
25
26
# File 'lib/byebug/interfaces/local_interface.rb', line 24

def read_command(prompt)
  readline(prompt, true)
end

#readline_support?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/byebug/interfaces/local_interface.rb', line 46

def readline_support?
  @have_readline
end