Noor-glyp commented on a change in pull request #350:
URL: https://github.com/apache/guacamole-server/pull/350#discussion_r748038580
##########
File path: src/terminal/terminal.c
##########
@@ -1590,17 +1590,120 @@ static int __guac_terminal_send_key(guac_terminal*
term, int keysym, int pressed
if (keysym == 0xFF54 || keysym == 0xFF99) return
guac_terminal_send_string(term, "\x1B[B"); /* Down */
}
+ /* Check if any Modifier key is pressed. */
+ if (term->mod_ctrl || term->mod_alt || term->mod_shift) {
+ int keyseq = 0;
+
+ if (term->mod_ctrl) {
+ keyseq = keyseq | 4; /* OR operation with other modifier
key combination. */
+ }
+
+ if (term->mod_alt) {
+ keyseq = keyseq | 2;
+ }
+
+ if (term->mod_shift) {
+ keyseq = keyseq | 1;
+ }
+
+ keyseq = keyseq + 1;
+
+ /* F1 */
+ if (keysym == 0xFFBE || keysym == 0xFF91) {
+ char data[10];
+ sprintf(data,"\x1B[1;%dP",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F2 */
+ if (keysym == 0xFFBF || keysym == 0xFF92) {
+ char data[10];
+ sprintf(data,"\x1B[1;%dQ",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F3 */
+ if (keysym == 0xFFC0 || keysym == 0xFF93) {
+ char data[10];
+ sprintf(data,"\x1B[1;%dR",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F4 */
+ if (keysym == 0xFFC1 || keysym == 0xFF94) {
+ char data[10];
+ sprintf(data,"\x1B[1;%dS",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F5 */
+ if (keysym == 0xFFC2) {
+ char data[10];
+ sprintf(data,"\x1B[15;%d~",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F6 */
+ if (keysym == 0xFFC3) {
+ char data[10];
+ sprintf(data,"\x1B[17;%d~",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F7 */
+ if (keysym == 0xFFC4) {
+ char data[10];
+ sprintf(data,"\x1B[18;%d~",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F8 */
+ if (keysym == 0xFFC5) {
+ char data[10];
+ sprintf(data,"\x1B[19;%d~",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F9 */
+ if (keysym == 0xFFC6) {
+ char data[10];
+ sprintf(data,"\x1B[20;%d~",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F10 */
+ if (keysym == 0xFFC7) {
+ char data[10];
+ sprintf(data,"\x1B[21;%d~",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F11 */
+ if (keysym == 0xFFC8) {
+ char data[10];
+ sprintf(data,"\x1B[23;%d~",keyseq);
+ return guac_terminal_send_string(term, data);
+ }
+
+ /* F12 */
+ if (keysym == 0xFFC9) {
+ char data[10];
+ sprintf(data,"\x1B[24;%d~",keyseq);
+ return guac_terminal_send_string(term, data);
Review comment:
It will remain like this as for the function keys we have to pass the
escape characters with some data so without the sprintf and this approch, I
can't think of a better solution. Please elaborate on this maybe. What you may
think be a better way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]