Fix reset not resetting default foreground and background colors
This commit is contained in:
parent
f0c546208d
commit
3b71a016a6
@ -258,8 +258,8 @@ class CharGrid:
|
||||
self.color_profile.update_ansi_color_table(build_ansi_color_table(opts))
|
||||
self.screen = screen
|
||||
self.opts = opts
|
||||
self.original_bg = self.default_bg = color_as_int(opts.background)
|
||||
self.original_fg = self.default_fg = color_as_int(opts.foreground)
|
||||
self.default_bg = color_as_int(opts.background)
|
||||
self.default_fg = color_as_int(opts.foreground)
|
||||
self.dpix, self.dpiy = get_logical_dpi()
|
||||
self.opts = opts
|
||||
self.default_cursor = self.current_cursor = Cursor(0, 0, opts.cursor_shape, opts.cursor_blink_interval > 0)
|
||||
@ -295,27 +295,25 @@ class CharGrid:
|
||||
|
||||
def item(raw):
|
||||
if raw is None:
|
||||
return True, None
|
||||
return 0
|
||||
val = to_color(raw)
|
||||
if val is None:
|
||||
return False, None
|
||||
return True, color_as_int(val)
|
||||
return None if val is None else (color_as_int(val) << 8) | 1
|
||||
|
||||
for which, val in changes.items():
|
||||
valid, val = item(val)
|
||||
if not valid:
|
||||
val = item(val)
|
||||
if val is None:
|
||||
continue
|
||||
dirtied = True
|
||||
if which is DynamicColor.default_fg:
|
||||
self.default_fg = self.original_fg if val is None else val
|
||||
self.screen.default_fg = val
|
||||
elif which is DynamicColor.default_bg:
|
||||
self.default_bg = self.original_bg if val is None else val
|
||||
self.screen.default_bg = val
|
||||
elif which is DynamicColor.cursor_color:
|
||||
self.screen.cursor.color = 0 if val is None else (val << 8) | 1
|
||||
self.screen.cursor.color = val
|
||||
elif which is DynamicColor.highlight_fg:
|
||||
self.screen.highlight_fg = 0 if val is None else (val << 8) | 1
|
||||
self.screen.highlight_fg = val
|
||||
elif which is DynamicColor.highlight_bg:
|
||||
self.screen.highlight_bg = 0 if val is None else (val << 8) | 1
|
||||
self.screen.highlight_bg = val
|
||||
if dirtied:
|
||||
self.screen.mark_as_dirty()
|
||||
|
||||
@ -333,12 +331,16 @@ class CharGrid:
|
||||
sprites = get_boss().sprites
|
||||
is_dirty = self.screen.is_dirty()
|
||||
with sprites.lock:
|
||||
fg = self.screen.default_fg
|
||||
fg = fg >> 8 if fg & 1 else self.default_fg
|
||||
bg = self.screen.default_bg
|
||||
bg = bg >> 8 if bg & 1 else self.default_bg
|
||||
cursor_changed, history_line_added_count = self.screen.update_cell_data(
|
||||
sprites.backend, self.color_profile, addressof(self.main_sprite_map), self.default_fg, self.default_bg, force_full_refresh)
|
||||
sprites.backend, self.color_profile, addressof(self.main_sprite_map), fg, bg, force_full_refresh)
|
||||
if self.scrolled_by:
|
||||
self.scrolled_by = min(self.scrolled_by + history_line_added_count, self.screen.historybuf.count)
|
||||
self.screen.set_scroll_cell_data(
|
||||
sprites.backend, self.color_profile, addressof(self.main_sprite_map), self.default_fg, self.default_bg,
|
||||
sprites.backend, self.color_profile, addressof(self.main_sprite_map), fg, bg,
|
||||
self.scrolled_by, addressof(self.scroll_sprite_map))
|
||||
|
||||
data = self.scroll_sprite_map if self.scrolled_by else self.main_sprite_map
|
||||
|
||||
@ -289,7 +289,7 @@ typedef struct {
|
||||
unsigned int parser_state, parser_text_start, parser_buf_pos;
|
||||
bool parser_has_pending_text;
|
||||
uint8_t read_buf[READ_BUF_SZ];
|
||||
uint32_t highlight_fg, highlight_bg;
|
||||
uint32_t default_fg, default_bg, highlight_fg, highlight_bg;
|
||||
|
||||
} Screen;
|
||||
PyTypeObject Screen_Type;
|
||||
|
||||
@ -44,6 +44,7 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
|
||||
self->columns = columns; self->lines = lines;
|
||||
self->modes = empty_modes;
|
||||
self->margin_top = 0; self->margin_bottom = self->lines - 1;
|
||||
self->default_fg = 0; self->default_bg = 0;
|
||||
self->highlight_fg = 0; self->highlight_bg = 0;
|
||||
RESET_CHARSETS;
|
||||
self->callbacks = callbacks; Py_INCREF(callbacks);
|
||||
@ -69,6 +70,7 @@ screen_reset(Screen *self) {
|
||||
if (self->linebuf == self->alt_linebuf) screen_toggle_screen_buffer(self);
|
||||
linebuf_clear(self->linebuf, ' ');
|
||||
self->modes = empty_modes;
|
||||
self->default_fg = 0; self->default_bg = 0;
|
||||
self->highlight_fg = 0; self->highlight_bg = 0;
|
||||
RESET_CHARSETS;
|
||||
self->margin_top = 0; self->margin_bottom = self->lines - 1;
|
||||
@ -1306,6 +1308,8 @@ static PyMemberDef members[] = {
|
||||
{"columns", T_UINT, offsetof(Screen, columns), READONLY, "columns"},
|
||||
{"margin_top", T_UINT, offsetof(Screen, margin_top), READONLY, "margin_top"},
|
||||
{"margin_bottom", T_UINT, offsetof(Screen, margin_bottom), READONLY, "margin_bottom"},
|
||||
{"default_fg", T_ULONG, offsetof(Screen, default_fg), 0, "default_fg"},
|
||||
{"default_bg", T_ULONG, offsetof(Screen, default_bg), 0, "default_bg"},
|
||||
{"highlight_fg", T_ULONG, offsetof(Screen, highlight_fg), 0, "highlight_fg"},
|
||||
{"highlight_bg", T_ULONG, offsetof(Screen, highlight_bg), 0, "highlight_bg"},
|
||||
{NULL}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user