Class: Canis::ListFooter
Overview
A vim-like application status bar that can display time and various other statuses
at the bottom, typically above the dock (3rd line from last).
Instance Attribute Summary collapse
-
#attrib ⇒ Object
Returns the value of attribute attrib.
-
#color_pair ⇒ Object
Returns the value of attribute color_pair.
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
-
#command(*args, &blk) ⇒ Object
(also: #left)
command that returns a string that populates the status line (left aligned) e.g.
-
#command_right(*args, &blk) ⇒ Object
Procudure for text to be right aligned in statusline.
-
#initialize(config = {}, &block) ⇒ ListFooter
constructor
A new instance of ListFooter.
-
#print(comp) ⇒ Object
supply a default print function.
- #right_text(comp) ⇒ Object
- #text(comp) ⇒ Object
Constructor Details
#initialize(config = {}, &block) ⇒ ListFooter
Returns a new instance of ListFooter.
14 15 16 17 18 19 |
# File 'lib/canis/core/widgets/listfooter.rb', line 14 def initialize config={}, &block @config = config @color_pair = get_color($datacolor, config[:color], config[:bgcolor]) @attrib = config[:attrib] instance_eval &block if block_given? end |
Instance Attribute Details
#attrib ⇒ Object
Returns the value of attribute attrib.
12 13 14 |
# File 'lib/canis/core/widgets/listfooter.rb', line 12 def attrib @attrib end |
#color_pair ⇒ Object
Returns the value of attribute color_pair.
11 12 13 |
# File 'lib/canis/core/widgets/listfooter.rb', line 11 def color_pair @color_pair end |
#config ⇒ Object
Returns the value of attribute config.
10 11 12 |
# File 'lib/canis/core/widgets/listfooter.rb', line 10 def config @config end |
Instance Method Details
#command(*args, &blk) ⇒ Object Also known as: left
command that returns a string that populates the status line (left aligned) e.g.
@l.command { "%-20s [DB: %-s | %-s ]" % [ Time.now, $current_db || "None", $current_table || "----"] }
26 27 28 29 |
# File 'lib/canis/core/widgets/listfooter.rb', line 26 def command *args, &blk @command_text = blk @command_args = args end |
#command_right(*args, &blk) ⇒ Object
Procudure for text to be right aligned in statusline
34 35 36 37 |
# File 'lib/canis/core/widgets/listfooter.rb', line 34 def command_right *args, &blk @right_text = blk @right_args = args end |
#print(comp) ⇒ Object
supply a default print function. The user program need not call this. It may be overridden The idea of passing a component at this stage is that one footer can be created for several tables or text components, each will pass self
when calling print.
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 75 76 77 78 79 80 81 82 |
# File 'lib/canis/core/widgets/listfooter.rb', line 49 def print comp config = @config row = comp.row + comp.height - 1 col = comp.col + 2 len = comp.width - col g = comp.form.window # we check just in case user nullifies it deliberately, since he may have changed config values @color_pair ||= get_color($datacolor, config[:color], config[:bgcolor]) @attrib ||= config[:attrib] || Ncurses::A_REVERSE # first print dashes through #g.printstring row, col, "%s" % "-" * len, @color_pair, Ncurses::A_REVERSE # now call the block to get current values for footer text on left ftext = nil if @command_text ftext = text(comp) else if !@right_text # user has not specified right or left, so we use a default on left ftext = "#{comp.current_index} of #{comp.size} " end end g.printstring(row, col, ftext, @color_pair, @attrib) if ftext # user has specified text for right, print it if @right_text len = comp.width ftext = right_text(comp) c = len - ftext.length - 2 g.printstring row, c, ftext, @color_pair, @attrib end end |
#right_text(comp) ⇒ Object
41 42 43 |
# File 'lib/canis/core/widgets/listfooter.rb', line 41 def right_text(comp) @right_text.call(comp, @right_args) end |
#text(comp) ⇒ Object
38 39 40 |
# File 'lib/canis/core/widgets/listfooter.rb', line 38 def text(comp) @command_text.call(comp, @command_args) end |