From 42a15b157827dbd9c981416c8919ce5f5c907331 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Mon, 2 Sep 2019 15:03:33 +0100 Subject: console: Use icu to provide proper UTF-8 editing --- src/imv.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/imv.c') diff --git a/src/imv.c b/src/imv.c index a612bb2..4231fd4 100644 --- a/src/imv.c +++ b/src/imv.c @@ -377,7 +377,7 @@ static void key_handler(struct imv *imv, const struct imv_event *event) { if (imv_console_is_active(imv->console)) { - if (imv_console_key(imv->console, event->data.keyboard.keyname)) { + if (imv_console_key(imv->console, event->data.keyboard.description)) { imv->need_redraw = true; return; } @@ -1209,8 +1209,20 @@ static void render_window(struct imv *imv) imv_canvas_fill_rectangle(imv->canvas, 0, wh - height - bottom_offset, ww, height + bottom_offset); imv_canvas_color(imv->canvas, 1, 1, 1, 1); - imv_canvas_printf(imv->canvas, 0, wh - height - bottom_offset, - ":%s\u2588", imv_console_prompt(imv->console)); + + int x = 0; + /* draw pre-cursor text */ + x += imv_canvas_printf(imv->canvas, x, wh - height - bottom_offset, + ":%.*s", + imv_console_prompt_cursor(imv->console), + imv_console_prompt(imv->console)); + /* draw the cursor */ + imv_canvas_color(imv->canvas, 1, 1, 1, 0.5); + imv_canvas_printf(imv->canvas, x, wh - height - bottom_offset, "\u2588"); + /* any any remaining text on top of the cursor */ + imv_canvas_color(imv->canvas, 1, 1, 1, 1); + imv_canvas_printf(imv->canvas, x, wh - height - bottom_offset, "%s", + imv_console_prompt(imv->console) + imv_console_prompt_cursor(imv->console)); } imv_canvas_draw(imv->canvas); -- cgit v1.2.3