Looking for blinking cursor for st online, I found [0]. But I saw it
was not upstreamed yet. So I took the diff, simplified it some, and
the result is below. It has little complexity and I imagine others
want it too, so it would be nice if this were upstream. Perhaps
config.def.h should be updated to mention; let me know.

[0]: https://github.com/cdchawthorne/cdc_st

---
 x.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/x.c b/x.c
index fbfd350..ddb158d 100644
--- a/x.c
+++ b/x.c
@@ -1321,11 +1321,15 @@ xdrawcursor(void)
                        utf8decode("☃", &g.u, UTF_SIZ);
                case 0: /* Blinking Block */
                case 1: /* Blinking Block (Default) */
+                       if (IS_SET(MODE_BLINK))
+                               break;
                case 2: /* Steady Block */
                        g.mode |= term.line[term.c.y][curx].mode & ATTR_WIDE;
                        xdrawglyph(g, term.c.x, term.c.y);
                        break;
                case 3: /* Blinking Underline */
+                       if (IS_SET(MODE_BLINK))
+                               break;
                case 4: /* Steady Underline */
                        XftDrawRect(xw.draw, &drawcol,
                                        borderpx + curx * win.cw,
@@ -1334,6 +1338,8 @@ xdrawcursor(void)
                                        win.cw, cursorthickness);
                        break;
                case 5: /* Blinking bar */
+                       if (IS_SET(MODE_BLINK))
+                               break;
                case 6: /* Steady bar */
                        XftDrawRect(xw.draw, &drawcol,
                                        borderpx + curx * win.cw,
@@ -1598,6 +1604,8 @@ run(void)
        int xfd = XConnectionNumber(xw.dpy), xev, blinkset = 0, dodraw = 0;
        struct timespec drawtimeout, *tv = NULL, now, last, lastblink;
        long deltatime;
+       int blink_cursor = win.cursor == 0 || win.cursor == 1 ||
+                          win.cursor == 3 || win.cursor == 5;

        /* Waiting for window mapping */
        do {
@@ -1635,7 +1643,7 @@ run(void)
                if (FD_ISSET(cmdfd, &rfd)) {
                        ttyread();
                        if (blinktimeout) {
-                               blinkset = tattrset(ATTR_BLINK);
+                               blinkset = blink_cursor || tattrset(ATTR_BLINK);
                                if (!blinkset)
                                        MODBIT(term.mode, 0, MODE_BLINK);
                        }
--
2.13.4


Reply via email to