Class: Ruco::CommandBar
Constant Summary collapse
- SHORTCUTS =
[ '^W Exit', '^S Save', '^F Find', '^D Delete line', '^G Go to line' ]
Instance Attribute Summary collapse
-
#cursor_line ⇒ Object
Returns the value of attribute cursor_line.
-
#form ⇒ Object
Returns the value of attribute form.
Instance Method Summary collapse
- #ask(question, options = {}, &block) ⇒ Object
- #cursor ⇒ Object
-
#initialize(options) ⇒ CommandBar
constructor
A new instance of CommandBar.
- #reset ⇒ Object
- #view ⇒ Object
Constructor Details
#initialize(options) ⇒ CommandBar
Returns a new instance of CommandBar.
14 15 16 17 18 |
# File 'lib/ruco/command_bar.rb', line 14 def initialize() @options = @forms_cache = {} reset end |
Instance Attribute Details
#cursor_line ⇒ Object
Returns the value of attribute cursor_line.
3 4 5 |
# File 'lib/ruco/command_bar.rb', line 3 def cursor_line @cursor_line end |
#form ⇒ Object
Returns the value of attribute form.
3 4 5 |
# File 'lib/ruco/command_bar.rb', line 3 def form @form end |
Instance Method Details
#ask(question, options = {}, &block) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/ruco/command_bar.rb', line 28 def ask(question, ={}, &block) @form = cached_form_if([:cache], question) do Form.new(question, :columns => @options[:columns]) do |result| @form = nil block.call(result) end end end |
#cursor ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/ruco/command_bar.rb', line 42 def cursor if @form Cursor.new cursor_line, @form.cursor.column else Cursor.new cursor_line, 0 end end |
#reset ⇒ Object
37 38 39 40 |
# File 'lib/ruco/command_bar.rb', line 37 def reset @forms_cache[@forms_cache.key(@form)] = nil @form = nil end |
#view ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/ruco/command_bar.rb', line 20 def view if @form @form.view else available_shortcuts end end |