More comprehensive reset of color profile on screen reset

This commit is contained in:
Kovid Goyal 2025-12-09 08:18:36 +05:30
parent f1cc676ea6
commit 8448f737ae
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 17 additions and 3 deletions

View file

@ -492,6 +492,20 @@ colorprofile_push_colors(ColorProfile *self, unsigned int idx) {
return false;
}
void
colorprofile_reset(ColorProfile *self) {
memcpy(self->color_table, self->orig_color_table, sizeof(FG_BG_256));
self->dirty = true;
self->color_stack_idx = 0;
zero_at_ptr(&self->overridden);
for (unsigned i = 0; i < arraysz(self->overriden_transparent_colors); i++) {
zero_at_ptr(self->overriden_transparent_colors + i);
}
for (unsigned i = 0; i < self->color_stack_sz; i++) {
zero_at_ptr(self->color_stack + i);
}
}
bool
colorprofile_pop_colors(ColorProfile *self, unsigned int idx) {
if (idx == 0) {

View file

@ -314,6 +314,7 @@ bool schedule_write_to_child_python(unsigned long id, const char *prefix, PyObje
bool set_iutf8(int, bool);
DynamicColor colorprofile_to_color(const ColorProfile *self, DynamicColor entry, DynamicColor defval);
void colorprofile_reset(ColorProfile *self);
bool colorprofile_to_transparent_color(const ColorProfile *self, unsigned index, color_type *color, float *opacity);
color_type
colorprofile_to_color_with_fallback(ColorProfile *self, DynamicColor entry, DynamicColor defval, DynamicColor fallback, DynamicColor falback_defval);

View file

@ -210,9 +210,8 @@ screen_reset(Screen *self) {
self->is_dirty = true;
clear_all_selections(self);
screen_cursor_position(self, 1, 1);
set_dynamic_color(self, 110, NULL);
set_dynamic_color(self, 111, NULL);
set_color_table_color(self, 104, NULL);
set_dynamic_color(self, 111, NULL); // does default_bg_changed processing
colorprofile_reset(self->color_profile);
CALLBACK("on_reset", NULL)
}