From 9de0e18d11670307de42ebf42e9e22b7fd1a63e5 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 5 Aug 2011 17:09:44 -0700 Subject: [PATCH] More CSI handlers. --- protocols/ssh/src/ssh_client.c | 7 --- protocols/ssh/src/ssh_terminal_handlers.c | 74 ++++++++++++++++++++++- 2 files changed, 73 insertions(+), 8 deletions(-) diff --git a/protocols/ssh/src/ssh_client.c b/protocols/ssh/src/ssh_client.c index 49147fb2..81e0c174 100644 --- a/protocols/ssh/src/ssh_client.c +++ b/protocols/ssh/src/ssh_client.c @@ -49,13 +49,6 @@ #include "ssh_handlers.h" #include "ssh_terminal.h" -#define SSH_TERM_STATE_NULL 0 -#define SSH_TERM_STATE_ECHO 1 -#define SSH_TERM_STATE_ESC 2 -#define SSH_TERM_STATE_CSI 3 -#define SSH_TERM_STATE_OSC 4 -#define SSH_TERM_STATE_CHARSET 5 - /* Client plugin arguments */ const char* GUAC_CLIENT_ARGS[] = { "hostname", diff --git a/protocols/ssh/src/ssh_terminal_handlers.c b/protocols/ssh/src/ssh_terminal_handlers.c index 3af9b19f..8fc76131 100644 --- a/protocols/ssh/src/ssh_terminal_handlers.c +++ b/protocols/ssh/src/ssh_terminal_handlers.c @@ -183,7 +183,7 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) { /* Any non-digit stops the parameter, and possibly the sequence */ else { - int i, row, col; + int i, row, col, amount; /* At most 16 parameters */ if (argc < 16) { @@ -200,6 +200,65 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) { /* Handle CSI functions */ switch (c) { + /* A: Move up */ + case 'A': + + /* Get move amount */ + amount = argv[0]; + if (amount == 0) amount = 1; + + /* Move cursor */ + term->cursor_row -= amount; + if (term->cursor_row < 0) + term->cursor_row = 0; + + break; + + /* B: Move down */ + case 'B': + + /* Get move amount */ + amount = argv[0]; + if (amount == 0) amount = 1; + + /* Move cursor */ + term->cursor_row += amount; + if (term->cursor_row >= term->term_height) + term->cursor_row = term->term_height - 1; + + break; + + /* D: Move left */ + case 'D': + + /* Get move amount */ + amount = argv[0]; + if (amount == 0) amount = 1; + + /* Move cursor */ + term->cursor_col -= amount; + if (term->cursor_col < 0) + term->cursor_col = 0; + + break; + + /* C: Move right */ + case 'C': + + /* Get move amount */ + amount = argv[0]; + if (amount == 0) amount = 1; + + /* Move cursor */ + term->cursor_col += amount; + if (term->cursor_col >= term->term_width) + term->cursor_col = term->term_width - 1; + + break; + + + + /* m: Set graphics rendition */ case 'm': @@ -277,6 +336,19 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) { term->cursor_col = col; break; + /* G: Move cursor, current row */ + case 'G': + col = argv[0]; if (col != 0) col--; + term->cursor_col = col; + break; + + /* d: Move cursor, current col */ + case 'd': + row = argv[0]; if (row != 0) row--; + term->cursor_row = row; + break; + + /* J: Erase display */ case 'J':