GUACAMOLE-871: Add support for hidden cursor (DECTECM)
This commit is contained in:
parent
b181026e58
commit
199c2a0961
@ -202,6 +202,7 @@ void guac_terminal_reset(guac_terminal* term) {
|
|||||||
/* Reset cursor location */
|
/* Reset cursor location */
|
||||||
term->cursor_row = term->visible_cursor_row = term->saved_cursor_row = 0;
|
term->cursor_row = term->visible_cursor_row = term->saved_cursor_row = 0;
|
||||||
term->cursor_col = term->visible_cursor_col = term->saved_cursor_col = 0;
|
term->cursor_col = term->visible_cursor_col = term->saved_cursor_col = 0;
|
||||||
|
term->cursor_visible = true;
|
||||||
|
|
||||||
/* Clear scrollback, buffer, and scroll region */
|
/* Clear scrollback, buffer, and scroll region */
|
||||||
term->buffer->top = 0;
|
term->buffer->top = 0;
|
||||||
@ -777,31 +778,42 @@ void guac_terminal_commit_cursor(guac_terminal* term) {
|
|||||||
|
|
||||||
guac_terminal_char* guac_char;
|
guac_terminal_char* guac_char;
|
||||||
|
|
||||||
guac_terminal_buffer_row* old_row;
|
guac_terminal_buffer_row* row;
|
||||||
guac_terminal_buffer_row* new_row;
|
|
||||||
|
|
||||||
/* If no change, done */
|
/* If no change, done */
|
||||||
if (term->visible_cursor_row == term->cursor_row && term->visible_cursor_col == term->cursor_col)
|
if (term->cursor_visible && term->visible_cursor_row == term->cursor_row && term->visible_cursor_col == term->cursor_col)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Get old and new rows with cursor */
|
/* Clear cursor if it was visible */
|
||||||
new_row = guac_terminal_buffer_get_row(term->buffer, term->cursor_row, term->cursor_col+1);
|
if (term->visible_cursor_row != -1 && term->visible_cursor_col != -1) {
|
||||||
old_row = guac_terminal_buffer_get_row(term->buffer, term->visible_cursor_row, term->visible_cursor_col+1);
|
/* Get old row with cursor */
|
||||||
|
row = guac_terminal_buffer_get_row(term->buffer, term->visible_cursor_row, term->visible_cursor_col+1);
|
||||||
|
|
||||||
/* Clear cursor */
|
guac_char = &(row->characters[term->visible_cursor_col]);
|
||||||
guac_char = &(old_row->characters[term->visible_cursor_col]);
|
guac_char->attributes.cursor = false;
|
||||||
guac_char->attributes.cursor = false;
|
guac_terminal_display_set_columns(term->display, term->visible_cursor_row + term->scroll_offset,
|
||||||
guac_terminal_display_set_columns(term->display, term->visible_cursor_row + term->scroll_offset,
|
term->visible_cursor_col, term->visible_cursor_col, guac_char);
|
||||||
term->visible_cursor_col, term->visible_cursor_col, guac_char);
|
}
|
||||||
|
|
||||||
/* Set cursor */
|
/* Set cursor if should be visible */
|
||||||
guac_char = &(new_row->characters[term->cursor_col]);
|
if (term->cursor_visible) {
|
||||||
guac_char->attributes.cursor = true;
|
/* Get new row with cursor */
|
||||||
guac_terminal_display_set_columns(term->display, term->cursor_row + term->scroll_offset,
|
row = guac_terminal_buffer_get_row(term->buffer, term->cursor_row, term->cursor_col+1);
|
||||||
term->cursor_col, term->cursor_col, guac_char);
|
|
||||||
|
|
||||||
term->visible_cursor_row = term->cursor_row;
|
guac_char = &(row->characters[term->cursor_col]);
|
||||||
term->visible_cursor_col = term->cursor_col;
|
guac_char->attributes.cursor = true;
|
||||||
|
guac_terminal_display_set_columns(term->display, term->cursor_row + term->scroll_offset,
|
||||||
|
term->cursor_col, term->cursor_col, guac_char);
|
||||||
|
|
||||||
|
term->visible_cursor_row = term->cursor_row;
|
||||||
|
term->visible_cursor_col = term->cursor_col;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise set visible position to a sentinel value */
|
||||||
|
else {
|
||||||
|
term->visible_cursor_row = -1;
|
||||||
|
term->visible_cursor_col = -1;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1240,7 +1252,8 @@ static void __guac_terminal_resize(guac_terminal* term, int width, int height) {
|
|||||||
/* Update buffer top and cursor row based on shift */
|
/* Update buffer top and cursor row based on shift */
|
||||||
term->buffer->top += shift_amount;
|
term->buffer->top += shift_amount;
|
||||||
term->cursor_row -= shift_amount;
|
term->cursor_row -= shift_amount;
|
||||||
term->visible_cursor_row -= shift_amount;
|
if (term->visible_cursor_row != -1)
|
||||||
|
term->visible_cursor_row -= shift_amount;
|
||||||
|
|
||||||
/* Redraw characters within old region */
|
/* Redraw characters within old region */
|
||||||
__guac_terminal_redraw_rect(term, height - shift_amount, 0, height-1, width-1);
|
__guac_terminal_redraw_rect(term, height - shift_amount, 0, height-1, width-1);
|
||||||
@ -1274,7 +1287,8 @@ static void __guac_terminal_resize(guac_terminal* term, int width, int height) {
|
|||||||
/* Update buffer top and cursor row based on shift */
|
/* Update buffer top and cursor row based on shift */
|
||||||
term->buffer->top -= shift_amount;
|
term->buffer->top -= shift_amount;
|
||||||
term->cursor_row += shift_amount;
|
term->cursor_row += shift_amount;
|
||||||
term->visible_cursor_row += shift_amount;
|
if (term->visible_cursor_row != -1)
|
||||||
|
term->visible_cursor_row += shift_amount;
|
||||||
|
|
||||||
/* If scrolled enough, use scroll to fulfill entire resize */
|
/* If scrolled enough, use scroll to fulfill entire resize */
|
||||||
if (term->scroll_offset >= shift_amount) {
|
if (term->scroll_offset >= shift_amount) {
|
||||||
|
@ -337,13 +337,20 @@ struct guac_terminal {
|
|||||||
*/
|
*/
|
||||||
int cursor_col;
|
int cursor_col;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The desired visibility state of the cursor.
|
||||||
|
*/
|
||||||
|
bool cursor_visible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The row of the rendered cursor.
|
* The row of the rendered cursor.
|
||||||
|
* Will be set to -1 if the cursor is not visible.
|
||||||
*/
|
*/
|
||||||
int visible_cursor_row;
|
int visible_cursor_row;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The column of the rendered cursor.
|
* The column of the rendered cursor.
|
||||||
|
* Will be set to -1 if the cursor is not visible.
|
||||||
*/
|
*/
|
||||||
int visible_cursor_col;
|
int visible_cursor_col;
|
||||||
|
|
||||||
|
@ -432,6 +432,7 @@ static bool* __guac_terminal_get_flag(guac_terminal* term, int num, char private
|
|||||||
if (private_mode == '?') {
|
if (private_mode == '?') {
|
||||||
switch (num) {
|
switch (num) {
|
||||||
case 1: return &(term->application_cursor_keys); /* DECCKM */
|
case 1: return &(term->application_cursor_keys); /* DECCKM */
|
||||||
|
case 25: return &(term->cursor_visible); /* DECTECM */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user