diff --git a/src/terminal/terminal/terminal.h b/src/terminal/terminal/terminal.h index e0863922..4e04fc7e 100644 --- a/src/terminal/terminal/terminal.h +++ b/src/terminal/terminal/terminal.h @@ -98,6 +98,13 @@ */ #define GUAC_TERMINAL_SCHEME_NUMBERED "color" +/** + * Flag which specifies that terminal output should be sent to both the current + * pipe stream and the user's display. By default, terminal output will be sent + * only to the open pipe. + */ +#define GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT 1 + typedef struct guac_terminal guac_terminal; /** @@ -219,6 +226,8 @@ struct guac_terminal { * Bitwise OR of all flags which apply to the currently-open pipe stream. * If no pipe stream is open, this value has no meaning, and its contents * are undefined. + * + * @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT */ int pipe_stream_flags; @@ -931,6 +940,8 @@ int guac_terminal_next_tab(guac_terminal* term, int column); * @param flags * A bitwise OR of all integer flags which should apply to the new pipe * stream. + * + * @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT */ void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name, int flags); diff --git a/src/terminal/terminal_handlers.c b/src/terminal/terminal_handlers.c index 1437307a..a6469ace 100644 --- a/src/terminal/terminal_handlers.c +++ b/src/terminal/terminal_handlers.c @@ -135,8 +135,14 @@ int guac_terminal_echo(guac_terminal* term, unsigned char c) { /* Echo to pipe stream if open and not starting an ESC sequence */ if (term->pipe_stream != NULL && c != 0x1B) { + guac_terminal_pipe_stream_write(term, c); - return 0; + + /* Do not render output while pipe is open unless explicitly requested + * via flags */ + if (!(term->pipe_stream_flags & GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT)) + return 0; + } /* If using non-Unicode mapping, just map straight bytes */