mike-jumper commented on a change in pull request #350:
URL: https://github.com/apache/guacamole-server/pull/350#discussion_r747967806



##########
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);

Review comment:
       Please follow established code style (see formatting of parameters with 
respect to commas and spaces). The lack of spaces after the commas separating 
parameters here (and elsewhere) produces a rather difficult-to-read line.

##########
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;

Review comment:
       What's up with the indentation here?

##########
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:
       With this section consisting of repeated `char data[10]` and `return 
guac_terminal_send_tring(...)` lines, I feel there must be a more DRY way to 
approach this.

##########
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) {

Review comment:
       Is there no way that these various keysyms could also be collapsed into 
fewer cases? Even if there are special cases for certain groups of function 
keys, the number of special cases seems like it should be well below 12.




-- 
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]


Reply via email to