diff --git a/src/terminal/terminal/terminal_handlers.h b/src/terminal/terminal/terminal_handlers.h index cc976862..0a8fdcef 100644 --- a/src/terminal/terminal/terminal_handlers.h +++ b/src/terminal/terminal/terminal_handlers.h @@ -138,6 +138,18 @@ int guac_terminal_open_pipe_stream(guac_terminal* term, unsigned char c); */ int guac_terminal_close_pipe_stream(guac_terminal* term, unsigned char c); +/** + * Parses the remainder of xterm's OSC sequence for redefining the terminal + * emulator's palette. + * + * @param term + * The terminal that received the given character of data. + * + * @param c + * The character that was received by the given terminal. + */ +int guac_terminal_xterm_palette(guac_terminal* term, unsigned char c); + /** * Handles the remaining characters of an Operating System Code (OSC) sequence, * typically initiated with "ESC ]". diff --git a/src/terminal/terminal_handlers.c b/src/terminal/terminal_handlers.c index defca4b4..8e83fb11 100644 --- a/src/terminal/terminal_handlers.c +++ b/src/terminal/terminal_handlers.c @@ -1156,6 +1156,19 @@ int guac_terminal_close_pipe_stream(guac_terminal* term, unsigned char c) { } +int guac_terminal_xterm_palette(guac_terminal* term, unsigned char c) { + + /* NOTE: Currently unimplemented. Attempts to set the 256-color palette + * are ignored. */ + + /* Stop on ECMA-48 ST (String Terminator */ + if (c == 0x9C || c == 0x5C || c == 0x07) + term->char_handler = guac_terminal_echo; + + return 0; + +} + int guac_terminal_osc(guac_terminal* term, unsigned char c) { static int operation = 0; @@ -1183,6 +1196,10 @@ int guac_terminal_osc(guac_terminal* term, unsigned char c) { else if (operation == 482203) term->char_handler = guac_terminal_close_pipe_stream; + /* xterm 256-color palette redefinition */ + else if (operation == 4) + term->char_handler = guac_terminal_xterm_palette; + /* Reset parameter for next OSC */ operation = 0;