En ce qui concerne dmenu vertical :
2 patchs sur internet :
http://schiewek.net/fresch/dmenu-3.9-fresch-3.diff :
le plus complet, des options très intéresssantes, d’autres juste cosmétiques (mes propos n’engagent que moi)
remplacer toutes les occurences de 3.9 par 4.0 pour qu’il s’applique bien sur un dmenu actuel (16.4ko)
http://prog.marmaro.de/dwm-meillo/dmenu-4.0-vertical_meillo.diff
version minimale du premier, n’ajoute que le mode vertical à dmenu et rien d’autre. (6ko)
J’en ai fait un troisième pour alléger le premier et compléter le deuxième, comme on peut toujours pas joindre des .diff en pièce jointe,
je vais le coller ici : (11.7ko)[code]
diff -up dmenu/dmenu-4.0/config.h dmenu/dmenu_vertical/config.h
— a/config.h 2009-04-18 13:50:04.000000000 +0200
+++ b/config.h 2009-10-15 11:17:36.000000000 +0200
@@ -1,9 +1,10 @@
/* See LICENSE file for copyright and license details. */
/* appearance /
-static const char font = "--terminus-medium-r-normal--14-------";
-static const char normbgcolor = “#cccccc”;
-static const char normfgcolor = “#000000”;
-static const char selbgcolor = “#0066ff”;
+static const char font = "-misc-fixed-medium-r---14-------";
+static const char *normbgcolor = “#000000”;
+static const char *normfgcolor = “#00ff00”;
+static const char *selbgcolor = “darkgreen”;
static const char selfgcolor = “#ffffff”;
static unsigned int spaceitem = 30; / px between menu items /
+static unsigned int maxtokens = 16; / max. tokens for pattern matching */
diff -up dmenu/dmenu-4.0/config.mk dmenu/dmenu_vertical/config.mk
— a/config.mk 2009-04-18 13:50:04.000000000 +0200
+++ b/config.mk 2009-10-15 11:51:53.000000000 +0200
@@ -1,5 +1,5 @@
dmenu version
-VERSION = 4.0
+VERSION = 4.0-vertical
Customize below to fit your system
diff -up dmenu/dmenu-4.0/dmenu.1 dmenu/dmenu_vertical/dmenu.1
— a/dmenu.1 2009-04-18 13:50:04.000000000 +0200
+++ b/dmenu.1 2009-10-15 11:07:35.000000000 +0200
@@ -5,12 +5,18 @@ dmenu - dynamic menu
.B dmenu
.RB [ -i ]
.RB [ -b ]
+.RB [ -a ]
+.RB [ -fl]
.RB [ -fn " "]
.RB [ -nb " "]
.RB [ -nf " "]
.RB [ -p " "]
.RB [ -sb " "]
.RB [ -sf " “]
+.RB [ -l " <#items>”]
+.RB [ -ms ]
+.RB [ -nl ]
+.RB [ -xs ]
.RB [ -v ]
.SH DESCRIPTION
.SS Overview
@@ -26,6 +32,14 @@ makes dmenu match menu entries case inse
.B -b
defines that dmenu appears at the bottom.
.TP
+.B -a
+makes dmenu autoconfirm, useful on recursive script.
+.TP
+.B -fl
+similar to -a but doesn’t care of substring,
+you have to type from first letter to match.
+Decrease the number of item faster on non-similar-begin item list.
+.TP
.B -fn
defines the font.
.TP
@@ -44,8 +58,22 @@ defines the selected background color (#
.B -sf
defines the selected foreground color (#RGB, #RRGGBB, and color names are supported).
.TP
+.B -l <#items>
+activates vertical list mode.
+window-size will be adjusted for displaying the given number of items.
+.TP
+.B -ms
+multi-select; selecting an item and pressing return won’t terminate dmenu.
+.TP
+.B -nl
+seperates standard output by newlines.
+.TP
+.B -xs
+xmms-like pattern matching.
+.TP
.B -v
prints version information to standard output, then exits.
+.TP
.SH USAGE
dmenu reads a list of newline-separated items from standard input and creates a
menu. When the user selects an item or enters any text and presses Return, his/her
@@ -57,7 +85,7 @@ dmenu is completely controlled by the ke
Appends the character to the text in the input field. This works as a filter:
only items containing this text will be displayed.
.TP
-.B Left/Right (Mod1-h/Mod1-l)
+.B Left/Right (Up/Down) (Mod1-h/Mod1-l)
Select the previous/next item.
.TP
.B PageUp/PageDown (Mod1-k/Mod1-j)
@@ -96,3 +124,4 @@ Remove all characters of current word fr
.SH SEE ALSO
.BR dwm (1),
.BR wmii (1) .
+.BR surf (1) .
diff -up dmenu/dmenu-4.0/dmenu.c dmenu/dmenu_vertical/dmenu.c
— a/dmenu.c 2009-04-18 13:50:04.000000000 +0200
+++ b/dmenu.c 2009-10-15 11:16:51.000000000 +0200
@@ -47,10 +47,12 @@ struct Item {
/* forward declarations */
static void appenditem(Item *i, Item **list, Item **last);
-static void calcoffsets(void);
+static void calcoffsetsh(void);
+static void calcoffsetsv(void);
static char *cistrstr(const char *s, const char *sub);
static void cleanup(void);
-static void drawmenu(void);
+static void drawmenuh(void);
+static void drawmenuv(void);
static void drawtext(const char *text, unsigned long col[ColLast]);
static void eprint(const char *errstr, …);
static unsigned long getcolor(const char *colstr);
@@ -69,6 +71,10 @@ static int textw(const char text);
/ variables */
static char *maxname = NULL;
static char *prompt = NULL;
+static Bool autoconfirm = False;
+static Bool flautoconfirm = False;
+static char *nl = “”;
+static char **tokens = NULL;
static char text[4096];
static int cmdw = 0;
static int promptw = 0;
@@ -77,6 +83,8 @@ static int screen;
static unsigned int mw, mh;
static unsigned int numlockmask = 0;
static Bool running = True;
+static Bool multiselect = False;
+static Bool xmms = False;
static Display *dpy;
static DC dc;
static Item allitems = NULL; / first of all items */
@@ -88,6 +96,10 @@ static Item *curr = NULL;
static Window root, win;
static int (*fstrncmp)(const char *, const char *, size_t n) = strncmp;
static char *(*fstrstr)(const char *, const char *) = strstr;
+static Bool vlist = False;
+static unsigned int lines = 0;
+static void (*calcoffsets)(void) = calcoffsetsh;
+static void (*drawmenu)(void) = drawmenuh;
void
appenditem(Item *i, Item **list, Item **last) {
@@ -101,7 +113,7 @@ appenditem(Item *i, Item **list, Item **
}
void
-calcoffsets(void) {
+calcoffsetsh(void) {
int tw;
unsigned int w;
@@ -127,6 +139,26 @@ calcoffsets(void) {
}
}
+void
+calcoffsetsv(void) {
- static unsigned int w;
-
- if(!curr)
-
return;
- w = (dc.font.height + 2) * (lines + 1);
- for(next = curr; next; next=next->right) {
-
w -= dc.font.height + 2;
-
if(w <= 0)
-
break;
- }
- w = (dc.font.height + 2) * (lines + 1);
- for(prev = curr; prev && prev->left; prev=prev->left) {
-
w -= dc.font.height + 2;
-
if(w <= 0)
-
break;
- }
+}
-
char *
cistrstr(const char *s, const char *sub) {
int c, csub;
@@ -168,10 +200,11 @@ cleanup(void) {
XFreeGC(dpy, dc.gc);
XDestroyWindow(dpy, win);
XUngrabKeyboard(dpy, CurrentTime);
void
-drawmenu(void) {
+drawmenuh(void) {
Item *i;
dc.x = 0;
@@ -212,6 +245,39 @@ drawmenu(void) {
}
void
+drawmenuv(void) {
- Item *i;
-
- dc.x = 0;
- dc.y = 0;
- dc.w = mw;
- dc.h = mh;
- drawtext(NULL, dc.norm);
- /* print prompt? */
- if(promptw) {
-
dc.w = promptw;
-
drawtext(prompt, dc.sel);
- }
- dc.x += promptw;
- dc.w = mw - promptw;
- /* print command */
- drawtext(text[0] ? text : NULL, dc.norm);
- if(curr) {
-
dc.x = 0;
-
dc.w = mw;
-
dc.y += dc.font.height + 2;
-
/* determine maximum items */
-
for(i = curr; i != next; i=i->right) {
-
drawtext(i->text, (sel == i) ? dc.sel : dc.norm);
-
dc.y += dc.font.height + 2;
-
}
-
drawtext(NULL, dc.norm);
- }
- XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
- XFlush(dpy);
+}
-
+void
drawtext(const char *text, unsigned long col[ColLast]) {
char buf[256];
int i, x, y, h, len, olen;
@@ -222,8 +288,8 @@ drawtext(const char *text, unsigned long
if(!text)
return;
olen = strlen(text);
- h = dc.font.ascent + dc.font.descent;
- y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
- h = dc.font.height;
- y = dc.y + ((h+2) / 2) - (h / 2) + dc.font.ascent;
x = dc.x + (h / 2);
/* shorten text if necessary */
for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len–);
@@ -426,6 +492,7 @@ kpress(XKeyEvent * e) {
calcoffsets();
break;
case XK_Left:
- case XK_Up:
if(!(sel && sel->left))
return;
sel=sel->left;
@@ -448,15 +515,16 @@ kpress(XKeyEvent * e) {
break;
case XK_Return:
if((e->state & ShiftMask) && *text)
+unsigned int tokenize(char *pat, char **tok)
+{
void
match(char *pattern) {
-
unsigned int plen, tokencnt = 0;
-
char append = 0;
Item *i, *itemend, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend;
if(!pattern)
return;
- if(!xmms)
-
tokens[(tokencnt = 1)-1] = pattern;
- else
-
if(!(tokencnt = tokenize(pattern, tokens)))
-
tokens[(tokencnt = 1)-1] = "";
- item = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL;
- for(i = allitems; i; i = i->next) {
-
for(int j = 0; j < tokencnt; ++j) {
-
plen = strlen(tokens[j]);
-
if(!fstrncmp(tokens[j], i->text, plen + 1))
-
append = !append || append > 1 ? 1 : append;
-
else if(!fstrncmp(tokens[j], i->text, plen ))
-
append = !append || append > 2 ? 2 : append;
-
else if(fstrstr(i->text, tokens[j]))
-
append = append > 0 && append < 3 ? append : 3;
-
else {
-
append = 0;
-
break;
-
}
-
}
-
if(append == 1)
appenditem(i, &lexact, &exactend);
-
else if(append == 3)
appenditem(i, &lsubstr, &substrend);
- }
if(lexact) {
item = lexact;
itemend = exactend;
@@ -514,6 +615,18 @@ match(char *pattern) {
}
curr = prev = next = sel = item;
calcoffsets();
-
- if(autoconfirm && item && !item->right) {
-
fprintf(stdout, "%s", item->text);
-
fflush(stdout);
-
running=False;
- }
-
- if(flautoconfirm && item && item==itemend) {
-
fprintf(stdout, "%s", item->text);
-
fflush(stdout);
-
running=False;
- }
}
void
@@ -598,6 +711,7 @@ setup(Bool topbar) {
/* menu window geometry */
mh = dc.font.height + 2;
- mh = vlist ? mh * (lines+1) : mh;
#if XINERAMA
if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) {
i = 0;
@@ -643,6 +757,7 @@ setup(Bool topbar) {
if(promptw > mw / 5)
promptw = mw / 5;
text[0] = 0;
- tokens = malloc((xmms?maxtokens:1)sizeof(char));
match(text);
XMapRaised(dpy, win);
}
@@ -674,8 +789,18 @@ main(int argc, char *argv[]) {
fstrncmp = strncasecmp;
fstrstr = cistrstr;
}
-
else if(!strcmp(argv[i], "-a"))
-
autoconfirm = True;
-
else if(!strcmp(argv[i], "-fl"))
-
flautoconfirm = True;
else if(!strcmp(argv[i], "-b"))
topbar = False;
-
else if(!strcmp(argv[i], "-l")) {
-
vlist = True;
-
calcoffsets = calcoffsetsv;
-
drawmenu = drawmenuv;
-
if(++i < argc) lines += atoi(argv[i]);
-
}
else if(!strcmp(argv[i], "-fn")) {
if(++i < argc) font = argv[i];
}
@@ -694,11 +819,17 @@ main(int argc, char *argv[]) {
else if(!strcmp(argv[i], “-sf”)) {
if(++i < argc) selfgcolor = argv[i];
}
-
else if(!strcmp(argv[i], "-nl"))
-
nl = "\n";
-
else if(!strcmp(argv[i], "-ms"))
-
multiselect = True;
-
else if(!strcmp(argv[i], "-xs"))
-
xmms = True;
else if(!strcmp(argv[i], "-v"))
eprint("dmenu-"VERSION", © 2006-2008 dmenu engineers, see LICENSE for details\n");
else