Class: Ruco::CommandBar
Constant Summary collapse
- SHORTCUTS =
[ '^W Exit', '^S Save', '^F Find', '^R Replace', '^D Delete line', '^G Go to line', '^B Select mode' ]
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
- #style_map ⇒ Object
- #view ⇒ Object
Constructor Details
#initialize(options) ⇒ CommandBar
Returns a new instance of CommandBar.
16 17 18 19 20 |
# File 'lib/ruco/command_bar.rb', line 16 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
41 42 43 44 45 46 47 48 |
# File 'lib/ruco/command_bar.rb', line 41 def ask(question, ={}, &block) @form = cached_form_if([:cache], question) do Form.new(question, :columns => @options[:columns], :auto_enter => [:auto_enter]) do |result| @form = nil block.call(result) end end end |
#cursor ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/ruco/command_bar.rb', line 55 def cursor if @form Position.new cursor_line, @form.cursor.column else Position.new cursor_line, 0 end end |
#reset ⇒ Object
50 51 52 53 |
# File 'lib/ruco/command_bar.rb', line 50 def reset @forms_cache[@forms_cache.key(@form)] = nil @form = nil end |
#style_map ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ruco/command_bar.rb', line 30 def style_map if @form map = @form.style_map map.invert! map.prepend(:reverse, 0, 0..@options[:columns]) map else Dispel::StyleMap.single_line_reversed(@options[:columns]) end end |
#view ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/ruco/command_bar.rb', line 22 def view if @form @form.view else available_shortcuts end end |