X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=839dc94db7621e4bbc9d29b2792ebfb0515a625f;hb=dbe8676d7d69651132bde2b6d9ec3787cbbc552a;hp=1e4196e175f97fe138149492948b66977f3bbc04;hpb=e2ee5ee6114eb74bb08cb9abe5a3020203e92688;p=st.git diff --git a/st.c b/st.c index 1e4196e..839dc94 100644 --- a/st.c +++ b/st.c @@ -28,13 +28,8 @@ #include #include -char *argv0; - -#define Glyph Glyph_ -#define Font Font_ - -#include "win.h" #include "st.h" +#include "win.h" #if defined(__linux) #include @@ -60,7 +55,7 @@ char *argv0; #define ISDELIM(u) (utf8strchr(worddelimiters, u) != NULL) /* constants */ -#define ISO14755CMD "dmenu -w %lu -p codepoint: > 4); + if (c == -1) + break; + *dst++ = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2); + if (d == -1) + break; + *dst++ = ((c & 0x03) << 6) | d; + } + *dst = '\0'; + return result; +} + void selinit(void) { @@ -381,24 +418,6 @@ selinit(void) sel.clipboard = NULL; } -int -x2col(int x) -{ - x -= borderpx; - x /= win.cw; - - return LIMIT(x, 0, term.col-1); -} - -int -y2row(int y) -{ - y -= borderpx; - y /= win.ch; - - return LIMIT(y, 0, term.row-1); -} - int tlinelen(int y) { @@ -655,7 +674,6 @@ execsh(void) setenv("SHELL", sh, 1); setenv("HOME", pw->pw_dir, 1); setenv("TERM", termname, 1); - xsetenv(); signal(SIGCHLD, SIG_DFL); signal(SIGHUP, SIG_DFL); @@ -887,14 +905,14 @@ ttysend(char *s, size_t n) } void -ttyresize(void) +ttyresize(int tw, int th) { struct winsize w; w.ws_row = term.row; w.ws_col = term.col; - w.ws_xpixel = win.tw; - w.ws_ypixel = win.th; + w.ws_xpixel = tw; + w.ws_ypixel = th; if (ioctl(cmdfd, TIOCSWINSZ, &w) < 0) fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno)); } @@ -1820,6 +1838,19 @@ strhandle(void) if (narg > 1) xsettitle(strescseq.args[1]); return; + case 52: + if (narg > 2) { + char *dec; + + dec = base64dec(strescseq.args[2]); + if (dec) { + xsetsel(dec, CurrentTime); + clipcopy(NULL); + } else { + fprintf(stderr, "erresc: invalid base64\n"); + } + } + return; case 4: /* color set */ if (narg < 3) break; @@ -1929,14 +1960,11 @@ tprinter(char *s, size_t len) void iso14755(const Arg *arg) { - unsigned long id = xwinid(); - char cmd[sizeof(ISO14755CMD) + NUMMAXLEN(id)]; FILE *p; char *us, *e, codepoint[9], uc[UTF_SIZ]; unsigned long utf32; - snprintf(cmd, sizeof(cmd), ISO14755CMD, id); - if (!(p = popen(cmd, "r"))) + if (!(p = popen(ISO14755CMD, "r"))) return; us = fgets(codepoint, sizeof(codepoint), p); @@ -2121,10 +2149,7 @@ tcontrolcode(uchar ascii) /* backwards compatibility to xterm */ strhandle(); } else { - if (!(win.state & WIN_FOCUSED)) - xseturgency(1); - if (bellvolume) - xbell(bellvolume); + xbell(); } break; case '\033': /* ESC */ @@ -2464,9 +2489,6 @@ tresize(int col, int row) free(term.alt[i]); } - /* resize to new width */ - term.specbuf = xrealloc(term.specbuf, col * sizeof(GlyphFontSpec)); - /* resize to new height */ term.line = xrealloc(term.line, row * sizeof(Line)); term.alt = xrealloc(term.alt, row * sizeof(Line)); @@ -2480,7 +2502,7 @@ tresize(int col, int row) } /* allocate any new rows */ - for (/* i == minrow */; i < row; i++) { + for (/* i = minrow */; i < row; i++) { term.line[i] = xmalloc(col * sizeof(Glyph)); term.alt[i] = xmalloc(col * sizeof(Glyph)); } @@ -2515,37 +2537,6 @@ tresize(int col, int row) term.c = c; } -void -zoom(const Arg *arg) -{ - Arg larg; - - larg.f = usedfontsize + arg->f; - zoomabs(&larg); -} - -void -zoomabs(const Arg *arg) -{ - xunloadfonts(); - xloadfonts(usedfont, arg->f); - cresize(0, 0); - ttyresize(); - redraw(); - xhints(); -} - -void -zoomreset(const Arg *arg) -{ - Arg larg; - - if (defaultfontsize > 0) { - larg.f = defaultfontsize; - zoomabs(&larg); - } -} - void resettitle(void) { @@ -2610,33 +2601,3 @@ kmap(KeySym k, uint state) return NULL; } - -void -cresize(int width, int height) -{ - int col, row; - - if (width != 0) - win.w = width; - if (height != 0) - win.h = height; - - col = (win.w - 2 * borderpx) / win.cw; - row = (win.h - 2 * borderpx) / win.ch; - - tresize(col, row); - xresize(col, row); -} - -void -usage(void) -{ - die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]" - " [-n name] [-o file]\n" - " [-T title] [-t title] [-w windowid]" - " [[-e] command [args ...]]\n" - " %s [-aiv] [-c class] [-f font] [-g geometry]" - " [-n name] [-o file]\n" - " [-T title] [-t title] [-w windowid] -l line" - " [stty_args ...]\n", argv0, argv0); -}