Let curses do the dirty work for flash Use the terminfo delay syntax ($<x>) in our flash capability to avoid hardcoding a fixed delay in redraw() when called from tsetmode() with DECSCNM. We need to turn on the npc capability so that delays are made with xon/xoff instead of padding characters.
Ivan Delalande colona@ycc.fr
M
st.c
→
st.c
@@ -63,8 +63,6 @@ #define XK_ANY_MOD UINT_MAX
#define XK_NO_MOD 0 #define XK_SWITCH_MOD (1<<13) -#define REDRAW_TIMEOUT (80*1000) /* 80 ms */ - /* macros */ #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) < (b) ? (b) : (a))@@ -349,7 +347,7 @@ } DC;
static void die(const char *, ...); static void draw(void); -static void redraw(int); +static void redraw(void); static void drawregion(int, int, int, int); static void execsh(void); static void sigchld(int);@@ -1826,7 +1824,7 @@ case 5: /* DECSCNM -- Reverse video */
mode = term.mode; MODBIT(term.mode, set, MODE_REVERSE); if(mode != term.mode) - redraw(REDRAW_TIMEOUT); + redraw(); break; case 6: /* DECOM -- Origin */ MODBIT(term.c.state, set, CURSOR_ORIGIN);@@ -2200,7 +2198,7 @@ /*
* TODO if defaultbg color is changed, borders * are dirty */ - redraw(0); + redraw(); } return; }@@ -3093,7 +3091,7 @@ xzoomabs(const Arg *arg) {
xunloadfonts(); xloadfonts(usedfont, arg->i); cresize(0, 0); - redraw(0); + redraw(); xhints(); }@@ -3558,16 +3556,9 @@ xsettitle(opt_title ? opt_title : "st");
} void -redraw(int timeout) { - struct timespec tv = {0, timeout * 1000}; - +redraw(void) { tfulldirt(); draw(); - - if(timeout > 0) { - nanosleep(&tv, NULL); - XSync(xw.dpy, False); /* necessary for a good tput flash */ - } } void@@ -3634,7 +3625,7 @@ if(xw.state & WIN_REDRAW) {
if(!e->count) xw.state &= ~WIN_REDRAW; } - redraw(0); + redraw(); } void