X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=6371167b43516e21df5d15a5f2156425be11b6d8;hb=58a57a23051deba7c77901c9971d839a0db05db0;hp=397f6a6294ca9c7c9f2062e4eb8638932dbbb197;hpb=c5a9b799d44be9c0fa4264dc34d9dd61321be795;p=st.git diff --git a/st.c b/st.c index 397f6a6..6371167 100644 --- a/st.c +++ b/st.c @@ -48,7 +48,7 @@ #define ESC_ARG_SIZ 16 #define STR_BUF_SIZ 256 #define STR_ARG_SIZ 16 -#define DRAW_BUF_SIZ 1024 +#define DRAW_BUF_SIZ 20*1024 #define UTF_SIZ 4 #define XK_NO_MOD UINT_MAX #define XK_ANY_MOD 0 @@ -561,8 +561,11 @@ bpress(XEvent *e) { if(IS_SET(MODE_MOUSE)) mousereport(e); else if(e->xbutton.button == Button1) { - if(sel.bx != -1) + if(sel.bx != -1) { + sel.bx = -1; tsetdirt(sel.b.y, sel.e.y); + draw(); + } sel.mode = 1; sel.ex = sel.bx = X2COL(e->xbutton.x); sel.ey = sel.by = Y2ROW(e->xbutton.y); @@ -2316,8 +2319,7 @@ resize(XEvent *e) { row = (xw.h - 2*BORDER) / xw.ch; if(col == term.col && row == term.row) return; - if(tresize(col, row)) - draw(); + tresize(col, row); xresize(col, row); ttyresize(col, row); } @@ -2326,7 +2328,8 @@ void run(void) { XEvent ev; fd_set rfd; - int xfd = XConnectionNumber(xw.dpy); + int xfd = XConnectionNumber(xw.dpy), i; + struct timeval drawtimeout; for(;;) { FD_ZERO(&rfd); @@ -2337,9 +2340,29 @@ run(void) { continue; die("select failed: %s\n", SERRNO); } - if(FD_ISSET(cmdfd, &rfd)) + + /* + * Stop after a certain number of reads so the user does not + * feel like the system is stuttering. + */ + for(i = 0; i < 1000 && FD_ISSET(cmdfd, &rfd); i++) { ttyread(); + FD_ZERO(&rfd); + FD_SET(cmdfd, &rfd); + /* + * Just wait a bit so it isn't disturbing the + * user and the system is able to write something. + */ + drawtimeout.tv_sec = 0; + drawtimeout.tv_usec = 5; + if(select(cmdfd+1, &rfd, NULL, NULL, &drawtimeout) < 0) { + if(errno == EINTR) + continue; + die("select failed: %s\n", SERRNO); + } + } + while(XPending(xw.dpy)) { XNextEvent(xw.dpy, &ev); if(XFilterEvent(&ev, xw.win))