Class: Debugger::Xml::Ide::Interface

Inherits:
Interface
  • Object
show all
Defined in:
lib/debugger/xml/ide/interface.rb

Overview

:nodoc:

Direct Known Subclasses

Vim::Interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ Interface

Returns a new instance of Interface.



11
12
13
14
15
16
17
18
# File 'lib/debugger/xml/ide/interface.rb', line 11

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.



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

def command_queue
  @command_queue
end

#histfileObject

Returns the value of attribute histfile.



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

def histfile
  @histfile
end

#history_lengthObject

Returns the value of attribute history_length.



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

def history_length
  @history_length
end

#history_saveObject

Returns the value of attribute history_save.



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

def history_save
  @history_save
end

#restart_fileObject

Returns the value of attribute restart_file.



9
10
11
# File 'lib/debugger/xml/ide/interface.rb', line 9

def restart_file
  @restart_file
end

Instance Method Details

#closeObject



20
21
22
23
# File 'lib/debugger/xml/ide/interface.rb', line 20

def close
  @socket.close
rescue Exception
end

#confirm(prompt) ⇒ Object



33
34
35
# File 'lib/debugger/xml/ide/interface.rb', line 33

def confirm(prompt)
  true
end

#errmsg(*args) ⇒ Object



29
30
31
# File 'lib/debugger/xml/ide/interface.rb', line 29

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

#finalizeObject



37
38
39
# File 'lib/debugger/xml/ide/interface.rb', line 37

def finalize
  close
end

#non_blocking_getsObject

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



42
43
44
45
46
47
48
# File 'lib/debugger/xml/ide/interface.rb', line 42

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


62
63
64
65
66
67
# File 'lib/debugger/xml/ide/interface.rb', line 62

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


25
26
27
# File 'lib/debugger/xml/ide/interface.rb', line 25

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

#read_command(*args) ⇒ Object

Raises:

  • (IOError)


50
51
52
53
54
55
56
# File 'lib/debugger/xml/ide/interface.rb', line 50

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

#readline_support?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/debugger/xml/ide/interface.rb', line 58

def readline_support?
  false
end