summaryrefslogtreecommitdiff
path: root/st.c.rej
diff options
context:
space:
mode:
Diffstat (limited to 'st.c.rej')
-rw-r--r--st.c.rej149
1 files changed, 149 insertions, 0 deletions
diff --git a/st.c.rej b/st.c.rej
new file mode 100644
index 0000000..de7bc2c
--- /dev/null
+++ b/st.c.rej
@@ -0,0 +1,149 @@
+--- st.c
++++ st.c
+@@ -1435,89 +1598,93 @@ tsetchar(Rune u, const Glyph *attr, int x, int y)
+ } else if (term.line[y][x].mode & ATTR_WDUMMY) {
+ term.line[y][x-1].u = ' ';
+ term.line[y][x-1].mode &= ~ATTR_WIDE;
+- }
++ }
+
+ term.dirty[y] = 1;
+ term.line[y][x] = *attr;
+ term.line[y][x].u = u;
++ term.line[y][x].mode |= ATTR_SET;
+ }
+
+ void
+-tclearregion(int x1, int y1, int x2, int y2)
++tclearglyph(Glyph *gp, int usecurattr)
+ {
+- int x, y, temp;
+- Glyph *gp;
++ if (usecurattr) {
++ gp->fg = term.c.attr.fg;
++ gp->bg = term.c.attr.bg;
++ } else {
++ gp->fg = defaultfg;
++ gp->bg = defaultbg;
++ }
++ gp->mode = ATTR_NULL;
++ gp->u = ' ';
++}
+
+- if (x1 > x2)
+- temp = x1, x1 = x2, x2 = temp;
+- if (y1 > y2)
+- temp = y1, y1 = y2, y2 = temp;
++void
++tclearregion(int x1, int y1, int x2, int y2, int usecurattr)
++{
++ int x, y;
+
+- LIMIT(x1, 0, term.col-1);
+- LIMIT(x2, 0, term.col-1);
+- LIMIT(y1, 0, term.row-1);
+- LIMIT(y2, 0, term.row-1);
++ /* regionselected() takes relative coordinates */
++ if (regionselected(x1+term.scr, y1+term.scr, x2+term.scr, y2+term.scr))
++ selremove();
+
+ for (y = y1; y <= y2; y++) {
+ term.dirty[y] = 1;
+- for (x = x1; x <= x2; x++) {
+- gp = &term.line[y][x];
+- if (selected(x, y))
+- selclear();
+- gp->fg = term.c.attr.fg;
+- gp->bg = term.c.attr.bg;
+- gp->mode = 0;
+- gp->u = ' ';
+- }
++ for (x = x1; x <= x2; x++)
++ tclearglyph(&term.line[y][x], usecurattr);
+ }
+ }
+
+ void
+ tdeletechar(int n)
+ {
+- int dst, src, size;
+- Glyph *line;
+-
+- LIMIT(n, 0, term.col - term.c.x);
++ int src, dst, size;
++ Line line;
+
++ if (n <= 0)
++ return;
+ dst = term.c.x;
+- src = term.c.x + n;
++ src = MIN(term.c.x + n, term.col);
+ size = term.col - src;
+- 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);
++ if (size > 0) { /* otherwise src would point beyond the array
++ https://stackoverflow.com/questions/29844298 */
++ line = term.line[term.c.y];
++ memmove(&line[dst], &line[src], size * sizeof(Glyph));
++ }
++ tclearregion(dst + size, term.c.y, term.col - 1, term.c.y, 1);
+ }
+
+ void
+ tinsertblank(int n)
+ {
+- int dst, src, size;
+- Glyph *line;
++ int src, dst, size;
++ Line line;
+
+- LIMIT(n, 0, term.col - term.c.x);
+-
+- dst = term.c.x + n;
++ if (n <= 0)
++ return;
++ dst = MIN(term.c.x + n, term.col);
+ src = term.c.x;
+ size = term.col - dst;
+- line = term.line[term.c.y];
+-
+- memmove(&line[dst], &line[src], size * sizeof(Glyph));
+- tclearregion(src, term.c.y, dst - 1, term.c.y);
++ if (size > 0) { /* otherwise dst would point beyond the array */
++ line = term.line[term.c.y];
++ memmove(&line[dst], &line[src], size * sizeof(Glyph));
++ }
++ tclearregion(src, term.c.y, dst - 1, term.c.y, 1);
+ }
+
+ void
+ tinsertblankline(int n)
+ {
+ if (BETWEEN(term.c.y, term.top, term.bot))
+- tscrolldown(term.c.y, n, 0);
++ tscrolldown(term.c.y, n);
+ }
+
+ void
+ tdeleteline(int n)
+ {
+ if (BETWEEN(term.c.y, term.top, term.bot))
+- tscrollup(term.c.y, n, 0);
++ tscrollup(term.c.y, term.bot, n, SCROLL_NOSAVEHIST);
+ }
+
+ int32_t
+@@ -2001,9 +2173,9 @@ csihandle(void)
+ break;
+ case 'n': /* DSR – Device Status Report (cursor position) */
+ if (csiescseq.arg[0] == 6) {
+- len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
++ n = snprintf(buf, sizeof(buf), "\033[%i;%iR",
+ term.c.y+1, term.c.x+1);
+- ttywrite(buf, len, 0);
++ ttywrite(buf, n, 0);
+ }
+ break;
+ case 'r': /* DECSTBM -- Set Scrolling Region */
© 2025 Stefan Weigl-Bosker