Class: TerminalNotes::InfoBar
- Defined in:
- lib/terminal-notes/info_bar.rb
Constant Summary collapse
- HEIGHT =
3
Constants inherited from Widget
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(config: {}, parent:, &block) ⇒ InfoBar
constructor
A new instance of InfoBar.
Methods inherited from Widget
Constructor Details
#initialize(config: {}, parent:, &block) ⇒ InfoBar
Returns a new instance of InfoBar.
5 6 7 8 9 10 11 |
# File 'lib/terminal-notes/info_bar.rb', line 5 def initialize(config: {}, parent:, &block) super(parent: parent, title: "", height: HEIGHT, y: (parent.size[:lines] - HEIGHT), border: false) @get_context = block draw end |
Instance Method Details
#draw ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/terminal-notes/info_bar.rb', line 13 def draw super do context = @get_context.call title = "Mode: #{context[:mode].to_s.capitalize}" cursor = Cursor.new(x: (@parent.size[:columns] - title.size) / 2, y: 0) @window.move_cursor(cursor) @window.draw_string(title) end end |