Class: Tuile::Component::InfoWindow
- Defined in:
- lib/tuile/component/info_window.rb,
sig/tuile.rbs
Overview
A Window with a read-only body, in one of two presentations: prose (#message=) wraps in a scrollable TextView, rows (#lines=) stay one per row in a List, truncating instead of wrapping — the presentation for columnar output, where a wrap would destroy the alignment. Usable tiled (add it to a Layout) or as a popup via InfoWindow.open; the constructor and InfoWindow.open pick the presentation from the body's type:
Component::InfoWindow.open("Help", "A long explanation, wrapped to fit.")
Component::InfoWindow.open("Files", ["drwx src/", "-rw- README.md"])
Both write the same body slot — the last writer wins.
Instance Attribute Summary collapse
-
#message ⇒ String, ...
@return — whatever #message= was given — set a
String, read thatStringback.
Attributes inherited from Window
Attributes included from HasContent
Class Method Summary collapse
-
.open(caption, body = nil, declared_size: Fraction::HALF) ⇒ Popup
Opens the info window as a popup.
Instance Method Summary collapse
-
#initialize(caption = "", body = nil) ⇒ InfoWindow
constructor
@param
caption— the border title. -
#lines=(lines) ⇒ void
Sets the rows body: a List populated via List#lines= (so entries are coerced,
\n-split and rstripped exactly as there), one item per row, long rows truncated — never wrapped.
Methods inherited from Window
#bottom_border, #caption, #caption=, #focusable?, #footer, #footer=, #layout, #layout_footer, #on_focus, #rect=, #repaint, #repaint_border, #scrollbar=, #top_border
Methods included from HasCaption
Methods included from HasContent
Constructor Details
#initialize(caption = "", body = nil) ⇒ InfoWindow
21 22 23 24 25 26 27 28 29 |
# File 'lib/tuile/component/info_window.rb', line 21 def initialize(caption = "", body = nil) @message = nil super(caption) if body.is_a?(Array) self.lines = body else self. = body end end |
Instance Attribute Details
Class Method Details
.open(caption, body = nil, declared_size: Fraction::HALF) ⇒ Popup
Opens the info window as a popup.
@param caption — the border title.
@param body — dispatched by type as in #initialize.
@param declared_size — the popup's box, applied top-down; the body wraps or scrolls within it. Defaults to Fraction::HALF.
@return — the opened popup.
75 76 77 |
# File 'lib/tuile/component/info_window.rb', line 75 def self.open(caption, body = nil, declared_size: Fraction::HALF) Popup.new(content: InfoWindow.new(caption, body), declared_size: declared_size).open end |
Instance Method Details
#lines=(lines) ⇒ void
This method returns an undefined value.
Sets the rows body: a List populated via List#lines= (so entries
are coerced, \n-split and rstripped exactly as there), one item per
row, long rows truncated — never wrapped. For prose use #message=.
@param lines — entries are String, StyledString, or anything that responds to #to_s.
61 62 63 64 65 |
# File 'lib/tuile/component/info_window.rb', line 61 def lines=(lines) list = List.new list.lines = lines self. = list end |