Class: Ruco::CommandBar
Constant Summary collapse
- SHORTCUTS =
[ '^W Exit', '^S Save', '^F Find', '^R Replace', '^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.
15 16 17 18 19 |
# File 'lib/ruco/command_bar.rb', line 15 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
29 30 31 32 33 34 35 36 |
# File 'lib/ruco/command_bar.rb', line 29 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
43 44 45 46 47 48 49 |
# File 'lib/ruco/command_bar.rb', line 43 def cursor if @form Position.new cursor_line, @form.cursor.column else Position.new cursor_line, 0 end end |
#reset ⇒ Object
38 39 40 41 |
# File 'lib/ruco/command_bar.rb', line 38 def reset @forms_cache[@forms_cache.key(@form)] = nil @form = nil end |
#view ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/ruco/command_bar.rb', line 21 def view if @form @form.view else available_shortcuts end end |