Handles C0 control codes and simple ESC sequences.
Extracted from Terminal.Emulator for better organization. Relies on Emulator state and ScreenBuffer for actions.
Summary
Functions
The state DECSC saves: cursor position, visibility, style and blink, SGR
attributes, charset state and (via mode_manager) origin/autowrap modes.
Handles bell control code.
Handle Backspace (BS)
Handles a C0 control code (0-31) or DEL (127). Delegates to specific handlers based on the codepoint.
Handle Carriage Return (CR)
Handles simple escape sequences (ESC followed by a single byte).
Handles the Horizontal Tab (HT) action.
Handle Line Feed (LF), New Line (NL), Vertical Tab (VT)
Handle Locking Shift 1 Right (LS1R) - ESC ~ Invokes G1 character set into GR
Handle Locking Shift 2 (LS2) - ESC n Invokes G2 character set into GL
Handle Locking Shift 2 Right (LS2R) - ESC } Invokes G2 character set into GR
Handle Locking Shift 3 (LS3) - ESC o Invokes G3 character set into GL
Handle Locking Shift 3 Right (LS3R) - ESC | Invokes G3 character set into GR
Handle Reverse Index (RI) - ESC M
Handles substitute character control code.
Applies a state saved by cursor_save_state/1. scroll_region is
deliberately NOT restored -- DECRC does not touch DECSTBM margins on real
terminals (see cursor_save_state/1).
The active screen's DECSC saved state, or nil.
Functions
@spec cursor_save_state(Raxol.Terminal.Emulator.t()) :: map()
The state DECSC saves: cursor position, visibility, style and blink, SGR
attributes, charset state and (via mode_manager) origin/autowrap modes.
It does NOT include the DECSTBM scroll region: per VT100/VT510 and xterm,
margins are not part of the DECSC/DECRC saved state, so a CSI t;b r
emitted inside an ESC 7/ESC 8 bracket survives the restore on real
hardware. This emulator used to round-trip scroll_region here, which
silently un-set a region established mid-bracket (the adaptive-pin
transition emits its DECSTBM inside the seal path's save/restore bracket)
-- diverging from every real terminal and invalidating the O2 replay
oracle. Pinned by test/harness/adaptive_pin_test.exs's transition replays
and the DECRC test in state_stack_test.exs.
Handles bell control code.
Handle Backspace (BS)
@spec handle_c0(Raxol.Terminal.Emulator.t(), non_neg_integer()) :: Raxol.Terminal.Emulator.t()
Handles a C0 control code (0-31) or DEL (127). Delegates to specific handlers based on the codepoint.
@spec handle_can(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
Handle Carriage Return (CR)
@spec handle_decrc(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
@spec handle_decsc(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
@spec handle_escape(Raxol.Terminal.Emulator.t(), integer()) :: Raxol.Terminal.Emulator.t()
Handles simple escape sequences (ESC followed by a single byte).
Handles the Horizontal Tab (HT) action.
@spec handle_hts(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
@spec handle_ind(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
Handle Line Feed (LF), New Line (NL), Vertical Tab (VT)
Handle Locking Shift 1 Right (LS1R) - ESC ~ Invokes G1 character set into GR
Handle Locking Shift 2 (LS2) - ESC n Invokes G2 character set into GL
Handle Locking Shift 2 Right (LS2R) - ESC } Invokes G2 character set into GR
Handle Locking Shift 3 (LS3) - ESC o Invokes G3 character set into GL
Handle Locking Shift 3 Right (LS3R) - ESC | Invokes G3 character set into GR
@spec handle_nel(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
Handle Reverse Index (RI) - ESC M
@spec handle_ris(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
@spec handle_si(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
@spec handle_so(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
Handles substitute character control code.
@spec restore_cursor_save_state(Raxol.Terminal.Emulator.t(), map()) :: Raxol.Terminal.Emulator.t()
Applies a state saved by cursor_save_state/1. scroll_region is
deliberately NOT restored -- DECRC does not touch DECSTBM margins on real
terminals (see cursor_save_state/1).
@spec saved_cursor_save_state(Raxol.Terminal.Emulator.t()) :: map() | nil
The active screen's DECSC saved state, or nil.