X-Git-Url: https://git.xinqibao.xyz/st.git/blobdiff_plain/6352502d644d8295ceb2cdf68a5ecbac0891d4a6..b0310fba5de0c519eae0c8a2817ccc7bfcdd5222:/st.c?ds=sidebyside diff --git a/st.c b/st.c index fb37eb5..79bb6aa 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 @@ -2769,7 +2767,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; @@ -2779,19 +2776,18 @@ tresize(int col, int row) { return; } - /* free unneeded rows */ - for(i = 0; i < slide; i++) { + /* + * slide screen to keep cursor where we expect it - + * tscrollup would work here, but we can optimize to + * memmove because we're freeing the earlier lines + */ + for(i = 0; i <= term.c.y - row; i++) { free(term.line[i]); free(term.alt[i]); } - if(slide > 0) { - /* - * slide screen to keep cursor where we expect it - - * tscrollup would work here, but we can optimize to - * memmove because we're freeing the earlier lines - */ - memmove(term.line, term.line + slide, row * sizeof(Line)); - memmove(term.alt, term.alt + slide, row * sizeof(Line)); + if(i > 0) { + 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]);