commit 27e32cdbaa3141f85d845df2288897dec8e7584f
Author: phi <[email protected]>
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
@@ -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
+@@ -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
+@@ -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;
+@@ -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] = '

Reply via email to