necouchman commented on code in PR #556:
URL: https://github.com/apache/guacamole-server/pull/556#discussion_r2487612499
##########
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'm not sure the comment here matches what's actually being done - it seems
like it's the opposite. The comment mentions that if it's rectangular and the
start column is less than the end column, but the `if` statement is if it's
*not* rectangular or the start column is greater than the end column.
Maybe comment just needs to be updated to say, `If the selection is
rectangular and the start column is greater than the end column, swap the
columns`.
Or does the `if` statement need to be updated?
##########
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:
Why are these being removed from the `is_part_of_word()` function? I can
understand adding them to the `is_part_of_uri` function, but shouldn't they
still be considered part of normal words?
##########
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:
This part of the comment should be on the line above - no reason for a new
line, here.
##########
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:
There are a lot of extra lines in this section - for example, when making a
multi-line function call, it would be:
```
guac_protocol_send)rect(socket, select_layer,
0,
end_row * display->char_height,
(end_col + 1) * display->char_width,
display->char_height);
```
--
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]