sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-iso14755-0.8.5.diff (2284B)


      1 diff --git a/config.def.h b/config.def.h
      2 index 91ab8ca..6d1aee0 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -170,6 +170,11 @@ static unsigned int defaultattr = 11;
      6   */
      7  static uint forcemousemod = ShiftMask;
      8  
      9 +/*
     10 + * Command used to query unicode glyphs.
     11 + */
     12 +char *iso14755_cmd = "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null";
     13 +
     14  /*
     15   * Internal mouse shortcuts.
     16   * Beware that overloading Button1 will disable the selection.
     17 @@ -201,6 +206,7 @@ static Shortcut shortcuts[] = {
     18  	{ TERMMOD,              XK_Y,           selpaste,       {.i =  0} },
     19  	{ ShiftMask,            XK_Insert,      selpaste,       {.i =  0} },
     20  	{ TERMMOD,              XK_Num_Lock,    numlock,        {.i =  0} },
     21 +	{ TERMMOD,              XK_I,           iso14755,       {.i =  0} },
     22  };
     23  
     24  /*
     25 diff --git a/st.1 b/st.1
     26 index 39120b4..4a98626 100644
     27 --- a/st.1
     28 +++ b/st.1
     29 @@ -159,6 +159,10 @@ Copy the selected text to the clipboard selection.
     30  .TP
     31  .B Ctrl-Shift-v
     32  Paste from the clipboard selection.
     33 +.TP
     34 +.B Ctrl-Shift-i
     35 +Launch dmenu to enter a unicode codepoint and send the corresponding glyph
     36 +to st.
     37  .SH CUSTOMIZATION
     38  .B st
     39  can be customized by creating a custom config.h and (re)compiling the source
     40 diff --git a/st.c b/st.c
     41 index 51049ba..308162b 100644
     42 --- a/st.c
     43 +++ b/st.c
     44 @@ -2068,6 +2068,28 @@ tprinter(char *s, size_t len)
     45  	}
     46  }
     47  
     48 +void
     49 +iso14755(const Arg *arg)
     50 +{
     51 +	FILE *p;
     52 +	char *us, *e, codepoint[9], uc[UTF_SIZ];
     53 +	unsigned long utf32;
     54 +
     55 +	if (!(p = popen(iso14755_cmd, "r")))
     56 +		return;
     57 +
     58 +	us = fgets(codepoint, sizeof(codepoint), p);
     59 +	pclose(p);
     60 +
     61 +	if (!us || *us == '\0' || *us == '-' || strlen(us) > 7)
     62 +		return;
     63 +	if ((utf32 = strtoul(us, &e, 16)) == ULONG_MAX ||
     64 +	    (*e != '\n' && *e != '\0'))
     65 +		return;
     66 +
     67 +	ttywrite(uc, utf8encode(utf32, uc), 1);
     68 +}
     69 +
     70  void
     71  toggleprinter(const Arg *arg)
     72  {
     73 diff --git a/st.h b/st.h
     74 index 519b9bd..51aa1ae 100644
     75 --- a/st.h
     76 +++ b/st.h
     77 @@ -81,6 +81,7 @@ void die(const char *, ...);
     78  void redraw(void);
     79  void draw(void);
     80  
     81 +void iso14755(const Arg *);
     82  void printscreen(const Arg *);
     83  void printsel(const Arg *);
     84  void sendbreak(const Arg *);
     85 @@ -126,3 +127,4 @@ extern unsigned int tabspaces;
     86  extern unsigned int defaultfg;
     87  extern unsigned int defaultbg;
     88  extern unsigned int defaultcs;
     89 +extern char *iso14755_cmd;