Class: Clacky::UI2::OutputBuffer::Entry
- Inherits:
-
Struct
- Object
- Struct
- Clacky::UI2::OutputBuffer::Entry
- Defined in:
- lib/clacky/ui2/output_buffer.rb
Overview
A single logical output entry.
Instance Attribute Summary collapse
-
#committed_line_offset ⇒ Object
Returns the value of attribute committed_line_offset.
-
#id ⇒ Object
readonly
Monotonic id, unique within the buffer.
-
#lines ⇒ Object
readonly
Rendered (already-wrapped) visual lines.
Instance Method Summary collapse
-
#committed(value) ⇒ Object
True once pushed into terminal scrollback.
-
#height ⇒ Object
Visual row count this entry currently OCCUPIES on screen.
-
#kind(value) ⇒ Object
:text | :progress | :system (hint for renderer).
- #to_s ⇒ Object
-
#visible_lines ⇒ Object
The currently on-screen lines of this entry (lines that haven’t been pushed to scrollback yet).
Instance Attribute Details
#committed_line_offset ⇒ Object
Returns the value of attribute committed_line_offset
36 37 38 |
# File 'lib/clacky/ui2/output_buffer.rb', line 36 def committed_line_offset @committed_line_offset end |
#id ⇒ Object (readonly)
Monotonic id, unique within the buffer
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/clacky/ui2/output_buffer.rb', line 36 Entry = Struct.new(:id, :lines, :kind, :committed, :committed_line_offset, keyword_init: true) do # Visual row count this entry currently OCCUPIES on screen. Once a # prefix of the entry's lines has been pushed into scrollback by # a scroll+partial-commit, those prefix rows are no longer on # screen — so height drops accordingly. When +committed+ flips to # true the entry is considered fully off-screen and height is 0. def height return 0 if committed lines.length - (committed_line_offset || 0) end # The currently on-screen lines of this entry (lines that haven't # been pushed to scrollback yet). Returns [] once fully committed. def visible_lines return [] if committed off = committed_line_offset || 0 off.zero? ? lines : lines[off..] || [] end def to_s lines.join("\n") end end |
#lines ⇒ Object (readonly)
Rendered (already-wrapped) visual lines
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/clacky/ui2/output_buffer.rb', line 36 Entry = Struct.new(:id, :lines, :kind, :committed, :committed_line_offset, keyword_init: true) do # Visual row count this entry currently OCCUPIES on screen. Once a # prefix of the entry's lines has been pushed into scrollback by # a scroll+partial-commit, those prefix rows are no longer on # screen — so height drops accordingly. When +committed+ flips to # true the entry is considered fully off-screen and height is 0. def height return 0 if committed lines.length - (committed_line_offset || 0) end # The currently on-screen lines of this entry (lines that haven't # been pushed to scrollback yet). Returns [] once fully committed. def visible_lines return [] if committed off = committed_line_offset || 0 off.zero? ? lines : lines[off..] || [] end def to_s lines.join("\n") end end |
Instance Method Details
#committed=(value) ⇒ Object
True once pushed into terminal scrollback
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/clacky/ui2/output_buffer.rb', line 36 Entry = Struct.new(:id, :lines, :kind, :committed, :committed_line_offset, keyword_init: true) do # Visual row count this entry currently OCCUPIES on screen. Once a # prefix of the entry's lines has been pushed into scrollback by # a scroll+partial-commit, those prefix rows are no longer on # screen — so height drops accordingly. When +committed+ flips to # true the entry is considered fully off-screen and height is 0. def height return 0 if committed lines.length - (committed_line_offset || 0) end # The currently on-screen lines of this entry (lines that haven't # been pushed to scrollback yet). Returns [] once fully committed. def visible_lines return [] if committed off = committed_line_offset || 0 off.zero? ? lines : lines[off..] || [] end def to_s lines.join("\n") end end |
#height ⇒ Object
Visual row count this entry currently OCCUPIES on screen. Once a prefix of the entry’s lines has been pushed into scrollback by a scroll+partial-commit, those prefix rows are no longer on screen — so height drops accordingly. When committed flips to true the entry is considered fully off-screen and height is 0.
42 43 44 45 |
# File 'lib/clacky/ui2/output_buffer.rb', line 42 def height return 0 if committed lines.length - (committed_line_offset || 0) end |
#kind=(value) ⇒ Object
:text | :progress | :system (hint for renderer)
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/clacky/ui2/output_buffer.rb', line 36 Entry = Struct.new(:id, :lines, :kind, :committed, :committed_line_offset, keyword_init: true) do # Visual row count this entry currently OCCUPIES on screen. Once a # prefix of the entry's lines has been pushed into scrollback by # a scroll+partial-commit, those prefix rows are no longer on # screen — so height drops accordingly. When +committed+ flips to # true the entry is considered fully off-screen and height is 0. def height return 0 if committed lines.length - (committed_line_offset || 0) end # The currently on-screen lines of this entry (lines that haven't # been pushed to scrollback yet). Returns [] once fully committed. def visible_lines return [] if committed off = committed_line_offset || 0 off.zero? ? lines : lines[off..] || [] end def to_s lines.join("\n") end end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/clacky/ui2/output_buffer.rb', line 55 def to_s lines.join("\n") end |
#visible_lines ⇒ Object
The currently on-screen lines of this entry (lines that haven’t been pushed to scrollback yet). Returns [] once fully committed.
49 50 51 52 53 |
# File 'lib/clacky/ui2/output_buffer.rb', line 49 def visible_lines return [] if committed off = committed_line_offset || 0 off.zero? ? lines : lines[off..] || [] end |