From 37d8808d4009df862da9976c765d5958ce5d2a63 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 10 Jan 2026 15:58:01 +0100 Subject: Curses: the hardware cursor is enabled by default now on the command line If you dislike this, you can always revert to the old style by adding the following to your profile: 0,2048ED 2#16@ES/SETCARETSTYLE//$ 2048,0ED --- src/interface-curses/interface.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'src/interface-curses') diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 9ace2ee..94501cb 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -395,6 +395,13 @@ teco_view_noutrefresh(teco_view_t *ctx) scintilla_noutrefresh(ctx); } +static inline void +teco_view_update_cursor(teco_view_t *ctx) +{ + if (teco_view_ssm(ctx, SCI_GETCARETSTYLE, 0, 0) & CARETSTYLE_CURSES) + scintilla_update_cursor(ctx); +} + static inline WINDOW * teco_view_get_window(teco_view_t *ctx) { @@ -445,6 +452,10 @@ teco_interface_init(void) * Instead we use INDIC_SQUIGGLE, which is rendered as A_UNDERLINE. */ teco_cmdline_ssm(SCI_INDICSETSTYLE, INDICATOR_RUBBEDOUT, INDIC_SQUIGGLE); + /* + * Enable hardware cursor by default. + */ + teco_cmdline_ssm(SCI_SETCARETSTYLE, CARETSTYLE_CURSES, 0); /* * On all platforms except Curses/XTerm, it's @@ -784,8 +795,6 @@ teco_interface_init_interactive(GError **error) cbreak(); noecho(); - /* Scintilla draws its own cursor */ - curs_set(0); /* * This has also been observed to reduce flickering * in teco_interface_refresh(). @@ -1827,6 +1836,16 @@ 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(), @@ -1839,6 +1858,17 @@ teco_interface_refresh(gboolean force) wnoutrefresh(teco_interface.msg_window); teco_view_noutrefresh(teco_cmdline.view); teco_curses_info_popup_noutrefresh(&teco_interface.popup); + /* + * If hardware cursors (CARETSTYLE_CURSES) are enabled on the + * command-line view, make sure that the cursor is left + * in the correct position. + * + * FIXME: This shouldn't be necessary if we refreshed the command-line + * view last. Also, if we wanted to support the hardware cursor + * in the main view as well, we'd have to handle a possibly + * overlappig info popup. + */ + teco_view_update_cursor(teco_cmdline.view); doupdate(); } @@ -2115,11 +2145,6 @@ teco_interface_event_loop_iter(void) return; #ifdef KEY_RESIZE case KEY_RESIZE: - /* - * At least on PDCurses/Wincon, the hardware cursor is sometimes - * reactivated. - */ - curs_set(0); teco_interface_resize_all_windows(); break; #endif -- cgit v1.2.3