Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/terminal/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ void guac_terminal_display_set_columns(guac_terminal_display* display, int row,
start_column = guac_terminal_fit_to_range(start_column, 0, display->width - 1);
end_column = guac_terminal_fit_to_range(end_column, 0, display->width - 1);

if (start_column > end_column) {
guac_client_log(display->client, GUAC_LOG_TRACE, "display_set_columns: Adjusted range is empty [%d,%d], returning.", start_column, end_column);
return;
}

size_t start_offset = guac_mem_ckd_add_or_die(guac_mem_ckd_mul_or_die(row, display->width), start_column);
guac_terminal_operation* current = &(display->operations[start_offset]);

Expand Down
42 changes: 35 additions & 7 deletions src/terminal/terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,19 @@ void guac_terminal_commit_cursor(guac_terminal* term) {

guac_terminal_char* characters;
int length = guac_terminal_buffer_get_columns(term->current_buffer, &characters, NULL, term->visible_cursor_row);
if (term->visible_cursor_col < length)
guac_terminal_display_set_columns(term->display, term->visible_cursor_row + term->scroll_offset,
term->visible_cursor_col, term->visible_cursor_col, &characters[term->visible_cursor_col]);
if (term->visible_cursor_col < length) {
guac_terminal_char* char_at_cursor = &characters[term->visible_cursor_col];
int char_width = char_at_cursor->width;

int clear_start_col = term->visible_cursor_col;
int clear_end_col = term->visible_cursor_col + char_width - 1;

if (clear_end_col >= length)
clear_end_col = length - 1;

guac_terminal_display_set_columns(term->display, term->visible_cursor_row + term->scroll_offset,
clear_start_col, clear_end_col, char_at_cursor);
}
}

/* Set cursor if should be visible */
Expand All @@ -777,9 +786,19 @@ void guac_terminal_commit_cursor(guac_terminal* term) {

guac_terminal_char* characters;
int length = guac_terminal_buffer_get_columns(term->current_buffer, &characters, NULL, term->cursor_row);
if (term->cursor_col < length)
if (term->cursor_col < length) {
guac_terminal_char* char_at_cursor = &characters[term->cursor_col];
int char_width = char_at_cursor->width;

int set_start_col = term->cursor_col;
int set_end_col = term->cursor_col + char_width - 1;

if (set_end_col >= length)
set_end_col = length - 1;

guac_terminal_display_set_columns(term->display, term->cursor_row + term->scroll_offset,
term->cursor_col, term->cursor_col, &characters[term->cursor_col]);
set_start_col, set_end_col, char_at_cursor);
}

term->visible_cursor_row = term->cursor_row;
term->visible_cursor_col = term->cursor_col;
Expand Down Expand Up @@ -1156,9 +1175,18 @@ void guac_terminal_set_columns(guac_terminal* terminal, int row,
guac_terminal_char cursor_character = *character;
cursor_character.attributes.cursor = true;

__guac_terminal_set_columns(terminal, row,
terminal->visible_cursor_col, terminal->visible_cursor_col, &cursor_character);
int cursor_redraw_start_col = terminal->visible_cursor_col;
int cursor_redraw_end_col = terminal->visible_cursor_col + character->width - 1;

if (cursor_redraw_start_col < start_column)
cursor_redraw_start_col = start_column;
if (cursor_redraw_end_col > end_column)
cursor_redraw_end_col = end_column;

__guac_terminal_set_columns(terminal, row,
cursor_redraw_start_col,
cursor_redraw_end_col,
&cursor_character);
}

}
Expand Down