Handle typing of Unicode properly.

This commit is contained in:
Michael Jumper 2013-05-13 01:51:16 -07:00
parent a7ba3f085f
commit 14bf8dd843

View File

@ -52,6 +52,7 @@
#include "ssh_handlers.h" #include "ssh_handlers.h"
#include "ssh_client.h" #include "ssh_client.h"
#include "common.h"
#include "cursor.h" #include "cursor.h"
int ssh_guac_client_handle_messages(guac_client* client) { int ssh_guac_client_handle_messages(guac_client* client) {
@ -265,22 +266,36 @@ int ssh_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
pthread_mutex_unlock(&(term->lock)); pthread_mutex_unlock(&(term->lock));
} }
/* If simple ASCII key */ /* Translate Ctrl+letter to control code */
if (keysym >= 0x00 && keysym <= 0xFF) { if (client_data->mod_ctrl) {
char data = (char) keysym;
/* Handle Ctrl modifier */ char data;
if (client_data->mod_ctrl) {
if (keysym >= 'A' && keysym <= 'Z') /* If valid control code, send it */
data = (char) (keysym - 'A' + 1); if (keysym >= 'A' && keysym <= 'Z')
else if (keysym >= 'a' && keysym <= 'z') data = (char) (keysym - 'A' + 1);
data = (char) (keysym - 'a' + 1); else if (keysym >= 'a' && keysym <= 'z')
} data = (char) (keysym - 'a' + 1);
/* Otherwise ignore */
else
return 0;
return channel_write(client_data->term_channel, &data, 1); return channel_write(client_data->term_channel, &data, 1);
} }
/* Translate Unicode to UTF-8 */
else if ((keysym >= 0x00 && keysym <= 0xFF) || ((keysym & 0xFFFF0000) == 0x01000000)) {
int length;
char data[5];
length = guac_terminal_encode_utf8(keysym & 0xFFFF, data);
return channel_write(client_data->term_channel, data, length);
}
else { else {
int length = 0; int length = 0;