Move flags to generic function, add charset handler stubs.

This commit is contained in:
Michael Jumper 2013-05-23 23:12:01 -07:00
parent ae7959c6a4
commit f4475b4f00
2 changed files with 78 additions and 11 deletions

View File

@ -42,7 +42,10 @@
int guac_terminal_echo(guac_terminal* term, char c); int guac_terminal_echo(guac_terminal* term, char c);
int guac_terminal_escape(guac_terminal* term, char c); int guac_terminal_escape(guac_terminal* term, char c);
int guac_terminal_charset(guac_terminal* term, char c); int guac_terminal_g0_charset(guac_terminal* term, char c);
int guac_terminal_g1_charset(guac_terminal* term, char c);
int guac_terminal_g2_charset(guac_terminal* term, char c);
int guac_terminal_g3_charset(guac_terminal* term, char c);
int guac_terminal_csi(guac_terminal* term, char c); int guac_terminal_csi(guac_terminal* term, char c);
int guac_terminal_osc(guac_terminal* term, char c); int guac_terminal_osc(guac_terminal* term, char c);
int guac_terminal_ctrl_func(guac_terminal* term, char c); int guac_terminal_ctrl_func(guac_terminal* term, char c);

View File

@ -173,7 +173,19 @@ int guac_terminal_escape(guac_terminal* term, char c) {
switch (c) { switch (c) {
case '(': case '(':
term->char_handler = guac_terminal_charset; term->char_handler = guac_terminal_g0_charset;
break;
case ')':
term->char_handler = guac_terminal_g1_charset;
break;
case '*':
term->char_handler = guac_terminal_g2_charset;
break;
case '+':
term->char_handler = guac_terminal_g3_charset;
break; break;
case ']': case ']':
@ -273,9 +285,58 @@ int guac_terminal_escape(guac_terminal* term, char c) {
} }
int guac_terminal_charset(guac_terminal* term, char c) { int guac_terminal_g0_charset(guac_terminal* term, char c) {
/* STUB */
guac_client_log_info(term->client, "Ignoring G0 charset: 0x%02x", c);
term->char_handler = guac_terminal_echo; term->char_handler = guac_terminal_echo;
return 0; return 0;
}
int guac_terminal_g1_charset(guac_terminal* term, char c) {
/* STUB */
guac_client_log_info(term->client, "Ignoring G1 charset: 0x%02x", c);
term->char_handler = guac_terminal_echo;
return 0;
}
int guac_terminal_g2_charset(guac_terminal* term, char c) {
/* STUB */
guac_client_log_info(term->client, "Ignoring G2 charset: 0x%02x", c);
term->char_handler = guac_terminal_echo;
return 0;
}
int guac_terminal_g3_charset(guac_terminal* term, char c) {
/* STUB */
guac_client_log_info(term->client, "Ignoring G3 charset: 0x%02x", c);
term->char_handler = guac_terminal_echo;
return 0;
}
/**
* Looks up the flag specified by the given number and mode. Used by the Set/Reset Mode
* functions of the terminal.
*/
static bool* __guac_terminal_get_flag(guac_terminal* term, int num, char private_mode) {
if (private_mode == '?') {
switch (num) {
case 1: return &(term->application_cursor_keys); /* DECCKM */
}
}
/* Unknown flag */
return NULL;
} }
int guac_terminal_csi(guac_terminal* term, char c) { int guac_terminal_csi(guac_terminal* term, char c) {
@ -304,6 +365,7 @@ int guac_terminal_csi(guac_terminal* term, char c) {
else if ((c >= 0x40 && c <= 0x7E) || c == ';') { else if ((c >= 0x40 && c <= 0x7E) || c == ';') {
int i, row, col, amount; int i, row, col, amount;
bool* flag;
/* At most 16 parameters */ /* At most 16 parameters */
if (argc < 16) { if (argc < 16) {
@ -555,9 +617,10 @@ int guac_terminal_csi(guac_terminal* term, char c) {
/* h: Set Mode */ /* h: Set Mode */
case 'h': case 'h':
/* DECCKM */ /* Look up flag and set */
if (argv[0] == 1 && private_mode_character == '?') flag = __guac_terminal_get_flag(term, argv[0], private_mode_character);
term->application_cursor_keys = true; if (flag != NULL)
*flag = true;
else else
guac_client_log_info(term->client, guac_client_log_info(term->client,
@ -569,9 +632,10 @@ int guac_terminal_csi(guac_terminal* term, char c) {
/* l: Reset Mode */ /* l: Reset Mode */
case 'l': case 'l':
/* DECCKM */ /* Look up flag and clear */
if (argv[0] == 1 && private_mode_character == '?') flag = __guac_terminal_get_flag(term, argv[0], private_mode_character);
term->application_cursor_keys = false; if (flag != NULL)
*flag = false;
else else
guac_client_log_info(term->client, guac_client_log_info(term->client,