From 2078e1675d8ec1e1c90e1ce7063d0a70d54ea167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 4 Dec 2020 18:43:06 +0100 Subject: [PATCH] =?UTF-8?q?render:=20ime:=20draw=20a=20=E2=80=98bar?= =?UTF-8?q?=E2=80=99=20cursor=20when=20the=20pre-edit=20cursor=E2=80=99s?= =?UTF-8?q?=20begin=20=3D=3D=20end?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/render.c b/render.c index 34323801..2a3ab5b8 100644 --- a/render.c +++ b/render.c @@ -1092,25 +1092,33 @@ render_ime_preedit(struct terminal *term, struct buffer *buf) render_cell(term, buf->pix[0], row, col_idx + i, row_idx, false); } - /* Hollow cursor */ int start = term->ime.preedit.cursor.start; int end = term->ime.preedit.cursor.end; - if (!term->ime.preedit.cursor.hidden && end > start) { + if (!term->ime.preedit.cursor.hidden) { + const struct cell *start_cell = &term->ime.preedit.cells[start]; pixman_color_t fg = color_hex_to_pixman(term->colors.fg); pixman_color_t bg = color_hex_to_pixman(term->colors.bg); pixman_color_t cursor_color, text_color; cursor_colors_for_cell( - term, &term->ime.preedit.cells[start], - &fg, &bg, &cursor_color, &text_color); + term, start_cell, &fg, &bg, &cursor_color, &text_color); int x = term->margins.left + (col_idx + start) * term->cell_width; int y = term->margins.top + row_idx * term->cell_height; - int cols = end - start; - draw_unfocused_block(term, buf->pix[0], &cursor_color, x, y, cols); + if (end == start) { + /* Bar */ + struct fcft_font *font = attrs_to_font(term, &start_cell->attrs); + draw_bar(term, buf->pix[0], font, &cursor_color, x, y); + } + + else if (end > start) { + /* Hollow cursor */ + int cols = end - start; + draw_unfocused_block(term, buf->pix[0], &cursor_color, x, y, cols); + } } /* Restore original content (but do not render) */