Class: Amun::UI::ModeLine
- Inherits:
-
Object
- Object
- Amun::UI::ModeLine
- Defined in:
- lib/amun/ui/mode_line.rb
Overview
a line of small segments that display information about the current buffer, like mode name, line number, buffer name…etc
Instance Attribute Summary collapse
-
#left_segments ⇒ Object
readonly
Returns the value of attribute left_segments.
-
#right_segments ⇒ Object
readonly
Returns the value of attribute right_segments.
Instance Method Summary collapse
-
#initialize(buffer) ⇒ ModeLine
constructor
A new instance of ModeLine.
- #render(window) ⇒ Object
Constructor Details
#initialize(buffer) ⇒ ModeLine
Returns a new instance of ModeLine.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/amun/ui/mode_line.rb', line 13 def initialize(buffer) @buffer = buffer @right_segments = [] @left_segments = [ ModeLineSegments::BufferName.new(buffer), ModeLineSegments::MajorMode.new(buffer) ] Helpers::Colors.register_default(:mode_line, 0, 255) end |
Instance Attribute Details
#left_segments ⇒ Object (readonly)
Returns the value of attribute left_segments.
11 12 13 |
# File 'lib/amun/ui/mode_line.rb', line 11 def left_segments @left_segments end |
#right_segments ⇒ Object (readonly)
Returns the value of attribute right_segments.
11 12 13 |
# File 'lib/amun/ui/mode_line.rb', line 11 def right_segments @right_segments end |
Instance Method Details
#render(window) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/amun/ui/mode_line.rb', line 24 def render(window) right_output = render_segments(right_segments, window) left_output = render_segments(left_segments, window) size = (right_output + left_output).map(&:size).inject(0, :+) empty_space = [0, window.maxx - size].max filler = (' ' * empty_space).colorize(:mode_line) Helpers::Colors.print(window, *left_output, filler, *right_output) end |