Class: Ruber::IRB::IRBWidget

Inherits:
Qt::Widget
  • Object
show all
Defined in:
plugins/irb/irb.rb,
plugins/irb/irb.rb

Constant Summary

PROMPTS =
{
  :PROMPT_I=>"%N(%m):%03n:%i> ",
  :PROMPT_N=>"%N(%m):%03n:%i> ",
  :PROMPT_S=>"%N(%m):%03n:%i%l ",
  :PROMPT_C=>"%N(%m):%03n:%i* ",
  :RETURN=>"=> "
}

Instance Method Summary (collapse)

Constructor Details

- (IRBWidget) initialize(parent = nil)

A new instance of IRBWidget



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'plugins/irb/irb.rb', line 47

def initialize parent = nil
  super
  @ui = Ui::ToolWidget.new
  @ui.setup_ui self
  @view = @ui.view
  @input = @ui.input
  self.focus_proxy = @input
  @controller = IRBController.new Ruber[:config][:irb, :irb], [], self
  @controller.connect(SIGNAL(:output_ready)){ display_output @controller.output}
  @display_output = true
  @controller.prompts = Ruber[:config][:irb, :prompts]
  @controller.start_irb
  @input.connect(SIGNAL('returnPressed(QString)')){|s| send_to_irb s}
  @input.completion_mode = KDE::GlobalSettings::CompletionAuto
  @controller.connect SIGNAL(:ready) do
    @input.enabled = true
    @input.set_focus if is_active_window
  end
  @ui.restart_irb.connect(SIGNAL(:clicked)){ @controller.restart_irb}
  @ui.send_abort.connect(SIGNAL(:clicked)){ @controller.interrupt}
  @controller.connect(SIGNAL(:interrupting_evaluation)){ @display_output = false}
  @controller.connect(SIGNAL(:evaluation_interrupted)){ @display_output = true}
  @cursor = @view.text_cursor
  @formats = {
    :input => Qt::TextCharFormat.new{|c| c.foreground = Qt::Brush.new Ruber[:config][:output_colors, :message]},
    :output => Qt::TextCharFormat.new{|c| c.foreground = Qt::Brush.new Ruber[:config][:output_colors, :output]}
  }
end

Instance Method Details

- (Object) display_output(lines) (private)



92
93
94
95
96
97
98
99
100
101
102
103
# File 'plugins/irb/irb.rb', line 92

def display_output lines
  return unless @display_output
  @cursor.move_position Qt::TextCursor::End
  lines.each do |l|
    Ruber[:app].process_events
    @cursor.char_format = @formats[l.category]
    @cursor.insert_text l.full_text+"\n"
  end
  @cursor.move_position Qt::TextCursor::End
  @view.text_cursor = @cursor
  @view.ensure_cursor_visible
end

- (Object) load_settings



81
82
83
# File 'plugins/irb/irb.rb', line 81

def load_settings
  @controller.prompts = Ruber[:config][:irb, :prompts]
end

Slot Signature:

load_settings()

- (Object) send_to_irb(line) (private)



102
103
104
105
106
107
108
# File 'plugins/irb/irb.rb', line 102

def send_to_irb line
  @input.completion_object.add_item line
  @input.insert_item 0, line
  @input.edit_text = ''
  @input.enabled = false
  @controller.send_to_irb [line]
end

- (Object) stop



86
87
88
# File 'plugins/irb/irb.rb', line 86

def stop
  @controller.stop_irb
end