From b513e4ba939e26e89495fa549ed9189cfe5385e1 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 24 May 2013 13:33:32 -0700 Subject: [PATCH] Add LF/NL mode. --- protocols/ssh/include/terminal.h | 5 +++++ protocols/ssh/src/terminal.c | 1 + protocols/ssh/src/terminal_handlers.c | 19 ++++++++++++++----- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/protocols/ssh/include/terminal.h b/protocols/ssh/include/terminal.h index 438e18e1..8138a812 100644 --- a/protocols/ssh/include/terminal.h +++ b/protocols/ssh/include/terminal.h @@ -210,6 +210,11 @@ struct guac_terminal { */ bool application_cursor_keys; + /** + * Whether a CR should automatically follow a LF, VT, or FF. + */ + bool automatic_carriage_return; + }; /** diff --git a/protocols/ssh/src/terminal.c b/protocols/ssh/src/terminal.c index 6c02eefa..afc00ef3 100644 --- a/protocols/ssh/src/terminal.c +++ b/protocols/ssh/src/terminal.c @@ -96,6 +96,7 @@ guac_terminal* guac_terminal_create(guac_client* client, term->text_selected = false; term->application_cursor_keys = false; + term->automatic_carriage_return = false; /* Open STDOUT pipe */ if (pipe(term->stdout_pipe_fd)) { diff --git a/protocols/ssh/src/terminal_handlers.c b/protocols/ssh/src/terminal_handlers.c index 212bd78c..392db46a 100644 --- a/protocols/ssh/src/terminal_handlers.c +++ b/protocols/ssh/src/terminal_handlers.c @@ -98,11 +98,6 @@ int guac_terminal_echo(guac_terminal* term, char c) { term->cursor_col--; break; - /* Carriage return */ - case '\r': - term->cursor_col = 0; - break; - /* Line feed / VT / FF */ case '\n': case 0x0B: /* VT */ @@ -118,6 +113,14 @@ int guac_terminal_echo(guac_terminal* term, char c) { term->scroll_end, 1); } + + /* If automatic carriage return, fall through to CR handler */ + if (!term->automatic_carriage_return) + break; + + /* Carriage return */ + case '\r': + term->cursor_col = 0; break; /* ESC */ @@ -333,6 +336,12 @@ static bool* __guac_terminal_get_flag(guac_terminal* term, int num, char private } } + else if (private_mode == 0) { + switch (num) { + case 20: return &(term->automatic_carriage_return); /* LF/NL */ + } + } + /* Unknown flag */ return NULL;