class Chamomile::EscapeParser
State-machine parser for ANSI escape sequences, CSI params, SGR mouse, and bracketed paste.
Constants
- CSI_ENTRY
- ESC_SEEN
- GROUND
-
States
- MAX_PASTE_SIZE
-
Maximum paste buffer size (1MB) to prevent memory exhaustion
- MODIFIER_MAP
-
CSI modifier mapping (xterm-style: param 2=Shift, 3=Alt, 4=Shift+Alt, 5=Ctrl, etc.)
- PASTE
- PASTE_END
- PASTE_START
- SS3
Public Class Methods
Source
# File lib/chamomile/escape_parser.rb, line 30 def initialize @state = GROUND @buf = +"" @paste_buf = +"" end
Public Instance Methods
Source
# File lib/chamomile/escape_parser.rb, line 37 def feed(bytes, &block) bytes.each_char { |ch| process_char(ch, &block) } end
Feed raw bytes into the parser, yielding parsed messages.
Source
# File lib/chamomile/escape_parser.rb, line 42 def timeout! return unless @state == ESC_SEEN @state = GROUND @buf.clear yield KeyEvent.new(key: :escape, mod: []) end
Call when IO.select times out — flushes ambiguous ESC as :escape key.