diff options
| -rw-r--r-- | st.c | 57 | ||||
| -rw-r--r-- | st.info | 1 | ||||
| -rw-r--r-- | win.h | 1 | ||||
| -rw-r--r-- | x.c | 1 |
4 files changed, 59 insertions, 1 deletions
| @@ -198,6 +198,8 @@ static char utf8encodebyte(Rune, size_t); | |||
| 198 | static char *utf8strchr(char *s, Rune u); | 198 | static char *utf8strchr(char *s, Rune u); |
| 199 | static size_t utf8validate(Rune *, size_t); | 199 | static size_t utf8validate(Rune *, size_t); |
| 200 | 200 | ||
| 201 | static char *base64dec(const char *); | ||
| 202 | |||
| 201 | static ssize_t xwrite(int, const char *, size_t); | 203 | static ssize_t xwrite(int, const char *, size_t); |
| 202 | static void *xrealloc(void *, size_t); | 204 | static void *xrealloc(void *, size_t); |
| 203 | 205 | ||
| @@ -369,6 +371,48 @@ utf8validate(Rune *u, size_t i) | |||
| 369 | return i; | 371 | return i; |
| 370 | } | 372 | } |
| 371 | 373 | ||
| 374 | static const char base64_digits[] = { | ||
| 375 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 376 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, | ||
| 377 | 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, -1, 0, 0, 0, 0, 1, | ||
| 378 | 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | ||
| 379 | 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, | ||
| 380 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, | ||
| 381 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 382 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 383 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 384 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 385 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 386 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
| 387 | }; | ||
| 388 | |||
| 389 | char * | ||
| 390 | base64dec(const char *src) | ||
| 391 | { | ||
| 392 | size_t in_len = strlen(src); | ||
| 393 | char *result, *dst; | ||
| 394 | |||
| 395 | if (in_len % 4) | ||
| 396 | return NULL; | ||
| 397 | result = dst = xmalloc(in_len / 4 * 3 + 1); | ||
| 398 | while (*src) { | ||
| 399 | int a = base64_digits[(unsigned char) *src++]; | ||
| 400 | int b = base64_digits[(unsigned char) *src++]; | ||
| 401 | int c = base64_digits[(unsigned char) *src++]; | ||
| 402 | int d = base64_digits[(unsigned char) *src++]; | ||
| 403 | |||
| 404 | *dst++ = (a << 2) | ((b & 0x30) >> 4); | ||
| 405 | if (c == -1) | ||
| 406 | break; | ||
| 407 | *dst++ = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2); | ||
| 408 | if (d == -1) | ||
| 409 | break; | ||
| 410 | *dst++ = ((c & 0x03) << 6) | d; | ||
| 411 | } | ||
| 412 | *dst = '\0'; | ||
| 413 | return result; | ||
| 414 | } | ||
| 415 | |||
| 372 | void | 416 | void |
| 373 | selinit(void) | 417 | selinit(void) |
| 374 | { | 418 | { |
| @@ -1820,6 +1864,19 @@ strhandle(void) | |||
| 1820 | if (narg > 1) | 1864 | if (narg > 1) |
| 1821 | xsettitle(strescseq.args[1]); | 1865 | xsettitle(strescseq.args[1]); |
| 1822 | return; | 1866 | return; |
| 1867 | case 52: | ||
| 1868 | if (narg > 2) { | ||
| 1869 | char *dec; | ||
| 1870 | |||
| 1871 | dec = base64dec(strescseq.args[2]); | ||
| 1872 | if (dec) { | ||
| 1873 | xsetsel(dec, CurrentTime); | ||
| 1874 | clipcopy(NULL); | ||
| 1875 | } else { | ||
| 1876 | fprintf(stderr, "erresc: invalid base64\n"); | ||
| 1877 | } | ||
| 1878 | } | ||
| 1879 | return; | ||
| 1823 | case 4: /* color set */ | 1880 | case 4: /* color set */ |
| 1824 | if (narg < 3) | 1881 | if (narg < 3) |
| 1825 | break; | 1882 | break; |
| @@ -189,6 +189,7 @@ st| simpleterm, | |||
| 189 | Se, | 189 | Se, |
| 190 | Ss, | 190 | Ss, |
| 191 | Tc, | 191 | Tc, |
| 192 | Ms=\E]52;%p1%s;%p2%s\007, | ||
| 192 | 193 | ||
| 193 | st-256color| simpleterm with 256 colors, | 194 | st-256color| simpleterm with 256 colors, |
| 194 | use=st, | 195 | use=st, |
| @@ -27,3 +27,4 @@ void xunloadfonts(void); | |||
| 27 | void xresize(int, int); | 27 | void xresize(int, int); |
| 28 | void xselpaste(void); | 28 | void xselpaste(void); |
| 29 | unsigned long xwinid(void); | 29 | unsigned long xwinid(void); |
| 30 | void xsetsel(char *, Time); | ||
| @@ -88,7 +88,6 @@ static void xclear(int, int, int, int); | |||
| 88 | static void xdrawcursor(void); | 88 | static void xdrawcursor(void); |
| 89 | static int xgeommasktogravity(int); | 89 | static int xgeommasktogravity(int); |
| 90 | static int xloadfont(Font *, FcPattern *); | 90 | static int xloadfont(Font *, FcPattern *); |
| 91 | static void xsetsel(char *, Time); | ||
| 92 | static void xunloadfont(Font *); | 91 | static void xunloadfont(Font *); |
| 93 | 92 | ||
| 94 | static void expose(XEvent *); | 93 | static void expose(XEvent *); |
