From 7fece4c0a8a685d5ada4dfb89ce5fd7efa9f38fa Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 15 Jan 2026 01:06:38 +0100 Subject: Curses: fixed flickering of the hardware cursor * Disabling the cursor with every key press caused a cursor status change when using CARETSTYLE_CURSES, which resulted in flickering, especially when using the cursor keys or typing quickly. * Instead we now disable the cursor only if CARETSTYLE_CURSES is NOT used on the command line. * It would be good to use curs_set(2) for `^T` - in some emulators it causes e.g. a blinking cursor - but it wouldn't be visible in simpleterm. This is probably just because it doesn't guarantee any contrast. * This was broken in v2.5.1. --- src/interface-curses/interface.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 94501cb..d07ff21 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -993,10 +993,11 @@ teco_interface_getch(gboolean widechar) /* * Signal that we accept input by drawing a real cursor in the message bar. + * FIXME: curs_set(2) would be better, but isn't always visible. */ wmove(teco_interface.msg_window, 0, 0); - curs_set(1); wrefresh(teco_interface.msg_window); + curs_set(1); gchar buf[4]; gint i = 0; @@ -1023,7 +1024,6 @@ teco_interface_getch(gboolean widechar) i = 0; } while (cp < 0); - curs_set(0); return cp; } @@ -1836,16 +1836,6 @@ teco_interface_refresh(gboolean force) if (G_UNLIKELY(force)) clearok(curscr, TRUE); - /* - * Let Scinterm enable/disable the hardware cursor - * based on the CARETSTYLE_CURSES. - * Doing this repeatedly ensures you can change the - * caret style interactively. - * Also, window resizes enable the cursor on PDCurses/wincon - * sometimes (FIXME). - */ - curs_set(0); - /* * Info window is updated very often which is very * costly, especially when using PDC_set_title(), @@ -1870,6 +1860,19 @@ teco_interface_refresh(gboolean force) */ teco_view_update_cursor(teco_cmdline.view); doupdate(); + + /* + * Scinterm enables/disables the hardware cursor, + * but only if CARETSTYLE_CURSES is used. + * Disabling the cursor repeatedly ensures you can change + * the caret style interactively. + * It also makes sure the cursor is reset after + * teco_interface_getch(). + * Also, window resizes sometimes enable the hardware cursor on + * PDCurses/wincon (FIXME). + */ + if (!(teco_view_ssm(teco_cmdline.view, SCI_GETCARETSTYLE, 0, 0) & CARETSTYLE_CURSES)) + curs_set(0); } #if NCURSES_MOUSE_VERSION >= 2 -- cgit v1.2.3