diff options
author | stefan <stefan@s00.xyz> | 2023-04-14 19:50:19 -0400 |
---|---|---|
committer | stefan <stefan@s00.xyz> | 2023-04-14 19:50:19 -0400 |
commit | ea4d4ad4ef0eae8f78d9e38bc3dc3145edded12a (patch) | |
tree | 46b1b637ba4b379064464fe2f23fa101fd281e8e /st.c.rej | |
parent | 211964d56ee00a7d46e251cbc150afb79138ae37 (diff) | |
download | st-ea4d4ad4ef0eae8f78d9e38bc3dc3145edded12a.tar.gz |
initial commit
Diffstat (limited to 'st.c.rej')
-rw-r--r-- | st.c.rej | 149 |
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 */ |