From 327d749ce03d25897447ec36ed4c46c0da4a72cb Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 16 Mar 2025 15:13:39 +0300 Subject: further improved monochrome terminal support: fixed reverse text on reverse backgrounds * Unfortunately we cannot use `wbkgdset(win, A_REVERSE)` if we plan to use reverse text on this background, i.e. if we want to cancel out the background A_REVERSE. * SciTECO therefore no longer uses background attributes, but only foreground attributes. When setting a reverse text, we XOR A_REVERSE into the previous attributes. * This fixes control characters especially in the info line and popups, as well as rendering of the popup scroll bars. * The command-line should now be rendered properly even on a dark-on-bright color theme (which does not yet exist). --- src/interface-curses/curses-utils.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/interface-curses/curses-utils.h') diff --git a/src/interface-curses/curses-utils.h b/src/interface-curses/curses-utils.h index 9f2e8f3..18cdd3d 100644 --- a/src/interface-curses/curses-utils.h +++ b/src/interface-curses/curses-utils.h @@ -34,3 +34,20 @@ teco_curses_add_wc(WINDOW *win, gunichar chr) gchar buf[6]; waddnstr(win, buf, g_unichar_to_utf8(chr, buf)); } + +/** + * Clear from the current position until the end of the given + * curses window with the current \b foreground attributes. + * This is similar to wclrtobot(), but does not use the + * background attributes. + */ +static inline void +teco_curses_clrtobot(WINDOW *win) +{ + int max_x, max_y; + getmaxyx(win, max_y, max_x); + if (getcurx(win)+1 < max_x) + whline(win, ' ', max_x - getcurx(win)); + for (int y = getcury(win)+1; y <= max_y; y++) + mvwhline(win, y, 0, ' ', max_x); +} -- cgit v1.2.3