diff --git a/kitty/char_grid.py b/kitty/char_grid.py index cbcdd662d..25eae6971 100644 --- a/kitty/char_grid.py +++ b/kitty/char_grid.py @@ -309,7 +309,7 @@ class CharGrid: elif which is DynamicColor.default_bg: self.screen.default_bg = val elif which is DynamicColor.cursor_color: - self.screen.cursor.color = val + self.screen.cursor_color = val elif which is DynamicColor.highlight_fg: self.screen.highlight_fg = val elif which is DynamicColor.highlight_bg: @@ -511,7 +511,7 @@ class CharGrid: ul = cursor_program.uniform_location left = sg.xstart + cursor.x * sg.dx top = sg.ystart - cursor.y * sg.dy - cc = self.screen.cursor.color + cc = self.screen.cursor_color col = color_from_int(cc >> 8) if cc & 1 else self.opts.cursor shape = cursor.shape or self.default_cursor.shape alpha = self.opts.cursor_opacity diff --git a/kitty/cursor.c b/kitty/cursor.c index 087f5f45c..aef382725 100644 --- a/kitty/cursor.c +++ b/kitty/cursor.c @@ -24,15 +24,15 @@ dealloc(Cursor* self) { #define EQ(x) (a->x == b->x) static int __eq__(Cursor *a, Cursor *b) { - return EQ(bold) && EQ(italic) && EQ(strikethrough) && EQ(reverse) && EQ(decoration) && EQ(fg) && EQ(bg) && EQ(decoration_fg) && EQ(x) && EQ(y) && EQ(shape) && EQ(blink) && EQ(color); + return EQ(bold) && EQ(italic) && EQ(strikethrough) && EQ(reverse) && EQ(decoration) && EQ(fg) && EQ(bg) && EQ(decoration_fg) && EQ(x) && EQ(y) && EQ(shape) && EQ(blink); } #define BOOL(x) ((x) ? Py_True : Py_False) static PyObject * repr(Cursor *self) { return PyUnicode_FromFormat( - "Cursor(x=%u, y=%u, shape=%d, blink=%R, color=#%08x, fg=#%08x, bg=#%08x, bold=%R, italic=%R, reverse=%R, strikethrough=%R, decoration=%d, decoration_fg=#%08x)", - self->x, self->y, self->shape, BOOL(self->blink), self->color, self->fg, self->bg, BOOL(self->bold), BOOL(self->italic), BOOL(self->reverse), BOOL(self->strikethrough), self->decoration, self->decoration_fg + "Cursor(x=%u, y=%u, shape=%d, blink=%R, fg=#%08x, bg=#%08x, bold=%R, italic=%R, reverse=%R, strikethrough=%R, decoration=%d, decoration_fg=#%08x)", + self->x, self->y, self->shape, BOOL(self->blink), self->fg, self->bg, BOOL(self->bold), BOOL(self->italic), BOOL(self->reverse), BOOL(self->strikethrough), self->decoration, self->decoration_fg ); } @@ -52,12 +52,11 @@ void cursor_reset(Cursor *self) { cursor_reset_display_attrs(self); self->x = 0; self->y = 0; self->shape = 0; self->blink = false; - self->color = 0; } void cursor_copy_to(Cursor *src, Cursor *dest) { #define CCY(x) dest->x = src->x; - CCY(x); CCY(y); CCY(shape); CCY(blink); CCY(color); + CCY(x); CCY(y); CCY(shape); CCY(blink); CCY(bold); CCY(italic); CCY(strikethrough); CCY(reverse); CCY(decoration); CCY(fg); CCY(bg); CCY(decoration_fg); } @@ -65,11 +64,6 @@ static PyObject* copy(Cursor *self); #define copy_doc "Create a clone of this cursor" -static PyObject* color_get(Cursor *self, void UNUSED *closure) { - if (!(self->color & 0xFF)) { Py_RETURN_NONE; } - return Py_BuildValue("BBB", (self->color >> 24) & 0xFF, (self->color >> 16) & 0xFF, (self->color >> 8) & 0xFF); -} - // Boilerplate {{{ BOOL_GETSET(Cursor, bold) @@ -82,7 +76,6 @@ static PyMemberDef members[] = { {"x", T_UINT, offsetof(Cursor, x), 0, "x"}, {"y", T_UINT, offsetof(Cursor, y), 0, "y"}, {"shape", T_UBYTE, offsetof(Cursor, shape), 0, "shape"}, - {"color", T_ULONG, offsetof(Cursor, color), 0, "color"}, {"decoration", T_UBYTE, offsetof(Cursor, decoration), 0, "decoration"}, {"fg", T_ULONG, offsetof(Cursor, fg), 0, "fg"}, {"bg", T_ULONG, offsetof(Cursor, bg), 0, "bg"}, @@ -96,7 +89,6 @@ static PyGetSetDef getseters[] = { GETSET(reverse) GETSET(strikethrough) GETSET(blink) - {"color", (getter) color_get, NULL, "color", NULL}, {NULL} /* Sentinel */ }; diff --git a/kitty/data-types.h b/kitty/data-types.h index 1844b8ac8..8d2522b10 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -188,7 +188,7 @@ typedef struct { bool bold, italic, reverse, strikethrough, blink; unsigned int x, y; uint8_t decoration, shape; - unsigned long fg, bg, decoration_fg, color; + unsigned long fg, bg, decoration_fg; } Cursor; PyTypeObject Cursor_Type; @@ -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 default_fg, default_bg, highlight_fg, highlight_bg; + uint32_t default_fg, default_bg, highlight_fg, highlight_bg, cursor_color; } Screen; PyTypeObject Screen_Type; diff --git a/kitty/screen.c b/kitty/screen.c index dd1653d3c..ec03b233a 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -46,6 +46,7 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) { 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; + self->cursor_color = 0; RESET_CHARSETS; self->callbacks = callbacks; Py_INCREF(callbacks); self->cursor = alloc_cursor(); @@ -72,6 +73,7 @@ screen_reset(Screen *self) { self->modes = empty_modes; self->default_fg = 0; self->default_bg = 0; self->highlight_fg = 0; self->highlight_bg = 0; + self->cursor_color = 0; RESET_CHARSETS; self->margin_top = 0; self->margin_bottom = self->lines - 1; screen_normal_keypad_mode(self); @@ -1312,6 +1314,7 @@ static PyMemberDef members[] = { {"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"}, + {"cursor_color", T_ULONG, offsetof(Screen, cursor_color), 0, "cursor_color"}, {NULL} };