corentin-soriano commented on code in PR #556:
URL: https://github.com/apache/guacamole-server/pull/556#discussion_r2487931163


##########
src/terminal/display.c:
##########
@@ -976,38 +976,67 @@ void guac_terminal_display_select(guac_terminal_display* 
display,
             start_row = end_row;
             end_row = temp;
 
+            /* Don't swap columns if it's a rectangular selection and start_col
+             * is less than end_col */
+            if (!rectangle || start_col > end_col) {
+                temp = start_col;
+                start_col = end_col;
+                end_col = temp;
+            }
+
+        }
+
+        /* Swap columns on rectangular selection to bottom-left direction */
+        else if (rectangle && start_col > end_col) {
+
+            int temp;
+
             temp = start_col;
             start_col = end_col;
             end_col = temp;
 
         }
 
-        /* First row */
-        guac_protocol_send_rect(socket, select_layer,
+        /* Multilines rectangular selection */
+        if (rectangle) {
+            guac_protocol_send_rect(socket, select_layer,
 
-                start_col * display->char_width,
-                start_row * display->char_height,
+                    start_col * display->char_width,
+                    start_row * display->char_height,
 
-                display->width * display->char_width,
-                display->char_height);
+                    (end_col - start_col + 1) * display->char_width,
+                    (end_row - start_row + 1) * display->char_height);
+        }
 
-        /* Middle */
-        guac_protocol_send_rect(socket, select_layer,
+        /* Multilines standard selection */
+        else {
+            /* First row */
+            guac_protocol_send_rect(socket, select_layer,
 
-                0,
-                (start_row + 1) * display->char_height,
+                    start_col * display->char_width,
+                    start_row * display->char_height,
 
-                display->width * display->char_width,
-                (end_row - start_row - 1) * display->char_height);
+                    display->width * display->char_width,
+                    display->char_height);
 
-        /* Last row */
-        guac_protocol_send_rect(socket, select_layer,
+            /* Middle */
+            guac_protocol_send_rect(socket, select_layer,
 
-                0,
-                end_row * display->char_height,
+                    0,
+                    (start_row + 1) * display->char_height,
 
-                (end_col + 1) * display->char_width,
-                display->char_height);
+                    display->width * display->char_width,
+                    (end_row - start_row - 1) * display->char_height);
+
+            /* Last row */
+            guac_protocol_send_rect(socket, select_layer,
+
+                    0,
+                    end_row * display->char_height,
+
+                    (end_col + 1) * display->char_width,
+                    display->char_height);
+        }

Review Comment:
   I changed them.



##########
src/terminal/terminal.c:
##########
@@ -1832,6 +1859,215 @@ static bool guac_terminal_is_blank(int ascii_char) {
     return (ascii_char == '\0' || ascii_char == ' ');
 }
 
+/**
+ * Set the row tail/head and col tail/head according to the value of current
+ * row/col and selection_initial_row/selection_initial_column. This aims to
+ * keep the initially selected word when dragging mouse after a double click.
+ *
+ * @param terminal
+ *     The terminal that received a double click event.
+ *
+ * @param col
+ *     The column where is currently the mouse.
+ *
+ * @param row
+ *     The row where is currently the mouse.
+ *
+ * @param col_head
+ *      Pointer where to write the calculated head column.
+ *
+ * @param col_tail
+ *      Pointer where to write the calculated tail column.
+ *
+ * @param row_head
+ *      Pointer where to write the calculated head row.
+ *
+ * @param row_tail
+ *      Pointer where to write the calculated tail row.
+ */
+static void guac_terminal_word_initial_position(guac_terminal* terminal,
+        int col, int row, int* col_head, int* col_tail, int* row_head, int* 
row_tail) {
+
+    /* The mouse is still in the intial row */
+    if (row == terminal->selection_initial_row) {
+
+        /* Mouse on the right of initial column */
+        if (col > terminal->selection_initial_column)
+            *col_head = terminal->selection_initial_column;
+
+        /* Mouse on the left of initial column */
+        else
+            *col_tail = terminal->selection_initial_column;
+    }
+
+    /* Use initial row as bottom-right of the selection and go up/left */
+    if (row < terminal->selection_initial_row) {
+        *row_tail = terminal->selection_initial_row;
+        *col_tail = terminal->selection_initial_column;
+    }
+
+    /* Use initial row/col as top-left of the selection and go down/right */
+    if (row > terminal->selection_initial_row) {
+        *row_head = terminal->selection_initial_row;
+        *col_head = terminal->selection_initial_column;
+    }
+}
+
+/**
+ * Get word/URI/blank boundaries on a terminal buffer depending on given 
position:
+ * existing selection to update or mouse position. Gets the boundaries in the
+ * left/up direction and then in the right/down direction, continuing if the
+ * row is wrapped.
+ * A sequence of the same character whatever it is will be treated as a word.

Review Comment:
   Done



##########
src/terminal/display.c:
##########
@@ -976,38 +976,67 @@ void guac_terminal_display_select(guac_terminal_display* 
display,
             start_row = end_row;
             end_row = temp;
 
+            /* Don't swap columns if it's a rectangular selection and start_col
+             * is less than end_col */
+            if (!rectangle || start_col > end_col) {
+                temp = start_col;
+                start_col = end_col;
+                end_col = temp;
+            }

Review Comment:
   I agree, the comment is not very clear.
   Even more interesting: the entire `if (start_row > end_row) {` block has 
become unnecessary since #607 because the swap is performed in 
`guac_terminal_select_update`:
   
https://github.com/apache/guacamole-server/blob/53ec1f49bdfb7412d0d94c1fab48d18166a00cad/src/terminal/select.c#L165-L170
   



##########
src/terminal/terminal.c:
##########
@@ -1804,18 +1804,45 @@ static bool guac_terminal_is_part_of_word(int 
ascii_char) {
     return ((ascii_char >= '0' && ascii_char <= '9') || 
             (ascii_char >= 'A' && ascii_char <= 'Z') || 
             (ascii_char >= 'a' && ascii_char <= 'z') ||
+            (ascii_char >= GUAC_TERMINAL_LATIN1_CAPITAL_AGRAVE &&
+             ascii_char <= GUAC_TERMINAL_LATIN1_Y_UMLAUT) ||
             (ascii_char == '$') ||
-            (ascii_char == '%') ||
-            (ascii_char == '&') ||

Review Comment:
   I initially placed them here to be able to match a URL. Outside of the 
context of a URL, I haven't found any other use for them.



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