diff options
| author | Nikita Langer <nikitalanger@icloud.com> | 2026-05-31 09:44:56 +0200 |
|---|---|---|
| committer | Nikita Langer <nikitalanger@icloud.com> | 2026-05-31 09:44:56 +0200 |
| commit | c46a160aa0618182c92f8a135fd8a35e53cdb4bf (patch) | |
| tree | 19e1d825ae3304b807947bbc7215cabaf0a8caad /st.c | |
| parent | 5187e696fdafee436aced2a54524445a58ff6ada (diff) | |
| download | st-c46a160aa0618182c92f8a135fd8a35e53cdb4bf.tar.gz st-c46a160aa0618182c92f8a135fd8a35e53cdb4bf.tar.bz2 st-c46a160aa0618182c92f8a135fd8a35e53cdb4bf.tar.xz st-c46a160aa0618182c92f8a135fd8a35e53cdb4bf.zip | |
Boxdraw Support
Diffstat (limited to 'st.c')
| -rw-r--r-- | st.c | 104 |
1 files changed, 11 insertions, 93 deletions
@@ -19,7 +19,6 @@ #include "st.h" #include "win.h" -#define USE_ARGB (alpha != OPAQUE) #if defined(__linux) #include <pty.h> @@ -644,95 +643,6 @@ getsel(void) return str; } -char * -strstrany(char* s, char** strs) { - char *match; - for (int i = 0; strs[i]; i++) { - if ((match = strstr(s, strs[i]))) { - return match; - } - } - return NULL; -} - -void -highlighturls(void) -{ - char *match; - char *linestr = calloc(sizeof(char), term.col+1); /* assume ascii */ - for (int i = term.top; i < term.bot; i++) { - int url_start = -1; - for (int j = 0; j < term.col; j++) { - if (term.line[i][j].u < 127) { - linestr[j] = term.line[i][j].u; - } - linestr[term.col] = '\0'; - } - while ((match = strstrany(linestr + url_start + 1, urlprefixes))) { - url_start = match - linestr; - for (int c = url_start; c < term.col && strchr(urlchars, linestr[c]); c++) { - term.line[i][c].mode |= ATTR_URL; - tsetdirt(i, c); - } - } - } - free(linestr); -} - -void -unhighlighturls(void) -{ - for (int i = term.top; i < term.bot; i++) { - for (int j = 0; j < term.col; j++) { - Glyph* g = &term.line[i][j]; - if (g->mode & ATTR_URL) { - g->mode &= ~ATTR_URL; - tsetdirt(i, j); - } - } - } - return; -} - -void -followurl(int x, int y) { - char *linestr = calloc(sizeof(char), term.col+1); /* assume ascii */ - char *match; - for (int i = 0; i < term.col; i++) { - if (term.line[x][i].u < 127) { - linestr[i] = term.line[x][i].u; - } - linestr[term.col] = '\0'; - } - int url_start = -1; - while ((match = strstrany(linestr + url_start + 1, urlprefixes))) { - url_start = match - linestr; - int url_end = url_start; - for (int c = url_start; c < term.col && strchr(urlchars, linestr[c]); c++) { - url_end++; - } - if (url_start <= y && y < url_end) { - linestr[url_end] = '\0'; - break; - } - } - if (url_start == -1) { - free(linestr); - return; - } - - pid_t chpid; - if ((chpid = fork()) == 0) { - if (fork() == 0) - execlp(urlhandler, urlhandler, linestr + url_start, NULL); - exit(1); - } - if (chpid > 0) - waitpid(chpid, NULL, 0); - free(linestr); - unhighlighturls(); -} - void selclear(void) { @@ -1065,6 +975,9 @@ tsetdirt(int top, int bot) { int i; + if (term.row <= 0) + return; + LIMIT(top, 0, term.row-1); LIMIT(bot, 0, term.row-1); @@ -1370,6 +1283,9 @@ tsetchar(Rune u, const Glyph *attr, int x, int y) term.dirty[y] = 1; term.line[y][x] = *attr; term.line[y][x].u = u; + + if (isboxdraw(u)) + term.line[y][x].mode |= ATTR_BOXDRAW; } void @@ -2538,6 +2454,7 @@ eschandle(uchar ascii) resettitle(); xloadcols(); xsetmode(0, MODE_HIDE); + xsetmode(0, MODE_BRCKTPASTE); break; case '=': /* DECPAM -- Application keypad */ xsetmode(1, MODE_APPKEYPAD); @@ -2872,9 +2789,10 @@ draw(void) cx--; drawregion(0, 0, term.col, term.row); - xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], - term.ocx, term.ocy, term.line[term.ocy][term.ocx], - term.line[term.ocy], term.col); + if (term.scr == 0) + xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], + term.ocx, term.ocy, term.line[term.ocy][term.ocx], + term.line[term.ocy], term.col); term.ocx = cx; term.ocy = term.c.y; xfinishdraw(); |
