Skip to content

Commit

Permalink
Let curses do the dirty work for flash
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
colona authored and k0gaMSX committed Feb 22, 2015
1 parent 3604445 commit 1b51404
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
21 changes: 6 additions & 15 deletions st.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ char *argv0;
#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))
Expand Down Expand Up @@ -349,7 +347,7 @@ typedef struct {

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);
Expand Down Expand Up @@ -1826,7 +1824,7 @@ tsetmode(bool priv, bool set, int *args, int narg) {
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);
Expand Down Expand Up @@ -2200,7 +2198,7 @@ strhandle(void) {
* TODO if defaultbg color is changed, borders
* are dirty
*/
redraw(0);
redraw();
}
return;
}
Expand Down Expand Up @@ -3093,7 +3091,7 @@ xzoomabs(const Arg *arg) {
xunloadfonts();
xloadfonts(usedfont, arg->i);
cresize(0, 0);
redraw(0);
redraw();
xhints();
}

Expand Down Expand Up @@ -3558,16 +3556,9 @@ xresettitle(void) {
}

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
Expand Down Expand Up @@ -3634,7 +3625,7 @@ expose(XEvent *ev) {
if(!e->count)
xw.state &= ~WIN_REDRAW;
}
redraw(0);
redraw();
}

void
Expand Down
3 changes: 2 additions & 1 deletion st.info
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ st| simpleterm,
el=\E[K,
el1=\E[1K,
enacs=\E)0,
flash=\E[?5h\E[?5l,
flash=\E[?5h$<80/>\E[?5l,
fsl=^G,
home=\E[H,
hpa=\E[%i%p1%dG,
Expand Down Expand Up @@ -150,6 +150,7 @@ st| simpleterm,
mir,
msgr,
ncv#3,
npc,
op=\E[39;49m,
pairs#64,
mc0=\E[i,
Expand Down

0 comments on commit 1b51404

Please sign in to comment.