| st-columnredraw-20241119-fb8569b.diff - sites - public wiki contents of suckles… | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| st-columnredraw-20241119-fb8569b.diff (2073B) | |
| --- | |
| 1 From fb8569b193cc063ad53388e8e2009fb6682092d2 Mon Sep 17 00:00:00 2001 | |
| 2 From: elbachir-one <[email protected]> | |
| 3 Date: Tue, 19 Nov 2024 15:39:16 +0100 | |
| 4 Subject: [PATCH] Added columnredraw | |
| 5 | |
| 6 --- | |
| 7 st.c | 25 +++++++++++++++++-------- | |
| 8 1 file changed, 17 insertions(+), 8 deletions(-) | |
| 9 | |
| 10 diff --git a/st.c b/st.c | |
| 11 index 57c6e96..7371554 100644 | |
| 12 --- a/st.c | |
| 13 +++ b/st.c | |
| 14 @@ -113,6 +113,7 @@ typedef struct { | |
| 15 typedef struct { | |
| 16 int row; /* nb row */ | |
| 17 int col; /* nb col */ | |
| 18 + int maxcol; /* Maximum number of columns */ | |
| 19 Line *line; /* screen */ | |
| 20 Line *alt; /* alternate screen */ | |
| 21 int *dirty; /* dirtyness of lines */ | |
| 22 @@ -1231,8 +1232,8 @@ tclearregion(int x1, int y1, int x2, int y2) | |
| 23 if (y1 > y2) | |
| 24 temp = y1, y1 = y2, y2 = temp; | |
| 25 | |
| 26 - LIMIT(x1, 0, term.col-1); | |
| 27 - LIMIT(x2, 0, term.col-1); | |
| 28 + LIMIT(x1, 0, term.maxcol-1); | |
| 29 + LIMIT(x2, 0, term.maxcol-1); | |
| 30 LIMIT(y1, 0, term.row-1); | |
| 31 LIMIT(y2, 0, term.row-1); | |
| 32 | |
| 33 @@ -2546,11 +2547,18 @@ void | |
| 34 tresize(int col, int row) | |
| 35 { | |
| 36 int i; | |
| 37 - int minrow = MIN(row, term.row); | |
| 38 - int mincol = MIN(col, term.col); | |
| 39 + int tmp; | |
| 40 + int minrow, mincol; | |
| 41 int *bp; | |
| 42 TCursor c; | |
| 43 | |
| 44 + tmp = col; | |
| 45 + if (!term.maxcol) | |
| 46 + term.maxcol = term.col; | |
| 47 + col = MAX(col, term.maxcol); | |
| 48 + minrow = MIN(row, term.row); | |
| 49 + mincol = MIN(col, term.maxcol); | |
| 50 + | |
| 51 if (col < 1 || row < 1) { | |
| 52 fprintf(stderr, | |
| 53 "tresize: error resizing to %dx%d\n", col, row); | |
| 54 @@ -2593,17 +2601,18 @@ tresize(int col, int row) | |
| 55 term.line[i] = xmalloc(col * sizeof(Glyph)); | |
| 56 term.alt[i] = xmalloc(col * sizeof(Glyph)); | |
| 57 } | |
| 58 - if (col > term.col) { | |
| 59 - bp = term.tabs + term.col; | |
| 60 + if (col > term.maxcol) { | |
| 61 + bp = term.tabs + term.maxcol; | |
| 62 | |
| 63 - memset(bp, 0, sizeof(*term.tabs) * (col - term.col)); | |
| 64 + memset(bp, 0, sizeof(*term.tabs) * (col - term.maxcol)); | |
| 65 while (--bp > term.tabs && !*bp) | |
| 66 /* nothing */ ; | |
| 67 for (bp += tabspaces; bp < term.tabs + col; bp += tabsp… | |
| 68 *bp = 1; | |
| 69 } | |
| 70 /* update terminal size */ | |
| 71 - term.col = col; | |
| 72 + term.col = tmp; | |
| 73 + term.maxcol = col; | |
| 74 term.row = row; | |
| 75 /* reset scrolling region */ | |
| 76 tsetscroll(0, row-1); | |
| 77 -- | |
| 78 2.46.2 | |
| 79 |