JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
subvert blinking code to blink cursor
authorJason Woofenden <jason@jasonwoof.com>
Thu, 11 Dec 2014 19:06:09 +0000 (14:06 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Thu, 11 Dec 2014 19:06:09 +0000 (14:06 -0500)
config.h
st.c

index f7e1c5a..804ef30 100644 (file)
--- 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.
  */
  * 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
 
 /*
  * 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 (file)
--- a/st.c
+++ b/st.c
@@ -3504,16 +3504,18 @@ xdrawcursor(void) {
 
        /* draw the new one */
        if(xw.state & WIN_FOCUSED) {
 
        /* 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,
        } else {
                XftDrawRect(xw.draw, &dc.col[defaultcs],
                                borderpx + curx * xw.cw,
@@ -3866,15 +3868,16 @@ run(void) {
                }
                if(FD_ISSET(cmdfd, &rfd)) {
                        ttyread();
                }
                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;
                        xev = actionfps;
+                       if(blinktimeout) {
+                               lastblink = now;
+                               MODBIT(term.mode, 1, MODE_BLINK);
+                               blinkset = 1;
+                       }
+               }
 
                clock_gettime(CLOCK_MONOTONIC, &now);
                drawtimeout.tv_sec = 0;
 
                clock_gettime(CLOCK_MONOTONIC, &now);
                drawtimeout.tv_sec = 0;