[wiki] [sites] Add a new patch navhistory for dmenu || phi
commit 27e32cdbaa3141f85d845df2288897dec8e7584f
Author: phi <crispyfrog_AT_163.com>
Date: Mon Apr 4 18:58:46 2016 +0800
Add a new patch navhistory for dmenu
diff --git a/tools.suckless.org/dmenu/patches/dmenu-4.6-navhistory.diff b/tools.suckless.org/dmenu/patches/dmenu-4.6-navhistory.diff
new file mode 100644
index 0000000..4add082
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/dmenu-4.6-navhistory.diff
_AT_@ -0,0 +1,173 @@
+diff -urp dmenu-4.6/config.def.h dmenu-4.6-patched/config.def.h
+--- dmenu-4.6/config.def.h 2015-11-09 06:42:21.000000000 +0800
++++ dmenu-4.6-patched/config.def.h 2016-04-03 10:59:02.413544865 +0800
+_AT_@ -15,3 +15,5 @@ static const char *outbgcolor = "#00fff
+ static const char *outfgcolor = "#000000";
+ /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+ static unsigned int lines = 0;
++static unsigned int maxhist = 15;
++static int histnodup = 1; /* if 0, record repeated histories */
+diff -urp dmenu-4.6/dmenu.c dmenu-4.6-patched/dmenu.c
+--- dmenu-4.6/dmenu.c 2015-11-09 06:42:21.000000000 +0800
++++ dmenu-4.6-patched/dmenu.c 2016-04-03 10:54:51.798552270 +0800
+_AT_@ -52,6 +52,10 @@ static XIC xic;
+ static ClrScheme scheme[SchemeLast];
+ static Drw *drw;
+
++static char *histfile;
++static char *histbuf, *histptr;
++static size_t histsz;
++
+ #include "config.h"
+
+ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
+_AT_@ -278,6 +282,105 @@ nextrune(int inc)
+ }
+
+ static void
++loadhistory(void)
++{
++ FILE *fp = NULL;
++ size_t sz;
++
++ if (!histfile)
++ return;
++ if (!(fp = fopen(histfile, "r")))
++ return;
++ fseek(fp, 0, SEEK_END);
++ sz = ftell(fp);
++ fseek(fp, 0, SEEK_SET);
++ if (sz) {
++ histsz = sz + 1 + BUFSIZ;
++ if (!(histbuf = malloc(histsz))) {
++ fprintf(stderr, "warning: cannot malloc %lu "\
++ "bytes", histsz);
++ } else {
++ histptr = histbuf + fread(histbuf, 1, sz, fp);
++ if (histptr <= histbuf) { /* fread error */
++ free(histbuf);
++ histbuf = NULL;
++ return;
++ }
++ if (histptr[-1] != '
')
++ *histptr++ = '
';
++ histptr[BUFSIZ - 1] = '
Received on Mon Apr 04 2016 - 12:58:16 CEST
This archive was generated by hypermail 2.3.0
: Mon Apr 04 2016 - 13:00:20 CEST