class TkInspect::Console::Base
Attributes
eval_binding[RW]
main_component[RW]
modal[RW]
root[RW]
tk_root[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/tk_inspect/console/base.rb, line 12 def initialize(options = {}) @tk_root = nil @main_component = nil @eval_binding = binding @modal = !!options[:modal] @root = !!options[:root] end
Public Instance Methods
create_root()
click to toggle source
# File lib/tk_inspect/console/base.rb, line 67 def create_root @tk_root = TkComponent::Window.new(title: "Ruby Console", root: @root) @main_component = RootComponent.new @main_component.console = self @tk_root.place_root_component(@main_component) create_menu @tk_root.tk_item.native_item.after(100) { @main_component.focus_on_code } end
execute(code)
click to toggle source
# File lib/tk_inspect/console/base.rb, line 39 def execute(code) eval(code, eval_binding) end
focus()
click to toggle source
# File lib/tk_inspect/console/base.rb, line 24 def focus create_root if @main_component.nil? @tk_root.focus @tk_root.tk_item.native_item.after(100) { @main_component.focus_on_code } end
make_main()
click to toggle source
# File lib/tk_inspect/console/base.rb, line 20 def make_main self.class.main_console = self end
modal_loop()
click to toggle source
# File lib/tk_inspect/console/base.rb, line 35 def modal_loop @main_component.run_modal_loop end
new_canvas_window()
click to toggle source
# File lib/tk_inspect/canvas_window/base.rb, line 34 def new_canvas_window TkInspect::CanvasWindow::Base.new.refresh end
open_class_browser()
click to toggle source
# File lib/tk_inspect/console/base.rb, line 63 def open_class_browser TkInspect::ClassBrowser::Base.new.refresh end
open_inspector(expression = nil)
click to toggle source
# File lib/tk_inspect/console/base.rb, line 48 def open_inspector(expression = nil) if expression.present? val = eval(expression, eval_binding) TkInspect::Inspector::Base .inspector_for_object(val) .new(expression: expression, binding: eval_binding, value: val).refresh else TkInspect::Inspector::Base .new(expression: expression, binding: eval_binding).refresh end end
refresh()
click to toggle source
# File lib/tk_inspect/console/base.rb, line 30 def refresh @main_component.regenerate @main_component.focus end
say(s)
click to toggle source
# File lib/tk_inspect/console/base.rb, line 43 def say(s) main_component.show_output(s) return nil end