--- st.c | 50 ++++++++++++++++++++++++++------------------------ st.h | 1 + 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/st.c b/st.c index ae93ade..b3c1a08 100644 --- a/st.c +++ b/st.c _AT_@ -1063,7 +1063,7 @@ tscrolldown(int orig, int n) LIMIT(n, 0, term.bot-orig+1); tsetdirt(orig, term.bot-n); - tclearregion(0, term.bot-n+1, term.col-1, term.bot); + tclearregion(0, term.bot-n+1, term.maxcol-1, term.bot); for (i = term.bot; i >= orig+n; i--) { temp = term.line[i]; _AT_@ -1082,7 +1082,7 @@ tscrollup(int orig, int n) LIMIT(n, 0, term.bot-orig+1); - tclearregion(0, orig, term.col-1, orig+n-1); + tclearregion(0, orig, term.maxcol-1, orig+n-1); tsetdirt(orig+n, term.bot); for (i = orig; i <= term.bot-n; i++) { _AT_@ -1238,8 +1238,8 @@ tclearregion(int x1, int y1, int x2, int y2) if (y1 > y2) temp = y1, y1 = y2, y2 = temp; - LIMIT(x1, 0, term.col-1); - LIMIT(x2, 0, term.col-1); + LIMIT(x1, 0, term.maxcol-1); + LIMIT(x2, 0, term.maxcol-1); LIMIT(y1, 0, term.row-1); LIMIT(y2, 0, term.row-1); _AT_@ -1271,7 +1271,7 @@ tdeletechar(int n) line = term.line[term.c.y]; memmove(&line[dst], &line[src], size * sizeof(Glyph)); - tclearregion(term.col-n, term.c.y, term.col-1, term.c.y); + tclearregion(term.col-n, term.c.y, term.maxcol-1, term.c.y); } void _AT_@ -1284,7 +1284,7 @@ tinsertblank(int n) dst = term.c.x + n; src = term.c.x; - size = term.col - dst; + size = term.maxcol - dst; line = term.line[term.c.y]; memmove(&line[dst], &line[src], size * sizeof(Glyph)); _AT_@ -1550,7 +1550,7 @@ tsetmode(int priv, int set, int *args, int narg) break; alt = IS_SET(MODE_ALTSCREEN); if (alt) { - tclearregion(0, 0, term.col-1, + tclearregion(0, 0, term.maxcol-1, term.row-1); } if (set ^ alt) /* set is always 1 or 0 */ _AT_@ -1702,9 +1702,9 @@ csihandle(void) selclear(); switch (csiescseq.arg[0]) { case 0: /* below */ - tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); + tclearregion(term.c.x, term.c.y, term.maxcol-1, term.c.y); if (term.c.y < term.row-1) { - tclearregion(0, term.c.y+1, term.col-1, + tclearregion(0, term.c.y+1, term.maxcol-1, term.row-1); } break; _AT_@ -1714,7 +1714,7 @@ csihandle(void) tclearregion(0, term.c.y, term.c.x, term.c.y); break; case 2: /* all */ - tclearregion(0, 0, term.col-1, term.row-1); + tclearregion(0, 0, term.maxcol-1, term.row-1); break; default: goto unknown; _AT_@ -1723,7 +1723,7 @@ csihandle(void) case 'K': /* EL -- Clear line */ switch (csiescseq.arg[0]) { case 0: /* right */ - tclearregion(term.c.x, term.c.y, term.col-1, + tclearregion(term.c.x, term.c.y, term.maxcol-1, term.c.y); break; case 1: /* left */ _AT_@ -2492,7 +2492,8 @@ tresize(int col, int row) { int i; int minrow = MIN(row, term.row); - int mincol = MIN(col, term.col); + int oldmaxcol = term.maxcol; + int newmaxcol = MAX(term.maxcol, col); int *bp; TCursor c; _AT_@ -2522,29 +2523,29 @@ tresize(int col, int row) } /* resize to new width */ - term.specbuf = xrealloc(term.specbuf, col * sizeof(GlyphFontSpec)); + term.specbuf = xrealloc(term.specbuf, newmaxcol * sizeof(GlyphFontSpec)); /* resize to new height */ term.line = xrealloc(term.line, row * sizeof(Line)); term.alt = xrealloc(term.alt, row * sizeof(Line)); term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty)); - term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs)); + term.tabs = xrealloc(term.tabs, newmaxcol * sizeof(*term.tabs)); /* resize each row to new width, zero-pad if needed */ for (i = 0; i < minrow; i++) { - term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph)); - term.alt[i] = xrealloc(term.alt[i], col * sizeof(Glyph)); + term.line[i] = xrealloc(term.line[i], newmaxcol * sizeof(Glyph)); + term.alt[i] = xrealloc(term.alt[i], newmaxcol * sizeof(Glyph)); } /* allocate any new rows */ for (/* i = minrow */; i < row; i++) { - term.line[i] = xmalloc(col * sizeof(Glyph)); - term.alt[i] = xmalloc(col * sizeof(Glyph)); + term.line[i] = xmalloc(newmaxcol * sizeof(Glyph)); + term.alt[i] = xmalloc(newmaxcol * sizeof(Glyph)); } - if (col > term.col) { + if (newmaxcol > term.col) { bp = term.tabs + term.col; - memset(bp, 0, sizeof(*term.tabs) * (col - term.col)); + memset(bp, 0, sizeof(*term.tabs) * (newmaxcol - term.col)); while (--bp > term.tabs && !*bp) /* nothing */ ; for (bp += tabspaces; bp < term.tabs + col; bp += tabspaces) _AT_@ -2552,6 +2553,7 @@ tresize(int col, int row) } /* update terminal size */ term.col = col; + term.maxcol = newmaxcol; term.row = row; /* reset scrolling region */ tsetscroll(0, row-1); _AT_@ -2560,11 +2562,11 @@ tresize(int col, int row) /* Clearing both screens (it makes dirty all lines) */ c = term.c; for (i = 0; i < 2; i++) { - if (mincol < col && 0 < minrow) { - tclearregion(mincol, 0, col - 1, minrow - 1); + if (oldmaxcol < term.maxcol && 0 < minrow) { + tclearregion(oldmaxcol, 0, term.maxcol - 1, minrow - 1); } - if (0 < col && minrow < row) { - tclearregion(0, minrow, col - 1, row - 1); + if (0 < term.maxcol && minrow < row) { + tclearregion(0, minrow, term.maxcol - 1, row - 1); } tswapscreen(); tcursor(CURSOR_LOAD); diff --git a/st.h b/st.h index 44d4938..dc57b78 100644 --- a/st.h +++ b/st.h _AT_@ -112,6 +112,7 @@ typedef struct { typedef struct { int row; /* nb row */ int col; /* nb col */ + int maxcol; /* maximum of col during terminal lifetime */ Line *line; /* screen */ Line *alt; /* alternate screen */ int *dirty; /* dirtyness of lines */ -- 2.12.1Received on Sun Mar 26 2017 - 05:41:46 CEST
This archive was generated by hypermail 2.3.0 : Sun Mar 26 2017 - 05:48:12 CEST