changeset: 2470:1e99af1304f5
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Wed May 27 13:22:24 2009 -0400
files: cmd/menu/menu.c rc/rc.wmii.rc
description:
Fix ticket #114.
diff -r 63165c426878 -r 1e99af1304f5 cmd/menu/menu.c
--- a/cmd/menu/menu.c Wed May 27 12:59:07 2009 -0400
+++ b/cmd/menu/menu.c Wed May 27 13:22:24 2009 -0400
@@ -7,6 +7,8 @@
static Handlers handlers;
static int ltwidth;
+
+static void _menu_draw(bool);
enum {
ACCEPT = CARET_LAST,
@@ -52,6 +54,15 @@
}
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 @@
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 @@
}
}
+ if(!draw)
+ return;
+
r2 = rd;
for(i=matchstart; i->string; i=i->next) {
r2.min.x = promptw + itemoff;
@@ -201,6 +212,11 @@
border(ibuf, rd, 1, cnorm.border);
copyimage(barwin, r, ibuf, ZP);
+}
+
+void
+menu_draw(void) {
+ _menu_draw(true);
}
void
diff -r 63165c426878 -r 1e99af1304f5 rc/rc.wmii.rc
--- a/rc/rc.wmii.rc Wed May 27 12:59:07 2009 -0400
+++ b/rc/rc.wmii.rc Wed May 27 13:22:24 2009 -0400
@@ -227,10 +227,10 @@
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/.*-//'}}
Received on Wed May 27 2009 - 17:22:26 UTC
This archive was generated by hypermail 2.2.0 : Wed May 27 2009 - 17:24:07 UTC