Class: DebuggerXml::Ide::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/debugger_xml/ide/interface.rb

Direct Known Subclasses

Vim::Interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ Interface

Returns a new instance of Interface.



10
11
12
13
14
15
16
17
# File 'lib/debugger_xml/ide/interface.rb', line 10

def initialize(socket)
  @command_queue = []
  @socket = socket
  @history_save = false
  @history_length = 256
  @histfile = ''
  @restart_file = nil
end

Instance Attribute Details

#command_queueObject

Returns the value of attribute command_queue.



4
5
6
# File 'lib/debugger_xml/ide/interface.rb', line 4

def command_queue
  @command_queue
end

#histfileObject

Returns the value of attribute histfile.



5
6
7
# File 'lib/debugger_xml/ide/interface.rb', line 5

def histfile
  @histfile
end

#history_lengthObject

Returns the value of attribute history_length.



7
8
9
# File 'lib/debugger_xml/ide/interface.rb', line 7

def history_length
  @history_length
end

#history_saveObject

Returns the value of attribute history_save.



6
7
8
# File 'lib/debugger_xml/ide/interface.rb', line 6

def history_save
  @history_save
end

#restart_fileObject

Returns the value of attribute restart_file.



8
9
10
# File 'lib/debugger_xml/ide/interface.rb', line 8

def restart_file
  @restart_file
end

Instance Method Details

#closeObject



19
20
21
22
# File 'lib/debugger_xml/ide/interface.rb', line 19

def close
  @socket.close
rescue Exception
end

#confirm(prompt) ⇒ Object



32
33
34
# File 'lib/debugger_xml/ide/interface.rb', line 32

def confirm(prompt)
  true
end

#errmsg(*args) ⇒ Object



28
29
30
# File 'lib/debugger_xml/ide/interface.rb', line 28

def errmsg(*args)
  print(*args)
end

#finalizeObject



36
37
38
# File 'lib/debugger_xml/ide/interface.rb', line 36

def finalize
  close
end

#non_blocking_getsObject

Workaround for JRuby issue jira.codehaus.org/browse/JRUBY-2063



41
42
43
44
45
46
47
# File 'lib/debugger_xml/ide/interface.rb', line 41

def non_blocking_gets
  loop do
    result, _, _ = IO.select([@socket], nil, nil, 0.2)
    next unless result
    return result[0].gets
  end
end


61
62
63
64
65
66
# File 'lib/debugger_xml/ide/interface.rb', line 61

def print(*args)
  escaped_args = escape_input(args)
  value = escaped_args.first % escaped_args[1..-1]
  DebuggerXml.logger.puts("Going to print: #{value}")
  @socket.print(value)
end


24
25
26
# File 'lib/debugger_xml/ide/interface.rb', line 24

def print_debug(msg)
  STDOUT.puts(msg)
end

#puts(*args) ⇒ Object



68
69
70
# File 'lib/debugger_xml/ide/interface.rb', line 68

def puts(*args)
  print(*args)
end

#read_command(*args) ⇒ Object

Raises:

  • (IOError)


49
50
51
52
53
54
55
# File 'lib/debugger_xml/ide/interface.rb', line 49

def read_command(*args)
  result = non_blocking_gets
  raise IOError unless result
  result.chomp.tap do |r|
    DebuggerXml.logger.puts("Read command: #{r}")
  end
end

#readline_support?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/debugger_xml/ide/interface.rb', line 57

def readline_support?
  false
end