diff --git a/config.h b/config.h index 6eb9b7c..9886a72 100644 --- a/config.h +++ b/config.h @@ -34,6 +34,9 @@ static struct Config config = { /* area around the icon, the triangle and the separator */ .horzpadding = 8, + + /* if nonzero, enable type-to-select feature, can be togglet with -t */ + .typetoselect = 0 }; /* diff --git a/xmenu.1 b/xmenu.1 index c2495a1..3f45a0b 100644 --- a/xmenu.1 +++ b/xmenu.1 @@ -3,7 +3,7 @@ xmenu \- menu utility for X .SH SYNOPSIS .B xmenu -.RB [ \-irw ] +.RB [ \-irtw ] .RB [ -p .IR position ] .RI [ title ] @@ -58,6 +58,10 @@ must spawn at the position 100x500 of the monitor 0. If this option is set, the right mouse button is disabled; so pressing it will not trigger any menu item. .TP +.B -t +If this option is set, the type-to-select feature is enabled, +so typing a string will select the first item matching it. +.TP .B -w Asks the window manager to draw a border around the menus. This option may be buggy in some window managers, @@ -108,12 +112,22 @@ Select the first item in the menu. .BR End Select the last item in the menu. .TP -.BR Down ", " Tab +.BR Down Cycle through the items in the regular direction. .TP -.BR Up ", " Shift-Tab +.BR Tab +Cycle through the items in the regular direction. +If the type-to-select feature is enabled, and there is a typed string in memory, +cycle through matching items instead. +.TP +.BR Up Cycle through the items in the reverse direction. .TP +.BR Shift-Tab +Cycle through the items in the reverse direction. +If the type-to-select feature is enabled, and there is a typed string in memory, +cycle through matching items instead. +.TP .BR Right ", " Enter Select the highlighted item. .TP diff --git a/xmenu.c b/xmenu.c index ff4cf53..acdabc2 100644 --- a/xmenu.c +++ b/xmenu.c @@ -141,7 +141,7 @@ getoptions(int argc, char *argv[]) { int ch; - while ((ch = getopt(argc, argv, "ip:rw")) != -1) { + while ((ch = getopt(argc, argv, "ip:rtw")) != -1) { switch (ch) { case 'i': iflag = 1; @@ -153,6 +153,9 @@ getoptions(int argc, char *argv[]) case 'r': rflag = 1; break; + case 't': + config.typetoselect = !config.typetoselect; + break; case 'w': wflag = 1; break; @@ -1373,6 +1376,8 @@ enteritem: break; default: append: + if (!config.typetoselect) + break; for (i = 0; i < 2; i++) { append(text, buf, sizeof text, len); if ((item = matchitem(currmenu, text, 0))) diff --git a/xmenu.h b/xmenu.h index b5f1556..385eb82 100644 --- a/xmenu.h +++ b/xmenu.h @@ -50,6 +50,7 @@ struct Config { int iconpadding; int horzpadding; int alignment; + int typetoselect; /* the values below are set by options */ int monitor;