From 7894346285382af1a6fbb0824fb65b3c3a51d40e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 21 May 2013 00:29:19 -0700 Subject: [PATCH] Implement Index and Next Line. --- protocols/ssh/src/terminal_handlers.c | 47 +++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/protocols/ssh/src/terminal_handlers.c b/protocols/ssh/src/terminal_handlers.c index 0e7d1870..9900b5c5 100644 --- a/protocols/ssh/src/terminal_handlers.c +++ b/protocols/ssh/src/terminal_handlers.c @@ -172,12 +172,16 @@ int guac_terminal_escape(guac_terminal* term, char c) { term->char_handler = guac_terminal_csi; break; - case '7': /* Save Cursor (DECSC) */ + /* Save Cursor (DECSC) */ + case '7': term->saved_cursor_row = term->cursor_row; term->saved_cursor_col = term->cursor_col; + + term->char_handler = guac_terminal_echo; break; - case '8': /* Restore Cursor (DECRC) */ + /* Restore Cursor (DECRC) */ + case '8': term->cursor_row = term->saved_cursor_row; if (term->cursor_row >= term->term_height) @@ -187,9 +191,46 @@ int guac_terminal_escape(guac_terminal* term, char c) { if (term->cursor_col >= term->term_width) term->cursor_col = term->term_width - 1; + term->char_handler = guac_terminal_echo; break; - case 'M': /* Reverse Linefeed */ + /* Index (IND) */ + case 'D': + term->cursor_row++; + + /* Scroll up if necessary */ + if (term->cursor_row > term->scroll_end) { + term->cursor_row = term->scroll_end; + + /* Scroll up by one row */ + guac_terminal_scroll_up(term, term->scroll_start, + term->scroll_end, 1); + + } + + term->char_handler = guac_terminal_echo; + break; + + /* Next Line (NEL) */ + case 'E': + term->cursor_col = 0; + term->cursor_row++; + + /* Scroll up if necessary */ + if (term->cursor_row > term->scroll_end) { + term->cursor_row = term->scroll_end; + + /* Scroll up by one row */ + guac_terminal_scroll_up(term, term->scroll_start, + term->scroll_end, 1); + + } + + term->char_handler = guac_terminal_echo; + break; + + /* Reverse Linefeed */ + case 'M': term->cursor_row--;