class Canis::ListFooter
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).
Attributes
attrib[RW]
color_pair[RW]
config[RW]
Public Class Methods
new(config={})
click to toggle source
# 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
Public Instance Methods
command(*args, &blk)
click to toggle source
command that returns a string that populates the status line (left aligned) @see :right e.g.
@l.command { "%-20s [DB: %-s | %-s ]" % [ Time.now, $current_db || "None", $current_table || "----"] }
# File lib/canis/core/widgets/listfooter.rb, line 26 def command *args, &blk @command_text = blk @command_args = args end
Also aliased as: left
command_right(*args, &blk)
click to toggle source
Procudure for text to be right aligned in statusline
# File lib/canis/core/widgets/listfooter.rb, line 34 def command_right *args, &blk @right_text = blk @right_args = args end
print(comp)
click to toggle source
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. @param comp : the calling textpad component (usually passed as self
)
# 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)
click to toggle source
# File lib/canis/core/widgets/listfooter.rb, line 41 def right_text(comp) @right_text.call(comp, @right_args) end
text(comp)
click to toggle source
# File lib/canis/core/widgets/listfooter.rb, line 38 def text(comp) @command_text.call(comp, @command_args) end