Implement save/restore cursor.

This commit is contained in:
Michael Jumper 2013-05-21 00:19:53 -07:00
parent c220a4875c
commit b38412fd3d
3 changed files with 29 additions and 2 deletions

View File

@ -122,6 +122,16 @@ struct guac_terminal {
*/
int visible_cursor_col;
/**
* The row of the saved cursor (ESC 7).
*/
int saved_cursor_row;
/**
* The column of the saved cursor (ESC 7).
*/
int saved_cursor_col;
/**
* The attributes which will be applied to future characters.
*/

View File

@ -83,8 +83,8 @@ guac_terminal* guac_terminal_create(guac_client* client,
term->current_attributes = default_char.attributes;
term->default_char = default_char;
term->cursor_row = term->visible_cursor_row = 0;
term->cursor_col = term->visible_cursor_col = 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->term_width = width / term->display->char_width;
term->term_height = height / term->display->char_height;

View File

@ -172,6 +172,23 @@ int guac_terminal_escape(guac_terminal* term, char c) {
term->char_handler = guac_terminal_csi;
break;
case '7': /* Save Cursor (DECSC) */
term->saved_cursor_row = term->cursor_row;
term->saved_cursor_col = term->cursor_col;
break;
case '8': /* Restore Cursor (DECRC) */
term->cursor_row = term->saved_cursor_row;
if (term->cursor_row >= term->term_height)
term->cursor_row = term->term_height - 1;
term->cursor_col = term->saved_cursor_col;
if (term->cursor_col >= term->term_width)
term->cursor_col = term->term_width - 1;
break;
case 'M': /* Reverse Linefeed */
term->cursor_row--;