GUACAMOLE-269: Allow backspace key to be configured.

This commit is contained in:
Nick Couchman 2018-02-23 22:14:11 -05:00
parent 2ace9385a2
commit 46e908c06e
8 changed files with 56 additions and 5 deletions

View File

@ -56,6 +56,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
"create-recording-path",
"read-only",
"server-alive-interval",
"backspace",
NULL
};
@ -209,6 +210,13 @@ enum SSH_ARGS_IDX {
*/
IDX_SERVER_ALIVE_INTERVAL,
/**
* The ASCII code, in decimal, to send for the backspace key, as configured
* by the SSH connection from the client. By default this will be 0x7f,
* the ASCII DELETE code.
*/
IDX_BACKSPACE,
SSH_ARGS_COUNT
};
@ -348,6 +356,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user,
guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_SERVER_ALIVE_INTERVAL, 0);
/* Parse backspace key setting */
settings->backspace =
guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,
IDX_BACKSPACE, 127);
/* Parsing was successful */
return settings;

View File

@ -223,6 +223,11 @@ typedef struct guac_ssh_settings {
*/
int server_alive_interval;
/**
* The decismal ASCII code of the command to send for backspace.
*/
int backspace;
} guac_ssh_settings;
/**

View File

@ -207,7 +207,7 @@ void* ssh_client_thread(void* data) {
ssh_client->term = guac_terminal_create(client,
settings->font_name, settings->font_size,
settings->resolution, settings->width, settings->height,
settings->color_scheme);
settings->color_scheme, settings->backspace);
/* Fail if terminal init failed */
if (ssh_client->term == NULL) {

View File

@ -50,6 +50,7 @@ const char* GUAC_TELNET_CLIENT_ARGS[] = {
"recording-include-keys",
"create-recording-path",
"read-only",
"backspace",
NULL
};
@ -174,6 +175,11 @@ enum TELNET_ARGS_IDX {
*/
IDX_READ_ONLY,
/**
* ASCII code to use for the backspace key, or 127 if not specified.
*/
IDX_BACKSPACE,
TELNET_ARGS_COUNT
};
@ -328,6 +334,11 @@ guac_telnet_settings* guac_telnet_parse_args(guac_user* user,
guac_user_parse_args_boolean(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_CREATE_RECORDING_PATH, false);
/* Parse backspae key code */
settings->backspace =
guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv,
IDX_BACKSPACE, 127);
/* Parsing was successful */
return settings;

View File

@ -207,6 +207,13 @@ typedef struct guac_telnet_settings {
*/
bool recording_include_keys;
/**
* The ASCII code, in decimal, that the telnet client will use when the
* backspace key is pressed. By default, this is 0x7f, ASCII delete,
* but can be configured in the client settings.
*/
int backspace;
} guac_telnet_settings;
/**

View File

@ -480,7 +480,7 @@ void* guac_telnet_client_thread(void* data) {
telnet_client->term = guac_terminal_create(client,
settings->font_name, settings->font_size,
settings->resolution, settings->width, settings->height,
settings->color_scheme);
settings->color_scheme, settings->backspace);
/* Fail if terminal init failed */
if (telnet_client->term == NULL) {

View File

@ -257,7 +257,8 @@ void* guac_terminal_thread(void* data) {
guac_terminal* guac_terminal_create(guac_client* client,
const char* font_name, int font_size, int dpi,
int width, int height, const char* color_scheme) {
int width, int height, const char* color_scheme,
const int backspace) {
int default_foreground;
int default_background;
@ -406,6 +407,10 @@ guac_terminal* guac_terminal_create(guac_client* client,
return NULL;
}
/* Configure backspace */
term->backspace = backspace;
guac_client_log(client, GUAC_LOG_DEBUG, "Backspace has been set to %d", term->backspace);
return term;
}
@ -1594,7 +1599,7 @@ static int __guac_terminal_send_key(guac_terminal* term, int keysym, int pressed
/* Non-printable keys */
else {
if (keysym == 0xFF08) return guac_terminal_send_string(term, "\x7F"); /* Backspace */
if (keysym == 0xFF08) return guac_terminal_send_string(term, &term->backspace); /* Backspace */
if (keysym == 0xFF09 || keysym == 0xFF89) return guac_terminal_send_string(term, "\x09"); /* Tab */
if (keysym == 0xFF0D || keysym == 0xFF8D) return guac_terminal_send_string(term, "\x0D"); /* Enter */
if (keysym == 0xFF1B) return guac_terminal_send_string(term, "\x1B"); /* Esc */

View File

@ -432,6 +432,11 @@ struct guac_terminal {
*/
guac_common_clipboard* clipboard;
/**
* Hexidecimal ASCII code sent when backspace is pressed.
*/
char backspace;
};
/**
@ -464,13 +469,18 @@ struct guac_terminal {
* invalid, a warning will be logged, and the terminal will fall back on
* GUAC_TERMINAL_SCHEME_GRAY_BLACK.
*
* @param backspace
* The decimal ASCII code to send when backspace is pressed in
* this terminal.
*
* @return
* A new guac_terminal having the given font, dimensions, and attributes
* which renders all text to the given client.
*/
guac_terminal* guac_terminal_create(guac_client* client,
const char* font_name, int font_size, int dpi,
int width, int height, const char* color_scheme);
int width, int height, const char* color_scheme,
const int backspace);
/**
* Frees all resources associated with the given terminal.