Class: Kward::PtyTranscriptNormalizer::Line
- Inherits:
-
Object
- Object
- Kward::PtyTranscriptNormalizer::Line
- Defined in:
- lib/kward/pty/transcript_normalizer.rb
Overview
Applies the horizontal cursor controls accepted by AdaptivePtyOutputSink without modeling a complete terminal screen.
Defined Under Namespace
Classes: WideGlyph
Constant Summary collapse
- BLANK_CELL =
" ".freeze
Instance Method Summary collapse
-
#initialize(text, columns) ⇒ Line
constructor
A new instance of Line.
- #render ⇒ Object
Constructor Details
#initialize(text, columns) ⇒ Line
Returns a new instance of Line.
34 35 36 37 38 39 |
# File 'lib/kward/pty/transcript_normalizer.rb', line 34 def initialize(text, columns) @text = text @last_column = columns - 1 @cells = [] @cursor = 0 end |
Instance Method Details
#render ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/kward/pty/transcript_normalizer.rb', line 41 def render ANSI.scan_escape_tokens(@text).each do |token| token[:escape] ? apply_escape(token[:text]) : write_text(token[:text]) end @cells.each_with_index.map do |cell, column| cell.is_a?(WideGlyph) ? (cell.text if cell.column == column) : cell end.join.rstrip end |