| st-iso14755-0.8.2.diff - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| st-iso14755-0.8.2.diff (2326B) | |
| --- | |
| 1 diff --git a/config.def.h b/config.def.h | |
| 2 index 0e01717..c6d7f58 100644 | |
| 3 --- a/config.def.h | |
| 4 +++ b/config.def.h | |
| 5 @@ -178,6 +178,7 @@ static Shortcut shortcuts[] = { | |
| 6 { TERMMOD, XK_Y, selpaste, {.i = … | |
| 7 { ShiftMask, XK_Insert, selpaste, {.i = … | |
| 8 { TERMMOD, XK_Num_Lock, numlock, {.i = … | |
| 9 + { TERMMOD, XK_I, iso14755, {.i = … | |
| 10 }; | |
| 11 | |
| 12 /* | |
| 13 diff --git a/st.1 b/st.1 | |
| 14 index e8d6059..81bceff 100644 | |
| 15 --- a/st.1 | |
| 16 +++ b/st.1 | |
| 17 @@ -159,6 +159,10 @@ Copy the selected text to the clipboard selection. | |
| 18 .TP | |
| 19 .B Ctrl-Shift-v | |
| 20 Paste from the clipboard selection. | |
| 21 +.TP | |
| 22 +.B Ctrl-Shift-i | |
| 23 +Launch dmenu to enter a unicode codepoint and send the corresponding gl… | |
| 24 +to st. | |
| 25 .SH CUSTOMIZATION | |
| 26 .B st | |
| 27 can be customized by creating a custom config.h and (re)compiling the s… | |
| 28 diff --git a/st.c b/st.c | |
| 29 index b8e6077..c089df3 100644 | |
| 30 --- a/st.c | |
| 31 +++ b/st.c | |
| 32 @@ -38,11 +38,15 @@ | |
| 33 | |
| 34 /* macros */ | |
| 35 #define IS_SET(flag) ((term.mode & (flag)) != 0) | |
| 36 +#define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) | |
| 37 #define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\… | |
| 38 #define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) | |
| 39 #define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c)) | |
| 40 #define ISDELIM(u) (utf8strchr(worddelimiters, u) != NUL… | |
| 41 | |
| 42 +/* constants */ | |
| 43 +#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint… | |
| 44 + | |
| 45 enum term_mode { | |
| 46 MODE_WRAP = 1 << 0, | |
| 47 MODE_INSERT = 1 << 1, | |
| 48 @@ -1980,6 +1984,28 @@ tprinter(char *s, size_t len) | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 +void | |
| 53 +iso14755(const Arg *arg) | |
| 54 +{ | |
| 55 + FILE *p; | |
| 56 + char *us, *e, codepoint[9], uc[UTF_SIZ]; | |
| 57 + unsigned long utf32; | |
| 58 + | |
| 59 + if (!(p = popen(ISO14755CMD, "r"))) | |
| 60 + return; | |
| 61 + | |
| 62 + us = fgets(codepoint, sizeof(codepoint), p); | |
| 63 + pclose(p); | |
| 64 + | |
| 65 + if (!us || *us == '\0' || *us == '-' || strlen(us) > 7) | |
| 66 + return; | |
| 67 + if ((utf32 = strtoul(us, &e, 16)) == ULONG_MAX || | |
| 68 + (*e != '\n' && *e != '\0')) | |
| 69 + return; | |
| 70 + | |
| 71 + ttywrite(uc, utf8encode(utf32, uc), 1); | |
| 72 +} | |
| 73 + | |
| 74 void | |
| 75 toggleprinter(const Arg *arg) | |
| 76 { | |
| 77 diff --git a/st.h b/st.h | |
| 78 index 38c61c4..dac64d8 100644 | |
| 79 --- a/st.h | |
| 80 +++ b/st.h | |
| 81 @@ -80,6 +80,7 @@ void die(const char *, ...); | |
| 82 void redraw(void); | |
| 83 void draw(void); | |
| 84 | |
| 85 +void iso14755(const Arg *); | |
| 86 void printscreen(const Arg *); | |
| 87 void printsel(const Arg *); | |
| 88 void sendbreak(const Arg *); |