Class: Tuile::Component::Fill
- Inherits:
-
Component
- Object
- Component
- Tuile::Component::Fill
- Defined in:
- lib/tuile/component/fill.rb,
sig/tuile.rbs
Overview
Fills every cell of its #rect with one glyph. Give it a one-column rect
and │ for a vertical rule between two borderless panes, a one-row rect
and ─ for a horizontal one — the glyph decides the direction, the parent
decides the length:
rule = Component::Fill.new("│", color: Theme.ref(:pane_frame))
bottom = Component::Layout::Horizontal.new
bottom.add(system_pane, Layout::Percent[40])
bottom.add(rule, Layout::Fixed[1])
bottom.add(log_pane, Layout::Expand[1])
Display-only — not focusable, no keys, no mouse. The background behind the glyph is its own #bg_color, else inherited, as for any component.
Instance Attribute Summary collapse
-
#char ⇒ String
@return — the glyph painted into every cell; one grapheme cluster, one column wide.
-
#color ⇒ Color, ...
@return — the value as set, so a Theme::Ref comes back unresolved;
nil(the default) is the terminal's default foreground.
Instance Method Summary collapse
-
#initialize(char, color: nil) ⇒ Fill
constructor
@param
char— initial #char=. -
#repaint(canvas) ⇒ void
Paints #char into every cell.
- #resolved_color ⇒ Color?
Constructor Details
Instance Attribute Details
#char ⇒ String
@return — the glyph painted into every cell; one grapheme cluster, one column wide.
33 34 35 |
# File 'lib/tuile/component/fill.rb', line 33 def char @char end |
#color ⇒ Color, ...
@return — the value as set, so a Theme::Ref
comes back unresolved; nil (the default) is the terminal's default
foreground.
38 39 40 |
# File 'lib/tuile/component/fill.rb', line 38 def color @color end |
Instance Method Details
#repaint(canvas) ⇒ void
This method returns an undefined value.
Paints #char into every cell. Not super: the default's clear would
dirty every cell just before it is painted over.
@param canvas — see Tuile::Component#repaint.
80 81 82 83 84 85 |
# File 'lib/tuile/component/fill.rb', line 80 def repaint(canvas) return if rect.empty? row = StyledString.styled(@char * rect.width, fg: resolved_color) rect.height.times { canvas.set_text(0, _1, row) } end |
#resolved_color ⇒ Color?
90 |
# File 'lib/tuile/component/fill.rb', line 90 def resolved_color = @color.is_a?(Theme::Ref) ? @color.resolve(screen.theme) : @color |