Package org.aesh.terminal
Class EventDecoder
java.lang.Object
org.aesh.terminal.EventDecoder
- All Implemented Interfaces:
Consumer<int[]>
Decodes terminal input events, separating signals (INT, SUSP, EOF) and
unsolicited terminal responses from regular input.
When a themeChangeHandler is
registered, this decoder also intercepts CSI ? 997 ; Ps n theme
change DSR notifications and routes them to the handler instead of passing
them through as input. This prevents theme change notifications from
corrupting the readline buffer.
- Author:
- Ståle W. Pedersen
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new EventDecoder with default control character values.EventDecoder(int intr, int eof, int susp) Create a new EventDecoder with custom control character values.EventDecoder(Attributes attributes) Create a new EventDecoder using control characters from terminal attributes. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(int[] input) Process input, separating signals and theme DSR notifications from regular input.Consumer<int[]> Get the current input handler.Get the current signal handler.Get the current theme change handler.voidsetInputHandler(Consumer<int[]> inputHandler) Set the input handler that will receive non-signal input.voidsetSignalHandler(Consumer<Signal> signalHandler) Set the signal handler that will be called when signals are detected in input.voidsetThemeChangeHandler(Consumer<TerminalTheme> themeChangeHandler) Set the handler for theme change DSR notifications.
-
Constructor Details
-
EventDecoder
public EventDecoder()Create a new EventDecoder with default control character values. Default values: INTR=3 (Ctrl+C), EOF=4 (Ctrl+D), SUSP=26 (Ctrl+Z). -
EventDecoder
public EventDecoder(int intr, int eof, int susp) Create a new EventDecoder with custom control character values.- Parameters:
intr- the interrupt character code (typically Ctrl+C = 3)eof- the end-of-file character code (typically Ctrl+D = 4)susp- the suspend character code (typically Ctrl+Z = 26)
-
EventDecoder
Create a new EventDecoder using control characters from terminal attributes. Falls back to default values if the attributes do not specify valid control characters.- Parameters:
attributes- the terminal attributes to extract control characters from
-
-
Method Details
-
getSignalHandler
Get the current signal handler.- Returns:
- the signal handler, or null if not set
-
setSignalHandler
Set the signal handler that will be called when signals are detected in input.- Parameters:
signalHandler- the handler to process signals
-
getInputHandler
Get the current input handler.- Returns:
- the input handler, or null if not set
-
setInputHandler
Set the input handler that will receive non-signal input. Any queued input will be delivered to the handler immediately.- Parameters:
inputHandler- the handler to process input as code point arrays
-
getThemeChangeHandler
Get the current theme change handler.- Returns:
- the theme change handler, or null if not set
-
setThemeChangeHandler
Set the handler for theme change DSR notifications.When set, the decoder will intercept
CSI ? 997 ; Ps nsequences from the input stream and invoke this handler instead of passing them through as regular input.- Parameters:
themeChangeHandler- the handler, or null to disable interception
-
accept
public void accept(int[] input) Process input, separating signals and theme DSR notifications from regular input.Signal characters are extracted and sent to the signal handler. When a theme change handler is registered,
CSI ? 997 ; Ps nsequences are intercepted and routed to the theme change handler. Remaining input is sent to the input handler.
-