aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2016-10-08 16:22:18 +0200
committerQuentin Rameau <quinq@fifth.space>2016-10-18 13:32:36 +0200
commit68bae9c7b121e30114f6b0cabe15da3fae46e673 (patch)
tree8f7a4cc7ece80e42148dc61f1dcd420974401eed
parent331033f1f6abe259218666e6f6a848f38d884078 (diff)
downloadst-68bae9c7b121e30114f6b0cabe15da3fae46e673.tar.gz
st-68bae9c7b121e30114f6b0cabe15da3fae46e673.zip
Add support for iso14755
We launch dmenu for getting a codepoint, then convert it and send it to the terminal.
-rw-r--r--config.def.h1
-rw-r--r--st.c28
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/*
diff --git a/st.c b/st.c
index 6c16386..c67623f 100644
--- a/st.c
+++ b/st.c
@@ -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
91enum glyph_attribute { 94enum glyph_attribute {
92 ATTR_NULL = 0, 95 ATTR_NULL = 0,
@@ -338,6 +341,7 @@ static void xzoomabs(const Arg *);
338static void xzoomreset(const Arg *); 341static void xzoomreset(const Arg *);
339static void printsel(const Arg *); 342static void printsel(const Arg *);
340static void printscreen(const Arg *) ; 343static void printscreen(const Arg *) ;
344static void iso14755(const Arg *);
341static void toggleprinter(const Arg *); 345static void toggleprinter(const Arg *);
342static void sendbreak(const Arg *); 346static void sendbreak(const Arg *);
343 347
@@ -2633,6 +2637,30 @@ tprinter(char *s, size_t len)
2633} 2637}
2634 2638
2635void 2639void
2640iso14755(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
2663void
2636toggleprinter(const Arg *arg) 2664toggleprinter(const Arg *arg)
2637{ 2665{
2638 term.mode ^= MODE_PRINT; 2666 term.mode ^= MODE_PRINT;