More CSI handlers.

This commit is contained in:
Michael Jumper 2011-08-05 17:09:44 -07:00
parent 57bb593ea8
commit 9de0e18d11
2 changed files with 73 additions and 8 deletions

View File

@ -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",

View File

@ -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':