Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUACAMOLE-1961: improve selection #2

Closed
wants to merge 7 commits into from
52 changes: 33 additions & 19 deletions src/terminal/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ void guac_terminal_display_dup(
}

void guac_terminal_display_select(guac_terminal_display* display,
int start_row, int start_col, int end_row, int end_col) {
int start_row, int start_col, int end_row, int end_col, bool rectangle) {

guac_socket* socket = display->client->socket;
guac_layer* select_layer = display->select_layer;
Expand Down Expand Up @@ -949,32 +949,46 @@ void guac_terminal_display_select(guac_terminal_display* display,

}

/* 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);
}

}

Expand Down
9 changes: 5 additions & 4 deletions src/terminal/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ void guac_terminal_select_redraw(guac_terminal* terminal) {
else
end_column += terminal->selection_end_width - 1;

guac_terminal_display_select(terminal->display, start_row, start_column, end_row, end_column);
guac_terminal_display_select(terminal->display, start_row,
start_column, end_row, end_column, terminal->rectangle_selection);

}

Expand Down Expand Up @@ -364,7 +365,7 @@ void guac_terminal_select_end(guac_terminal* terminal) {
for (int row = start_row; row <= end_row; row++) {

/* Add a newline only if the previous line was not wrapped */
if (!last_row_was_wrapped)
if (!last_row_was_wrapped || (terminal->rectangle_selection && row != start_row))
guac_common_clipboard_append(terminal->clipboard, "\n", 1);

/* Append next row from desired region, adjusting the start/end column
Expand All @@ -373,8 +374,8 @@ void guac_terminal_select_end(guac_terminal* terminal) {
* copied in their entirety. */
int length = guac_terminal_buffer_get_columns(terminal->current_buffer, &characters, &last_row_was_wrapped, row);
guac_terminal_clipboard_append_characters(terminal, characters, length,
(row == start_row) ? start_col : 0,
(row == end_row) ? end_col : length - 1);
(row == start_row || terminal->rectangle_selection) ? start_col : 0,
(row == end_row || terminal->rectangle_selection) ? end_col : length - 1);

}

Expand Down
Loading
Loading