Class EventDecoder
- All Implemented Interfaces:
Consumer<int[]>
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.Get the current focus event handler.Consumer<int[]> Get the current input handler.Get the current mouse event handler.Get the current signal handler.Consumer<org.aesh.terminal.detect.TerminalTheme> Get the current theme change handler.voidsetFocusHandler(Consumer<Boolean> focusHandler) Set the handler for terminal focus events.voidsetInputHandler(Consumer<int[]> inputHandler) Set the input handler that will receive non-signal input.voidsetMouseHandler(Consumer<MouseEvent> mouseHandler) Set the handler for mouse events.voidsetSignalHandler(Consumer<Signal> signalHandler) Set the signal handler that will be called when signals are detected in input.voidsetThemeChangeHandler(Consumer<org.aesh.terminal.detect.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
-
setSignalHandler
-
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
-
getMouseHandler
Get the current mouse event handler.- Returns:
- the mouse handler, or null if not set
-
setMouseHandler
Set the handler for mouse events.When set, the decoder will intercept SGR mouse sequences (
CSI < Pb ; Px ; Py M/m) from the input stream and invoke this handler instead of passing them through as input.- Parameters:
mouseHandler- the handler, or null to disable interception
-
setThemeChangeHandler
public void setThemeChangeHandler(Consumer<org.aesh.terminal.detect.TerminalTheme> themeChangeHandler) 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
-
getFocusHandler
-
setFocusHandler
Set the handler for terminal focus events.When set, the decoder will intercept focus in (
ESC [ I) and focus out (ESC [ O) sequences from the input stream and invoke this handler instead of passing them through as input. The handler receivestruefor focus gained andfalsefor focus lost.- Parameters:
focusHandler- 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.
-