Class: Clacky::UI2::OutputBuffer::Entry

Inherits:
Struct
  • Object
show all
Defined in:
lib/clacky/ui2/output_buffer.rb

Overview

A single logical output entry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#committed_line_offsetObject

Returns the value of attribute committed_line_offset

Returns:

  • (Object)

    the current value of committed_line_offset



36
37
38
# File 'lib/clacky/ui2/output_buffer.rb', line 36

def committed_line_offset
  @committed_line_offset
end

#idObject (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

#linesObject (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

#heightObject

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_sObject



55
56
57
# File 'lib/clacky/ui2/output_buffer.rb', line 55

def to_s
  lines.join("\n")
end

#visible_linesObject

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