1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00

Save and restore true-colour state with the cursor.

I spotted this myself while looking through the code in search of the
cause of the background-colour-erase bug: saving and restoring the
cursor via ESC 7 / ESC 8 ought to also save and restore the current
graphics rendition attributes including foreground and background
colour settings, but it was not saving and restoring the new
term->curr_truecolour along with term->curr_attr.

So there's now a term->save_truecolour to keep that in, and also a
term->alt_save_truecolour to take account of the fact that all the
saved cursor state variables get swapped out _again_ when switching
between the main and alternate screens.

(However, there is not a term->alt_truecolour to complete the cross
product, because the _active_ graphics rendition is carried over when
switching between the terminal screens; it's only the _saved_ one from
ESC 7 / ESC 8 that is saved separately. That's consistent with the
behaviour we've had all along for ordinary fg/bg colour selection.)
This commit is contained in:
Simon Tatham 2017-10-08 13:45:08 +01:00
parent 96a088195f
commit e3d92df936
2 changed files with 9 additions and 0 deletions

View File

@ -1297,6 +1297,7 @@ static void power_on(Terminal *term, int clear)
term->default_attr = term->save_attr =
term->alt_save_attr = term->curr_attr = ATTR_DEFAULT;
term->curr_truecolour.fg = term->curr_truecolour.bg = optionalrgb_none;
term->save_truecolour = term->alt_save_truecolour = term->curr_truecolour;
term->term_editing = term->term_echoing = FALSE;
term->app_cursor_keys = conf_get_int(term->conf, CONF_app_cursor);
term->app_keypad_keys = conf_get_int(term->conf, CONF_app_keypad);
@ -1987,6 +1988,7 @@ static void swap_screen(Terminal *term, int which, int reset, int keep_cur_pos)
{
int t;
pos tp;
truecolour ttc;
tree234 *ttr;
if (!which)
@ -2051,6 +2053,10 @@ static void swap_screen(Terminal *term, int which, int reset, int keep_cur_pos)
if (!reset && !keep_cur_pos)
term->save_attr = term->alt_save_attr;
term->alt_save_attr = t;
ttc = term->save_truecolour;
if (!reset && !keep_cur_pos)
term->save_truecolour = term->alt_save_truecolour;
term->alt_save_truecolour = ttc;
t = term->save_utf;
if (!reset && !keep_cur_pos)
term->save_utf = term->alt_save_utf;
@ -2346,6 +2352,7 @@ static void save_cursor(Terminal *term, int save)
if (save) {
term->savecurs = term->curs;
term->save_attr = term->curr_attr;
term->save_truecolour = term->curr_truecolour;
term->save_cset = term->cset;
term->save_utf = term->utf;
term->save_wnext = term->wrapnext;
@ -2360,6 +2367,7 @@ static void save_cursor(Terminal *term, int save)
term->curs.y = term->rows - 1;
term->curr_attr = term->save_attr;
term->curr_truecolour = term->save_truecolour;
term->cset = term->save_cset;
term->utf = term->save_utf;
term->wrapnext = term->save_wnext;

View File

@ -140,6 +140,7 @@ struct terminal_tag {
/* ESC 7 saved state for the alternate screen */
pos alt_savecurs;
int alt_save_attr;
truecolour alt_save_truecolour;
int alt_save_cset, alt_save_csattr;
int alt_save_utf, alt_save_wnext;
int alt_save_sco_acs;