From d1167672d5d985b51a0bffa2f6cb7e5a3c60a8a7 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Thu, 11 Dec 2014 14:06:09 -0500 Subject: [PATCH] subvert blinking code to blink cursor --- config.h | 2 +- st.c | 33 ++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/config.h b/config.h index f7e1c5a..804ef30 100644 --- a/config.h +++ b/config.h @@ -39,7 +39,7 @@ static unsigned int actionfps = 30; * blinking timeout (set to 0 to disable blinking) for the terminal blinking * attribute. */ -static unsigned int blinktimeout = 0; +static unsigned int blinktimeout = 250; /* * bell volume. It must be a value between -100 and 100. Use 0 for disabling diff --git a/st.c b/st.c index 6f38311..80910f3 100644 --- a/st.c +++ b/st.c @@ -3504,16 +3504,18 @@ xdrawcursor(void) { /* draw the new one */ if(xw.state & WIN_FOCUSED) { - if(IS_SET(MODE_REVERSE)) { - g.mode |= ATTR_REVERSE; - } - g.fg = term.line[term.c.y][curx].bg; - g.bg = term.line[term.c.y][curx].fg; + if(term.mode & MODE_BLINK) { + if(IS_SET(MODE_REVERSE)) { + g.mode |= ATTR_REVERSE; + } + g.fg = term.line[term.c.y][curx].bg; + g.bg = term.line[term.c.y][curx].fg; - sl = utf8len(g.c); - width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\ - ? 2 : 1; - xdraws(g.c, g, term.c.x, term.c.y, width, sl); + sl = utf8len(g.c); + width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\ + ? 2 : 1; + xdraws(g.c, g, term.c.x, term.c.y, width, sl); + } } else { XftDrawRect(xw.draw, &dc.col[defaultcs], borderpx + curx * xw.cw, @@ -3866,15 +3868,16 @@ run(void) { } if(FD_ISSET(cmdfd, &rfd)) { ttyread(); - if(blinktimeout) { - blinkset = tattrset(ATTR_BLINK); - if(!blinkset) - MODBIT(term.mode, 0, MODE_BLINK); - } } - if(FD_ISSET(xfd, &rfd)) + if(FD_ISSET(xfd, &rfd)) { xev = actionfps; + if(blinktimeout) { + lastblink = now; + MODBIT(term.mode, 1, MODE_BLINK); + blinkset = 1; + } + } clock_gettime(CLOCK_MONOTONIC, &now); drawtimeout.tv_sec = 0; -- 1.7.10.4