mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Fix changing colours in Change Settings.
Sinceca9cd983e1
, changing colour config mid-session had no effect (until the palette was reset for some other reason). Now it does take effect immediately (provided that the palette has not been overridden by escape sequence -- this is new withca9cd983e1
). This changes the semantics of palette_reset(): the only important parameter when doing that is whether we keep escape sequence overrides -- there's no harm in re-fetching config and platform colours whether or not they've changed -- so that's what the parameter becomes (with a sense that doesn't require changing the call sites). The other part of this change is actually remembering to trigger this when the configuration is changed. (cherry picked from commit1e726c94e8
)
This commit is contained in:
parent
27a04d96a3
commit
ff53c6716a
2
putty.h
2
putty.h
@ -1790,7 +1790,7 @@ void term_keyinputw(Terminal *, const wchar_t * widebuf, int len);
|
||||
void term_get_cursor_position(Terminal *term, int *x, int *y);
|
||||
void term_setup_window_titles(Terminal *term, const char *title_hostname);
|
||||
void term_notify_minimised(Terminal *term, bool minimised);
|
||||
void term_notify_palette_overrides_changed(Terminal *term);
|
||||
void term_notify_palette_changed(Terminal *term);
|
||||
void term_notify_window_pos(Terminal *term, int x, int y);
|
||||
void term_notify_window_size_pixels(Terminal *term, int x, int y);
|
||||
void term_palette_override(Terminal *term, unsigned osc4_index, rgb rgb);
|
||||
|
51
terminal.c
51
terminal.c
@ -1629,6 +1629,7 @@ void term_reconfig(Terminal *term, Conf *conf)
|
||||
* Mode, BCE, blinking text, character classes.
|
||||
*/
|
||||
bool reset_wrap, reset_decom, reset_bce, reset_tblink, reset_charclass;
|
||||
bool palette_changed = false;
|
||||
int i;
|
||||
|
||||
reset_wrap = (conf_get_bool(term->conf, CONF_wrap_mode) !=
|
||||
@ -1674,6 +1675,29 @@ void term_reconfig(Terminal *term, Conf *conf)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Just setting conf is sufficient to cause colour setting changes
|
||||
* to appear on the next ESC]R palette reset. But we should also
|
||||
* check whether any colour settings have been changed, so that
|
||||
* they can be updated immediately if they haven't been overridden
|
||||
* by some escape sequence.
|
||||
*/
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < CONF_NCOLOURS; i++) {
|
||||
for (j = 0; j < 3; j++)
|
||||
if (conf_get_int_int(term->conf, CONF_colours, i*3+j) !=
|
||||
conf_get_int_int(conf, CONF_colours, i*3+j))
|
||||
break;
|
||||
if (j < 3) {
|
||||
/* Actually enacting the change has to be deferred
|
||||
* until the new conf is installed. */
|
||||
palette_changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
conf_free(term->conf);
|
||||
term->conf = conf_copy(conf);
|
||||
|
||||
@ -1702,6 +1726,8 @@ void term_reconfig(Terminal *term, Conf *conf)
|
||||
if (!conf_get_str(term->conf, CONF_printer)) {
|
||||
term_print_finish(term);
|
||||
}
|
||||
if (palette_changed)
|
||||
term_notify_palette_changed(term);
|
||||
term_schedule_tblink(term);
|
||||
term_schedule_cblink(term);
|
||||
term_copy_stuff_from_conf(term);
|
||||
@ -1829,9 +1855,13 @@ static void palette_rebuild(Terminal *term)
|
||||
}
|
||||
}
|
||||
|
||||
static void palette_reset(Terminal *term, bool overrides_only)
|
||||
/*
|
||||
* Rebuild the palette from configuration and platform colours.
|
||||
* If 'keep_overrides' set, any escape-sequence-specified overrides will
|
||||
* remain in place.
|
||||
*/
|
||||
static void palette_reset(Terminal *term, bool keep_overrides)
|
||||
{
|
||||
if (!overrides_only) {
|
||||
for (unsigned i = 0; i < OSC4_NCOLOURS; i++)
|
||||
term->subpalettes[SUBPAL_CONF].present[i] = true;
|
||||
|
||||
@ -1862,13 +1892,6 @@ static void palette_reset(Terminal *term, bool overrides_only)
|
||||
col->r = col->g = col->b = shade;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get rid of all escape-sequence configuration.
|
||||
*/
|
||||
for (unsigned i = 0; i < OSC4_NCOLOURS; i++)
|
||||
term->subpalettes[SUBPAL_SESSION].present[i] = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Re-fetch any OS-local overrides.
|
||||
*/
|
||||
@ -1876,6 +1899,14 @@ static void palette_reset(Terminal *term, bool overrides_only)
|
||||
term->subpalettes[SUBPAL_PLATFORM].present[i] = false;
|
||||
win_palette_get_overrides(term->win, term);
|
||||
|
||||
if (!keep_overrides) {
|
||||
/*
|
||||
* Get rid of all escape-sequence configuration.
|
||||
*/
|
||||
for (unsigned i = 0; i < OSC4_NCOLOURS; i++)
|
||||
term->subpalettes[SUBPAL_SESSION].present[i] = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rebuild the composite palette.
|
||||
*/
|
||||
@ -7593,7 +7624,7 @@ void term_notify_minimised(Terminal *term, bool minimised)
|
||||
term->minimised = minimised;
|
||||
}
|
||||
|
||||
void term_notify_palette_overrides_changed(Terminal *term)
|
||||
void term_notify_palette_changed(Terminal *term)
|
||||
{
|
||||
palette_reset(term, true);
|
||||
}
|
||||
|
@ -2394,7 +2394,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
|
||||
if (conf_get_bool(conf, CONF_system_colour) !=
|
||||
conf_get_bool(prev_conf, CONF_system_colour))
|
||||
term_notify_palette_overrides_changed(term);
|
||||
term_notify_palette_changed(term);
|
||||
|
||||
/* Pass new config data to the terminal */
|
||||
term_reconfig(term, conf);
|
||||
@ -3384,7 +3384,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
case WM_SYSCOLORCHANGE:
|
||||
if (conf_get_bool(conf, CONF_system_colour)) {
|
||||
/* Refresh palette from system colours. */
|
||||
term_notify_palette_overrides_changed(term);
|
||||
term_notify_palette_changed(term);
|
||||
init_palette();
|
||||
/* Force a repaint of the terminal window. */
|
||||
term_invalidate(term);
|
||||
|
Loading…
Reference in New Issue
Block a user