X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=f91eb8d1c8cae82677dcc4639798afd648f1595a;hb=84f6dbffa5a26e1a2f94f844844d76f80dd6c5a0;hp=1a2b1ddc82148e4b16201eda50cbc8ac6258bad0;hpb=99d2d6007ace1d5558ee349224af275722fcc701;p=st.git diff --git a/st.c b/st.c index 1a2b1dd..f91eb8d 100644 --- a/st.c +++ b/st.c @@ -375,7 +375,7 @@ static void tmoveto(int, int); static void tmoveato(int, int); static void tnew(int, int); static void tnewline(int); -static void tputtab(bool); +static void tputtab(int); static void tputc(char *, int); static void treset(void); static int tresize(int, int); @@ -452,7 +452,7 @@ static char utf8encodebyte(long, size_t); static size_t utf8len(char *); static size_t utf8validate(long *, size_t); -static ssize_t xwrite(int, char *, size_t); +static ssize_t xwrite(int, const char *, size_t); static void *xmalloc(size_t); static void *xrealloc(void *, size_t); static char *xstrdup(char *); @@ -518,7 +518,7 @@ static Fontcache frc[16]; static int frclen = 0; ssize_t -xwrite(int fd, char *s, size_t len) { +xwrite(int fd, const char *s, size_t len) { size_t aux = len; while(len > 0) { @@ -992,7 +992,7 @@ selnotify(XEvent *e) { } /* - * As seen in selcopy: + * As seen in getsel: * Line endings are inconsistent in the terminal and GUI world * copy and pasting. When receiving some selection data, * replace all '\n' with '\r'. @@ -1270,7 +1270,7 @@ ttyread(void) { void ttywrite(const char *s, size_t n) { - if(write(cmdfd, s, n) == -1) + if(xwrite(cmdfd, s, n) == -1) die("write error on tty: %s\n", strerror(errno)); } @@ -1781,7 +1781,6 @@ tsetmode(bool priv, bool set, int *args, int narg) { for(lim = args + narg; args < lim; ++args) { if(priv) { switch(*args) { - break; case 1: /* DECCKM -- Cursor key */ MODBIT(term.mode, set, MODE_APPCURSOR); break; @@ -1996,8 +1995,7 @@ csihandle(void) { break; case 'I': /* CHT -- Cursor Forward Tabulation tab stops */ DEFAULT(csiescseq.arg[0], 1); - while(csiescseq.arg[0]--) - tputtab(1); + tputtab(csiescseq.arg[0]); break; case 'J': /* ED -- Clear screen */ selclear(NULL); @@ -2065,8 +2063,7 @@ csihandle(void) { break; case 'Z': /* CBT -- Cursor Backward Tabulation tab stops */ DEFAULT(csiescseq.arg[0], 1); - while(csiescseq.arg[0]--) - tputtab(0); + tputtab(-csiescseq.arg[0]); break; case 'd': /* VPA -- Move to */ DEFAULT(csiescseq.arg[0], 1); @@ -2281,19 +2278,17 @@ tdump(void) { } void -tputtab(bool forward) { +tputtab(int n) { uint x = term.c.x; - if(forward) { - if(x == term.col) - return; - for(++x; x < term.col && !term.tabs[x]; ++x) - /* nothing */ ; - } else { - if(x == 0) - return; - for(--x; x > 0 && !term.tabs[x]; --x) - /* nothing */ ; + if(n > 0) { + while(x < term.col && n--) + for(++x; x < term.col && !term.tabs[x]; ++x) + /* nothing */ ; + } else if(n < 0) { + while(x > 0 && n++) + for(--x; x > 0 && !term.tabs[x]; --x) + /* nothing */ ; } tmoveto(x, term.c.y); } @@ -2678,7 +2673,9 @@ tresize(int col, int row) { if(0 < col && minrow < row) { tclearregion(0, minrow, col - 1, row - 1); } + tcursor(CURSOR_SAVE); tswapscreen(); + tcursor(CURSOR_LOAD); } while(orig != term.line); return (slide > 0); @@ -3457,7 +3454,7 @@ drawregion(int x1, int y1, int x2, int y2) { bool ena_sel = sel.ob.x != -1; long unicodep; - if(sel.alt ^ IS_SET(MODE_ALTSCREEN)) + if(sel.alt != IS_SET(MODE_ALTSCREEN)) ena_sel = 0; if(!(xw.state & WIN_VISIBLE))