diff --git a/docs/changelog.rst b/docs/changelog.rst index dbf73161c..b1ccd6935 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -91,6 +91,8 @@ Detailed list of changes - When reporting unused activity in a window, ignore activity that occurs soon after a window resize (:iss:`5881`) +- Fix using :opt:`cursor` = ``none`` not working on text that has reverse video (:iss:`5897`) + 0.26.5 [2022-11-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/line.c b/kitty/line.c index bb9cba7a3..9d5d31802 100644 --- a/kitty/line.c +++ b/kitty/line.c @@ -626,11 +626,17 @@ resolve_color(ColorProfile *cp, color_type val, color_type defval) { } bool -colors_for_cell(Line *self, ColorProfile *cp, index_type *x, color_type *fg, color_type *bg) { +colors_for_cell(Line *self, ColorProfile *cp, index_type *x, color_type *fg, color_type *bg, bool *reversed) { if (*x >= self->xnum) return false; if (*x > 0 && !self->gpu_cells[*x].attrs.width && self->gpu_cells[*x-1].attrs.width == 2) (*x)--; *fg = resolve_color(cp, self->gpu_cells[*x].fg, *fg); *bg = resolve_color(cp, self->gpu_cells[*x].bg, *bg); + if (self->gpu_cells[*x].attrs.reverse) { + color_type t = *fg; + *fg = *bg; + *bg = t; + *reversed = true; + } return true; } diff --git a/kitty/lineops.h b/kitty/lineops.h index fc7d058e2..cbba20d74 100644 --- a/kitty/lineops.h +++ b/kitty/lineops.h @@ -129,4 +129,4 @@ void historybuf_clear(HistoryBuf *self); void mark_text_in_line(PyObject *marker, Line *line); bool line_has_mark(Line *, uint16_t mark); PyObject* as_text_generic(PyObject *args, void *container, get_line_func get_line, index_type lines, ANSIBuf *ansibuf, bool add_trailing_newline); -bool colors_for_cell(Line *self, ColorProfile *cp, index_type *x, color_type *fg, color_type *bg); +bool colors_for_cell(Line *self, ColorProfile *cp, index_type *x, color_type *fg, color_type *bg, bool *reversed); diff --git a/kitty/screen.c b/kitty/screen.c index 97d63ed70..ba04248a2 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2227,10 +2227,11 @@ get_line_edge_colors(Screen *self, color_type *left, color_type *right) { color_type left_cell_fg = OPT(foreground), left_cell_bg = OPT(background), right_cell_bg = OPT(background), right_cell_fg = OPT(foreground); index_type cell_color_x = 0; char_type left_char = line_get_char(line, cell_color_x); - colors_for_cell(line, self->color_profile, &cell_color_x, &left_cell_fg, &left_cell_bg); + bool reversed = false; + colors_for_cell(line, self->color_profile, &cell_color_x, &left_cell_fg, &left_cell_bg, &reversed); if (line->xnum > 0) cell_color_x = line->xnum - 1; char_type right_char = line_get_char(line, cell_color_x); - colors_for_cell(line, self->color_profile, &cell_color_x, &right_cell_fg, &right_cell_bg); + colors_for_cell(line, self->color_profile, &cell_color_x, &right_cell_fg, &right_cell_bg, &reversed); *left = effective_cell_edge_color(left_char, left_cell_fg, left_cell_bg, true); *right = effective_cell_edge_color(right_char, right_cell_fg, right_cell_bg, false); return true; diff --git a/kitty/shaders.c b/kitty/shaders.c index b0e8d06f5..21a391bb1 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -332,9 +332,10 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c color_type cell_fg = rd->default_fg, cell_bg = rd->default_bg; index_type cell_color_x = screen->cursor->x; bool cursor_ok = screen->cursor->x < screen->columns && screen->cursor->y < screen->lines; + bool reversed = false; if (cursor_ok) { linebuf_init_line(screen->linebuf, screen->cursor->y); - colors_for_cell(screen->linebuf->line, screen->color_profile, &cell_color_x, &cell_fg, &cell_bg); + colors_for_cell(screen->linebuf->line, screen->color_profile, &cell_color_x, &cell_fg, &cell_bg, &reversed); } if (screen->color_profile->overridden.cursor_color.type == COLOR_IS_INDEX || screen->color_profile->overridden.cursor_color.type == COLOR_IS_RGB) { // since the program is controlling the cursor color we hope it has chosen one