commit 772b49c6a65676fa417129db84001a1a065beedc
parent 4b2c11bc7914b5369c1db144c75e74a3b8532ac6
Author: Kris Maglione <jg@suckless.org>
Date: Wed, 27 May 2009 13:22:24 -0400
Fix ticket #114.
Diffstat:
2 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/cmd/menu/menu.c b/cmd/menu/menu.c
@@ -8,6 +8,8 @@ static Handlers handlers;
static int ltwidth;
+static void _menu_draw(bool);
+
enum {
ACCEPT = CARET_LAST,
REJECT,
@@ -52,6 +54,15 @@ menu_unmap(long id, void *p) {
}
static void
+selectitem(Item *i) {
+ if(i != matchidx) {
+ caret_set(input.filter_start, input.pos - input.string);
+ caret_insert(i->retstring, 0);
+ matchidx = i;
+ }
+}
+
+static void
menu_cmd(int op, int motion) {
int n;
@@ -86,38 +97,35 @@ next:
caret_move(op, motion);
break;
case CMPL_NEXT:
- matchidx = matchidx ? matchidx->next : matchfirst;
+ selectitem(matchidx ? matchidx->next : matchfirst);
break;
case CMPL_PREV:
- if(!matchidx)
- matchidx = matchfirst;
- matchidx = matchidx->prev;
+ selectitem((matchidx ? matchidx : matchstart)->prev);
break;
case CMPL_FIRST:
matchstart = matchfirst;
- matchidx = matchstart;
matchend = nil;
+ selectitem(matchstart);
break;
case CMPL_LAST:
- matchidx = matchfirst->prev;
+ selectitem(matchfirst->prev);
break;
case CMPL_NEXT_PAGE:
- matchidx = matchend->next;
+ if(matchend)
+ selectitem(matchend->next);
break;
case CMPL_PREV_PAGE:
matchend = matchstart->prev;
matchidx = nil;
+ _menu_draw(false);
+ selectitem(matchstart);
break;
}
- if(matchidx) {
- caret_set(input.filter_start, input.pos - input.string);
- caret_insert(matchidx->retstring, 0);
- }
menu_draw();
}
-void
-menu_draw(void) {
+static void
+_menu_draw(bool draw) {
Rectangle r, rd, rp, r2;
CTuple *c;
Item *i;
@@ -163,6 +171,9 @@ menu_draw(void) {
}
}
+ if(!draw)
+ return;
+
r2 = rd;
for(i=matchstart; i->string; i=i->next) {
r2.min.x = promptw + itemoff;
@@ -204,6 +215,11 @@ menu_draw(void) {
}
void
+menu_draw(void) {
+ _menu_draw(true);
+}
+
+void
menu_show(void) {
Rectangle r;
int height, pad;
diff --git a/rc/rc.wmii.rc b/rc/rc.wmii.rc
@@ -227,10 +227,10 @@ key $MODKEY-Return || fn $key {
wi_runcmd $WMII_TERM &}
key $MODKEY-t || fn $key {
- wmiir xwrite /ctl view `{wi_tags | wimenu -h $hist.tag -n 50} &}
+ tag=`{wi_tags | wimenu -h $hist.tag -n 50} && wmiir xwrite /ctl view $tag &}
key $MODKEY-Shift-t || fn $key {
- sel = `{wi_selclient} \
- wmiir xwrite /client/$sel/tags `{wi_tags | wimenu -h $hist.tag -n 50} &}
+ sel=`{wi_selclient} {
+ tag=`{wi_tags | wimenu -h $hist.tag -n 50} && wmiir xwrite /client/$sel/tags $tag } &}
key $MODKEY-^`{seq 0 9} || fn $key {
wmiir xwrite /ctl view `{echo $1 | sed 's/.*-//'}}