changeset: 2552:4d85770063e3
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Oct 17 03:10:37 2009 -0400
files: cmd/menu/main.c cmd/menu/menu.c
description:
Add -S flag to wimenu.
diff -r a88f7925b77c -r 4d85770063e3 cmd/menu/main.c
--- a/cmd/menu/main.c Fri Oct 16 10:14:15 2009 -0400
+++ b/cmd/menu/main.c Sat Oct 17 03:10:37 2009 -0400
@@ -18,6 +18,7 @@
static Biobuf* cmplbuf;
static Biobuf* inbuf;
static bool alwaysprint;
+static char* cmdsep;
static void
usage(void) {
@@ -78,9 +79,13 @@
i = i->next;
i->string = p;
i->retstring = p;
+ if(cmdsep && (p = strstr(p, cmdsep))) {
+ *p = '\0';
+ i->retstring = p + strlen(cmdsep);
+ }
if(!hist) {
- i->len = strlen(p);
- i->width = textwidth_l(font, p, i->len);
+ i->len = strlen(i->string);
+ i->width = textwidth_l(font, i->string, i->len);
if(i->width > maxwidth)
maxwidth = i->width;
}
@@ -257,6 +262,9 @@
case 's':
screen = strtol(EARGF(usage()), nil, 10);
break;
+ case 'S':
+ cmdsep = EARGF(usage());
+ break;
case 'v':
print("%s", version);
return 0;
diff -r a88f7925b77c -r 4d85770063e3 cmd/menu/menu.c
--- a/cmd/menu/menu.c Fri Oct 16 10:14:15 2009 -0400
+++ b/cmd/menu/menu.c Sat Oct 17 03:10:37 2009 -0400
@@ -57,7 +57,7 @@
selectitem(Item *i) {
if(i != matchidx) {
caret_set(input.filter_start, input.pos - input.string);
- caret_insert(i->retstring, 0);
+ caret_insert(i->string, 0);
matchidx = i;
}
}
@@ -86,7 +86,10 @@
if(!matchidx && matchfirst->retstring && !motion)
if(input.filter_start == 0 && input.pos == input.end)
menu_cmd(CMPL_FIRST, 0);
- print("%s", input.string);
+ if(!motion && matchidx && !strcmp(input.string, matchidx->string))
+ print("%s", matchidx->retstring);
+ else
+ print("%s", input.string);
break;
case REJECT:
srv.running = false;
Received on Sat Oct 17 2009 - 23:49:03 UTC
This archive was generated by hypermail 2.2.0 : Sun Oct 18 2009 - 00:00:15 UTC