diff options
-rw-r--r-- | config.def.h | 1 | ||||
-rw-r--r-- | st.c | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index b41747f..c2e4ffd 100644 --- a/config.def.h +++ b/config.def.h | |||
@@ -172,6 +172,7 @@ static Shortcut shortcuts[] = { | |||
172 | { MODKEY|ShiftMask, XK_C, clipcopy, {.i = 0} }, | 172 | { MODKEY|ShiftMask, XK_C, clipcopy, {.i = 0} }, |
173 | { MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} }, | 173 | { MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} }, |
174 | { MODKEY, XK_Num_Lock, numlock, {.i = 0} }, | 174 | { MODKEY, XK_Num_Lock, numlock, {.i = 0} }, |
175 | { MODKEY, XK_Control_L, iso14755, {.i = 0} }, | ||
175 | }; | 176 | }; |
176 | 177 | ||
177 | /* | 178 | /* |
@@ -66,6 +66,7 @@ char *argv0; | |||
66 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) | 66 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
67 | #define MAX(a, b) ((a) < (b) ? (b) : (a)) | 67 | #define MAX(a, b) ((a) < (b) ? (b) : (a)) |
68 | #define LEN(a) (sizeof(a) / sizeof(a)[0]) | 68 | #define LEN(a) (sizeof(a) / sizeof(a)[0]) |
69 | #define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) | ||
69 | #define DEFAULT(a, b) (a) = (a) ? (a) : (b) | 70 | #define DEFAULT(a, b) (a) = (a) ? (a) : (b) |
70 | #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) | 71 | #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) |
71 | #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) | 72 | #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) |
@@ -87,6 +88,8 @@ char *argv0; | |||
87 | #define TRUEGREEN(x) (((x) & 0xff00)) | 88 | #define TRUEGREEN(x) (((x) & 0xff00)) |
88 | #define TRUEBLUE(x) (((x) & 0xff) << 8) | 89 | #define TRUEBLUE(x) (((x) & 0xff) << 8) |
89 | 90 | ||
91 | /* constants */ | ||
92 | #define ISO14755CMD "dmenu -w %lu -p codepoint: </dev/null" | ||
90 | 93 | ||
91 | enum glyph_attribute { | 94 | enum glyph_attribute { |
92 | ATTR_NULL = 0, | 95 | ATTR_NULL = 0, |
@@ -338,6 +341,7 @@ static void xzoomabs(const Arg *); | |||
338 | static void xzoomreset(const Arg *); | 341 | static void xzoomreset(const Arg *); |
339 | static void printsel(const Arg *); | 342 | static void printsel(const Arg *); |
340 | static void printscreen(const Arg *) ; | 343 | static void printscreen(const Arg *) ; |
344 | static void iso14755(const Arg *); | ||
341 | static void toggleprinter(const Arg *); | 345 | static void toggleprinter(const Arg *); |
342 | static void sendbreak(const Arg *); | 346 | static void sendbreak(const Arg *); |
343 | 347 | ||
@@ -2633,6 +2637,30 @@ tprinter(char *s, size_t len) | |||
2633 | } | 2637 | } |
2634 | 2638 | ||
2635 | void | 2639 | void |
2640 | iso14755(const Arg *arg) | ||
2641 | { | ||
2642 | char cmd[sizeof(ISO14755CMD) + NUMMAXLEN(xw.win)]; | ||
2643 | FILE *p; | ||
2644 | char *us, *e, codepoint[9], uc[UTF_SIZ]; | ||
2645 | unsigned long utf32; | ||
2646 | |||
2647 | snprintf(cmd, sizeof(cmd), ISO14755CMD, xw.win); | ||
2648 | if (!(p = popen(cmd, "r"))) | ||
2649 | return; | ||
2650 | |||
2651 | us = fgets(codepoint, sizeof(codepoint), p); | ||
2652 | pclose(p); | ||
2653 | |||
2654 | if (!us || *us == '\0' || *us == '-' || strlen(us) > 7) | ||
2655 | return; | ||
2656 | if ((utf32 = strtoul(us, &e, 16)) == ULONG_MAX || | ||
2657 | (*e != '\n' && *e != '\0')) | ||
2658 | return; | ||
2659 | |||
2660 | ttysend(uc, utf8encode(utf32, uc)); | ||
2661 | } | ||
2662 | |||
2663 | void | ||
2636 | toggleprinter(const Arg *arg) | 2664 | toggleprinter(const Arg *arg) |
2637 | { | 2665 | { |
2638 | term.mode ^= MODE_PRINT; | 2666 | term.mode ^= MODE_PRINT; |