diff --git a/st.c b/st.c index fbcd9e0..4e7ab10 100644 --- a/st.c +++ b/st.c @@ -134,7 +134,7 @@ enum term_mode { MODE_MOUSESGR = 1 << 12, MODE_8BIT = 1 << 13, MODE_BLINK = 1 << 14, - MODE_FBLINK = 1 << 15, + MODE_CURSORBLINK = 1 << 15, MODE_FOCUS = 1 << 16, MODE_MOUSEX10 = 1 << 17, MODE_MOUSEMANY = 1 << 18, @@ -390,6 +390,7 @@ static void strparse(void); static void strreset(void); static int tattrset(int); +static int cursorset(int); static void tprinter(char *, size_t); static void tdumpsel(void); static void tdumpline(int); @@ -1612,6 +1613,25 @@ ttyresize(void) fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno)); } +/* + * cursorset() + * Check for cursor attr + */ +int +cursorset(int attr) +{ + /* For now, only ATTR_BLINK is considered */ + switch (xw.cursor) { + case 0: /* Blinking Block */ + case 1: /* Blinking Block (Default) */ + case 3: /* Blinking Underline */ + case 5: /* Blinking bar */ + return(1); + default: + return(0); + } +} + int tattrset(int attr) { @@ -4008,6 +4028,12 @@ xdrawcursor(void) if (IS_SET(MODE_HIDE)) return; + if (cursorset(ATTR_BLINK)) { + if ((term.mode & MODE_CURSORBLINK) == 0) { + /* Every other time, leave unpainted */ + return; + } + } /* draw the new one */ if (xw.state & WIN_FOCUSED) { @@ -4393,8 +4419,10 @@ run(void) ttyread(); if (blinktimeout) { blinkset = tattrset(ATTR_BLINK); - if (!blinkset) + if (!blinkset) { MODBIT(term.mode, 0, MODE_BLINK); + } + blinkset |= cursorset(ATTR_BLINK); } } @@ -4409,7 +4437,7 @@ run(void) dodraw = 0; if (blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) { tsetdirtattr(ATTR_BLINK); - term.mode ^= MODE_BLINK; + term.mode ^= (MODE_BLINK | MODE_CURSORBLINK); lastblink = now; dodraw = 1; }