X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=2a565b6e96e7d1c3692a2dd5ed18331981a24b37;hb=9619760e129b0994cd3bc4c827c83960f6a5e98f;hp=79bf1c8cb3ae1afd3c929bf4f984e551031171ac;hpb=39ae1a4de5c471c8626c80ef1e961f0c83f5199d;p=st.git diff --git a/st.c b/st.c index 79bf1c8..2a565b6 100644 --- a/st.c +++ b/st.c @@ -1,4 +1,4 @@ -/* See LICENSE for licence details. */ +/* See LICENSE for license details. */ #include #include #include @@ -1571,11 +1571,9 @@ tmoveto(int x, int y) { miny = 0; maxy = term.row - 1; } - LIMIT(x, 0, term.col-1); - LIMIT(y, miny, maxy); term.c.state &= ~CURSOR_WRAPNEXT; - term.c.x = x; - term.c.y = y; + term.c.x = LIMIT(x, 0, term.col-1); + term.c.y = LIMIT(y, miny, maxy); } void @@ -2446,21 +2444,19 @@ tdectest(char c) { void tstrsequence(uchar c) { - if (c & 0x80) { - switch (c) { - case 0x90: /* DCS -- Device Control String */ - c = 'P'; - break; - case 0x9f: /* APC -- Application Program Command */ - c = '_'; - break; - case 0x9e: /* PM -- Privacy Message */ - c = '^'; - break; - case 0x9d: /* OSC -- Operating System Command */ - c = ']'; - break; - } + switch (c) { + case 0x90: /* DCS -- Device Control String */ + c = 'P'; + break; + case 0x9f: /* APC -- Application Program Command */ + c = '_'; + break; + case 0x9e: /* PM -- Privacy Message */ + c = '^'; + break; + case 0x9d: /* OSC -- Operating System Command */ + c = ']'; + break; } strreset(); strescseq.type = c; @@ -2769,7 +2765,6 @@ tresize(int col, int row) { int i; int minrow = MIN(row, term.row); int mincol = MIN(col, term.col); - int slide = term.c.y - row + 1; bool *bp; TCursor c; @@ -2784,14 +2779,12 @@ tresize(int col, int row) { * tscrollup would work here, but we can optimize to * memmove because we're freeing the earlier lines */ - for(i = 0; i < slide; i++) { + for(i = 0; i <= term.c.y - row; i++) { free(term.line[i]); free(term.alt[i]); } - if(slide > 0) { - memmove(term.line, term.line + slide, row * sizeof(Line)); - memmove(term.alt, term.alt + slide, row * sizeof(Line)); - } + memmove(term.line, term.line + i, row * sizeof(Line)); + memmove(term.alt, term.alt + i, row * sizeof(Line)); for(i += row; i < term.row; i++) { free(term.line[i]); free(term.alt[i]); @@ -4015,7 +4008,6 @@ usage(void) { int main(int argc, char *argv[]) { - char *titles; uint cols = 80, rows = 24; xw.l = xw.t = 0; @@ -4033,10 +4025,8 @@ main(int argc, char *argv[]) { /* eat all remaining arguments */ if(argc > 1) { opt_cmd = &argv[1]; - if(argv[1] != NULL && opt_title == NULL) { - titles = xstrdup(argv[1]); - opt_title = basename(titles); - } + if(argv[1] != NULL && opt_title == NULL) + opt_title = basename(xstrdup(argv[1])); } goto run; case 'f':