Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.2 KiB

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