st

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.instinctive.eu/st.git
Log | Files | Refs | README | LICENSE

commit 46a915ab43733308fa70e4dcebf68e1fb6a48e18
parent 76900b9b6870921510d4efd429d7b8e3966c7f48
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date:   Sun, 19 Feb 2023 10:42:23 +0100

[nat] ISO 14755

Diffstat:
Mconfig.def.h | 6++++++
Mst.1 | 4++++
Mst.c | 22++++++++++++++++++++++
Mst.h | 2++
4 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -171,6 +171,11 @@ static unsigned int defaultattr = 11; static uint forcemousemod = ShiftMask; /* + * Command used to query unicode glyphs. + */ +char *iso14755_cmd = "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null"; + +/* * Internal mouse shortcuts. * Beware that overloading Button1 will disable the selection. */ @@ -201,6 +206,7 @@ static Shortcut shortcuts[] = { { TERMMOD, XK_Y, selpaste, {.i = 0} }, { ShiftMask, XK_Insert, selpaste, {.i = 0} }, { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, + { TERMMOD, XK_I, iso14755, {.i = 0} }, }; /* diff --git a/st.1 b/st.1 @@ -159,6 +159,10 @@ Copy the selected text to the clipboard selection. .TP .B Ctrl-Shift-v Paste from the clipboard selection. +.TP +.B Ctrl-Shift-i +Launch dmenu to enter a unicode codepoint and send the corresponding glyph +to st. .SH CUSTOMIZATION .B st can be customized by creating a custom config.h and (re)compiling the source diff --git a/st.c b/st.c @@ -2044,6 +2044,28 @@ tprinter(char *s, size_t len) } void +iso14755(const Arg *arg) +{ + FILE *p; + char *us, *e, codepoint[9], uc[UTF_SIZ]; + unsigned long utf32; + + if (!(p = popen(iso14755_cmd, "r"))) + return; + + us = fgets(codepoint, sizeof(codepoint), p); + pclose(p); + + if (!us || *us == '\0' || *us == '-' || strlen(us) > 7) + return; + if ((utf32 = strtoul(us, &e, 16)) == ULONG_MAX || + (*e != '\n' && *e != '\0')) + return; + + ttywrite(uc, utf8encode(utf32, uc), 1); +} + +void toggleprinter(const Arg *arg) { term.mode ^= MODE_PRINT; diff --git a/st.h b/st.h @@ -81,6 +81,7 @@ void die(const char *, ...); void redraw(void); void draw(void); +void iso14755(const Arg *); void printscreen(const Arg *); void printsel(const Arg *); void sendbreak(const Arg *); @@ -124,3 +125,4 @@ extern unsigned int tabspaces; extern unsigned int defaultfg; extern unsigned int defaultbg; extern unsigned int defaultcs; +extern char *iso14755_cmd;