> I honestly have to say that I don't favor the fast-blinking-patch at
> all. How often do you stumble upon blinking-tags anyway? Even if there
> is a broad application of it in some program I don't know about, I'm
> absolutely sure that the dependency on two blinking speeds is just 
> ridiculuous!

Yeah, it is true. I will apply it only if it fits well in the new
main-loop. I have modified the original patch and now it may be applied
to HEAD. The patch itself is not bad, and the complexity it pays for two
blinks is very small. I have not tested it, but I attach it only to show
what modifications need to be done.

> I planned on increasing my efforts to refactor the st main-loop, and
> after only 10 minutes of work, I already had a fix ready for the timing-
> subsystem.

Cool.

> More time spent on it now without unnecessarily bloating it up will open
> the possiblity of getting rid of some cruft.

Refactoring the main loop is the first priority now, if you have a patch
serie about it, be sure no any other patch is going to be applied that
could create a conflict.

Regards,

-- 
Roberto E. Vargas Caballero
>From 710738a1f0976feb58980fd26b3372d49fdd395d Mon Sep 17 00:00:00 2001
From: Anders Eurenius <a...@spotify.com>
Date: Sun, 22 Jun 2014 16:02:06 +0200
Subject: [PATCH] Add fast blink support

Fast blink is implemented using the new main loop changes. It may mark a
few characters too many as dirty when the blink state hasn't changed,
but it's not a major issue.

Signed-off-by: Roberto E. Vargas Caballero <k...@shike2.com>
---
 st.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/st.c b/st.c
index 0c917fd..ba769c5 100644
--- a/st.c
+++ b/st.c
@@ -406,6 +406,7 @@ static void ttyresize(void);
 static void ttysend(char *, size_t);
 static void ttywrite(const char *, size_t);
 static void tstrsequence(uchar c);
+static int tsetblinks(struct timespec *);
 
 static void xdraws(char *, Glyph, int, int, int, int);
 static void xhints(void);
@@ -3261,6 +3262,9 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, 
int bytelen) {
        if(base.mode & ATTR_BLINK && term.mode & MODE_BLINK)
                fg = bg;
 
+       if(base.mode & ATTR_FASTBLINK && term.mode & MODE_FBLINK)
+               fg = bg;
+
        if(base.mode & ATTR_INVISIBLE)
                fg = bg;
 
@@ -3768,6 +3772,26 @@ resize(XEvent *e) {
        cresize(e->xconfigure.width, e->xconfigure.height);
 }
 
+int
+tsetblinks(struct timespec *now) {
+       unsigned long long int t;
+       int blink, fblink, change = 0;
+
+       t = now->tv_sec * 1000 + now->tv_nsec / 1000000;
+       blink = (t / blinktimeout) & 1;
+       if(!!(term.mode & MODE_BLINK) != blink)
+               change = 1;
+
+       fblink = (t / (blinktimeout / 4)) & 1;
+       if(!!(term.mode & MODE_FBLINK) != fblink)
+               change = 1;
+
+       MODBIT(term.mode, blink, MODE_BLINK);
+       MODBIT(term.mode, fblink, MODE_FBLINK);
+
+       return change;
+}
+
 void
 run(void) {
        XEvent ev;
@@ -3824,10 +3848,9 @@ run(void) {
                tv = &drawtimeout;
 
                dodraw = 0;
-               if(blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) {
+               if(blinktimeout && blinkset && tsetblinks(&now)) {
                        tsetdirtattr(ATTR_BLINK);
-                       term.mode ^= MODE_BLINK;
-                       lastblink = now;
+                       tsetdirtattr(ATTR_FASTBLINK);
                        dodraw = 1;
                }
                deltatime = TIMEDIFF(now, last);
-- 
1.8.5.3

Reply via email to