Class: Shellfie::LineLayout
- Inherits:
-
Object
- Object
- Shellfie::LineLayout
- Defined in:
- lib/shellfie/line_layout.rb
Instance Attribute Summary collapse
-
#visible_count ⇒ Object
readonly
Returns the value of attribute visible_count.
Instance Method Summary collapse
-
#initialize(config) ⇒ LineLayout
constructor
A new instance of LineLayout.
- #prepare(lines, content_width:, font_size:, title_bar_height:, padding:, line_height:) ⇒ Object
Constructor Details
#initialize(config) ⇒ LineLayout
Returns a new instance of LineLayout.
11 12 13 |
# File 'lib/shellfie/line_layout.rb', line 11 def initialize(config) @config = config end |
Instance Attribute Details
#visible_count ⇒ Object (readonly)
Returns the value of attribute visible_count.
9 10 11 |
# File 'lib/shellfie/line_layout.rb', line 9 def visible_count @visible_count end |
Instance Method Details
#prepare(lines, content_width:, font_size:, title_bar_height:, padding:, line_height:) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/shellfie/line_layout.rb', line 15 def prepare(lines, content_width:, font_size:, title_bar_height:, padding:, line_height:) max_cells = [(content_width / (font_size * 0.6)).floor, 1].max mode = @config.window[:wrap] ? "wrap" : @config.window[:overflow] display_lines = lines.flat_map { |line| apply_overflow(line, max_cells, mode) } line_limit = vertical_line_limit(, padding, line_height) @visible_count = line_limit || display_lines.size render_limit = render_line_limit(line_limit) render_limit ? display_lines.last(render_limit) : display_lines end |