sfeed_curses

[fork] sfeed (atom feed) reader
Log | Files | Refs | README | LICENSE

commit fd900052a71824adf321d6c11bfe3398105e3da5
parent 6e524876311fad92e9501cf04bfd9db88f1732ba
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Wed, 19 Aug 2020 19:05:48 +0200

improve cursor visibility and behaviour on some terminals

This is for terminals that cannot hide the cursor.

Noticed on OpenBSD, DragonFlyBSD and Illumos/OpenIndiana.

Diffstat:
Msfeed_curses.c | 26+++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -411,24 +411,32 @@ cursormode(int on) } void -cursorsave(void) +cursormove(int x, int y) { - /*ttywrite("\x1b""7");*/ - ttywrite(tparm(save_cursor, 0, 0, 0, 0, 0, 0, 0, 0, 0)); + /*ttywritef("\x1b[%d;%dH", y + 1, x + 1);*/ + ttywrite(tparm(cursor_address, y, x, 0, 0, 0, 0, 0, 0, 0)); } void -cursorrestore(void) +cursorsave(void) { - /*ttywrite("\x1b""8");*/ - ttywrite(tparm(restore_cursor, 0, 0, 0, 0, 0, 0, 0, 0, 0)); + /*ttywrite("\x1b""7");*/ /* save cursor */ + + /* do not save the cursor if it won't be restored anyway */ + if (cursor_invisible) + ttywrite(tparm(save_cursor, 0, 0, 0, 0, 0, 0, 0, 0, 0)); } void -cursormove(int x, int y) +cursorrestore(void) { - /*ttywritef("\x1b[%d;%dH", y + 1, x + 1);*/ - ttywrite(tparm(cursor_address, y, x, 0, 0, 0, 0, 0, 0, 0)); + /*ttywrite("\x1b""8");*/ /* restore cursor */ + + /* if the cursor cannot be hidden then move to a consistent position */ + if (cursor_invisible) + ttywrite(tparm(restore_cursor, 0, 0, 0, 0, 0, 0, 0, 0, 0)); + else + cursormove(0, 0); } void