Skip to content
Kward Search API index

Class: Kward::PtyTranscriptNormalizer::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/pty_transcript_normalizer.rb

Overview

Applies the horizontal cursor controls accepted by AdaptivePtyOutputSink without modeling a complete terminal screen.

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Line

Returns a new instance of Line.



22
23
24
25
26
# File 'lib/kward/pty_transcript_normalizer.rb', line 22

def initialize(text)
  @text = text
  @cells = []
  @cursor = 0
end

Instance Method Details

#renderObject



28
29
30
31
32
33
# File 'lib/kward/pty_transcript_normalizer.rb', line 28

def render
  ANSI.scan_escape_tokens(@text).each do |token|
    token[:escape] ? apply_escape(token[:text]) : write_text(token[:text])
  end
  @cells.join.rstrip
end