add keybind for navigating items quickly

This commit is contained in:
speedie 2023-03-20 16:33:23 +01:00
parent 10bc28ce94
commit 13d6ba9065
4 changed files with 39 additions and 4 deletions

View file

@ -16,12 +16,17 @@ This build of spmenu has some features written for this build.
Of course if you want, this is free software so you can use it in your own build.
- dwm-like keybind array (See keybinds.h)
- Vim-like modes, including indicator
- Vim-like modes, including indicator.
- The ability to move around items with keybinds.
- Customizable line/column size.
- Web browser like keybindings.
- 256 color support through SGR codes.
- Image support (from [this repository](https://github.com/Cloudef/dmenu-pango-imlib))
- Option to block typing.
- Rewritten arguments, old arguments still work though.
- Hiding each part of the menu
- Hiding each part of the menu.
..and more!
### Other features

View file

@ -13,7 +13,7 @@
*
* Example keybind:
*
* { MODIFIER1, XK_1, myfunction, ${0} },
* { -1, MODIFIER1, XK_1, myfunction, ${0} },
*
* Once you're done with your edits, run 'make clean install'.
*/
@ -66,13 +66,15 @@ static Key keys[] = {
{ 0, 0, XK_j, move, {.i = 2 } },
{ 0, 0, XK_h, move, {.i = 3 } },
{ 0, 0, XK_l, move, {.i = 4 } },
{ 0, CONTROL, XK_u, fastmoveup, {.i = 5 } },
{ 0, CONTROL, XK_d, fastmovedown, {.i = 5 } },
{ 0, CONTROL, XK_k, setlines, {.i = +1 } },
{ 0, CONTROL, XK_j, setlines, {.i = -1 } },
{ 0, CONTROL, XK_h, setcolumns, {.i = +1 } },
{ 0, CONTROL, XK_l, setcolumns, {.i = -1 } },
{ 0, CONTROL, XK_k, restoresel, {0} },
{ 0, CONTROL|SHIFT, XK_h, viewhist, {0} },
{ 0, CONTROL, XK_u, clear, {0} },
{ 0, 0, XK_d, clear, {0} },
{ 0, 0, XK_Escape, quit, {0} },
{ 0, 0, XK_Home, movestart, {0} },
{ 0, 0, XK_End, moveend, {0} },

View file

@ -78,6 +78,32 @@ move(const Arg *arg)
}
}
void
fastmoveup(const Arg *arg)
{
for (int i = 0; i < arg->i; i++) {
if (sel && sel->left && (sel = sel->left)->right == curr) {
curr = prev;
}
}
calcoffsets();
drawmenu();
}
void
fastmovedown(const Arg *arg)
{
for (int i = 0; i < arg->i; i++) {
if (sel && sel->right && (sel = sel->right) == next) {
curr = next;
}
}
calcoffsets();
drawmenu();
}
void
complete(const Arg *arg)
{

View file

@ -33,3 +33,5 @@ static void setimgpos(const Arg *arg);
static void setimggaps(const Arg *arg);
static void setlines(const Arg *arg);
static void setcolumns(const Arg *arg);
static void fastmoveup(const Arg *arg);
static void fastmovedown(const Arg *arg);