From 21f9aa09e5515148cf39d89711ef0286f43859d9 Mon Sep 17 00:00:00 2001 From: speedie Date: Sun, 16 Jul 2023 18:44:35 +0200 Subject: [PATCH] Add documentation for functions --- docs/docs.md | 100 +++++++++++++++- libs/arg.c | 77 +++++++++++-- libs/conf/config.h | 84 ++++++++------ spmenu.1 | 278 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 489 insertions(+), 50 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 3fb7a1d..f577edc 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -863,6 +863,9 @@ spmenu supports mouse clicks. The following parts can be clicked on: - `None` - Any click +For information on the different functions you can pass, see the bottom of this +man page, 'List of all configurable functions'. + You can set mouse binds through the config file. A default config file is available after installing spmenu. This configuration file has identical keybinds to the default hardcoded keybinds. @@ -884,7 +887,6 @@ These are the default mouse binds. Mode does not apply for mouse binds. | None | Scroll Up | moveprev | 0 | | None | Scroll Down | movenext | 0 | - ## .Xresources **NOTE: Only applies for X11 users** @@ -924,6 +926,102 @@ is the official theme manager, but you could use another one or write your own. For more information on the theme.conf configuration file, see [this page](https://spmenu.speedie.site/theme.conf+documentation). +## List of all configurable functions + +This is a list of all functions that can be called using a key or mouse +bind: + +- `moveup` + - Move up by MAX(passed argument, 1) +- `movedown` + - Move down by MAX(passed argument, 1) +- `moveleft` + - Move left by MAX(passed argument, 1) +- `moveright` + - Move right by MAX(passed argument, 1) +- `movestart` + - Move to the first item +- `moveend` + - Move to the last item +- `movenext` + - Move to the next page +- `moveprev` + - Move to the previous page +- `moveitem` + - Move to item passed argument +- `paste` + - Paste from clipboard, 0 means clipboard selection, 1 means primary selection +- `restoresel` + - Move back to the first item +- `clear` + - Clear input +- `clearins` + - Clear input text and switch to insert mode +- `viewhist` + - Toggle history and item buffer +- `moveword` + - Navigate through input text by 1 word, -1 means start, +1 means end +- `deleteword` + - Delete input text by 1 word +- `movecursor` + - Move cursor (caret) by MAX(passed argument, 1) +- `navhistory` + - Navigate through history buffer, -1 means forward, +1 means backwards +- `backspace` + - Backspace 1 character from input text +- `selectitem` + - Select the current selected item +- `quit` + - Quit spmenu +- `complete` + - Tab complete the selected item +- `setimgsize` + - Set image size to passed argument +- `defaultimg` + - Reset image size to the default +- `toggleinput` + - Toggle input +- `togglelarrow` + - Toggle left arrow +- `togglerarrow` + - Toggle right arrow +- `toggleitem` + - Toggle items +- `toggleprompt` + - Toggle prompt +- `togglecaps` + - Toggle caps lock indicator +- `togglepowerline` + - Toggle powerlines +- `togglecaret` + - Toggle caret (cursor) +- `togglehighlight` + - Toggle highlighting +- `togglematchcount` + - Toggle match count +- `togglemode` + - Toggle mode +- `toggleregex` + - Toggle regex mode +- `toggleimg` + - Toggle images +- `flipimg` + - Flip image, 0 means vertically, 1 means horizontally +- `setimgpos` + - Move to the next image position +- `setimggaps` + - Set image gaps to passed argument +- `setlines` + - Set lines to passed argument +- `setcolumns` + - Set columns to passed argument +- `setprofile` + - Open profile menu if available +- `switchmode` + - Switch between Normal mode and Insert mode +- `screenshot` + - Take a screenshot of spmenu + ## License spmenu is licensed under the MIT license. The documentation is licensed diff --git a/libs/arg.c b/libs/arg.c index 9cc96fb..55549f3 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -443,6 +443,71 @@ void setimggaps(Arg *arg) { #endif } +void toggleinput(Arg *arg) { + hideinput = !hideinput; + drawmenu(); +} + +void togglelarrow(Arg *arg) { + hidelarrow = !hidelarrow; + drawmenu(); +} + +void togglerarrow(Arg *arg) { + hiderarrow = !hiderarrow; + drawmenu(); +} + +void toggleitem(Arg *arg) { + hideitem = !hideitem; + drawmenu(); +} + +void toggleprompt(Arg *arg) { + hideprompt = !hideprompt; + drawmenu(); +} + +void togglecaps(Arg *arg) { + hidecaps = !hidecaps; + drawmenu(); +} + +void togglepowerline(Arg *arg) { + hidepowerline = !hidepowerline; + drawmenu(); +} + +void togglecaret(Arg *arg) { + hidecaret = !hidecaret; + drawmenu(); +} + +void togglematchcount(Arg *arg) { + hidematchcount = !hidematchcount; + drawmenu(); +} + +void togglemode(Arg *arg) { + hidemode = !hidemode; + drawmenu(); +} + +void togglehighlight(Arg *arg) { + hidehighlight = !hidehighlight; + drawmenu(); +} + +void toggleregex(Arg *arg) { +#if USEREGEX + regex = !regex; + + match(); + drawmenu(); + +#endif +} + void toggleimg(Arg *arg) { #if USEIMAGE @@ -512,11 +577,6 @@ void spawn(Arg *arg) { exit(0); } -void togglehighlight(Arg *arg) { - hidehighlight = !hidehighlight; - drawmenu(); -} - void setprofile(Arg *arg) { if (!system("command -v spmenu_profile > /dev/null && spmenu_profile --spmenu-set-profile")) { die("spmenu: failed to run profile menu\n"); @@ -525,13 +585,6 @@ void setprofile(Arg *arg) { } } -void toggleregex(Arg *arg) { - regex = !regex; - - match(); - drawmenu(); -} - void switchmode(Arg *arg) { if (sp.forceinsertmode) { return; diff --git a/libs/conf/config.h b/libs/conf/config.h index d249058..7daae6c 100644 --- a/libs/conf/config.h +++ b/libs/conf/config.h @@ -347,43 +347,53 @@ static ArgList al[] = { }; static FuncList fl[] = { - { "moveup", moveup }, - { "movedown", movedown }, - { "moveleft", moveleft }, - { "moveright", moveright }, - { "moveend", moveend }, - { "movestart", movestart }, - { "movenext", movenext }, - { "moveprev", moveprev }, - { "moveitem", moveitem }, - { "paste", paste }, - { "restoresel", restoresel }, - { "clear", clear }, - { "clearins", clearins }, - { "viewhist", viewhist }, - { "moveword", moveword }, - { "deleteword", deleteword }, - { "movecursor", movecursor }, - { "navhistory", navhistory }, - { "backspace", backspace }, - { "selectitem", selectitem }, - { "markitem", markitem }, - { "quit", quit }, - { "complete", complete }, - { "setimgsize", setimgsize }, - { "toggleimg", toggleimg }, - { "defaultimg", defaultimg }, - { "flipimg", flipimg }, - { "setimgpos", setimgpos }, - { "setimggaps", setimggaps }, - { "setlines", setlines }, - { "screenshot", screenshot }, - { "setcolumns", setcolumns }, - { "togglehighlight",togglehighlight }, - { "toggleregex", toggleregex }, - { "setprofile", setprofile }, - { "switchmode", switchmode }, - { "spawn", spawn }, + { "moveup", moveup }, + { "movedown", movedown }, + { "moveleft", moveleft }, + { "moveright", moveright }, + { "moveend", moveend }, + { "movestart", movestart }, + { "movenext", movenext }, + { "moveprev", moveprev }, + { "moveitem", moveitem }, + { "paste", paste }, + { "restoresel", restoresel }, + { "clear", clear }, + { "clearins", clearins }, + { "viewhist", viewhist }, + { "moveword", moveword }, + { "deleteword", deleteword }, + { "movecursor", movecursor }, + { "navhistory", navhistory }, + { "backspace", backspace }, + { "selectitem", selectitem }, + { "markitem", markitem }, + { "quit", quit }, + { "complete", complete }, + { "setimgsize", setimgsize }, + { "defaultimg", defaultimg }, + { "flipimg", flipimg }, + { "setimgpos", setimgpos }, + { "setimggaps", setimggaps }, + { "setlines", setlines }, + { "screenshot", screenshot }, + { "setcolumns", setcolumns }, + { "toggleinput", toggleinput }, + { "togglelarrow", togglelarrow }, + { "togglerarrow", togglerarrow }, + { "toggleitem", toggleitem }, + { "toggleprompt", toggleprompt }, + { "togglecaps", togglecaps }, + { "togglepowerline", togglepowerline }, + { "togglecaret", togglecaret }, + { "togglehighlight", togglehighlight }, + { "togglematchcount", togglematchcount }, + { "togglemode", togglemode }, + { "toggleregex", toggleregex }, + { "toggleimg", toggleimg }, + { "setprofile", setprofile }, + { "switchmode", switchmode }, + { "spawn", spawn }, }; // list of modifiers that can be used in the config file diff --git a/spmenu.1 b/spmenu.1 index 9c7a283..0967914 100644 --- a/spmenu.1 +++ b/spmenu.1 @@ -1447,6 +1447,9 @@ Clicking on the mode indicator Any click .RE .PP +For information on the different functions you can pass, see the bottom +of this man page, `List of all configurable functions'. +.PP You can set mouse binds through the config file. A default config file is available after installing spmenu. This configuration file has identical keybinds to the default hardcoded @@ -1583,6 +1586,281 @@ theme manager, but you could use another one or write your own. .PP For more information on the theme.conf configuration file, see this page (https://spmenu.speedie.site/theme.conf+documentation). +.SS List of all configurable functions +.PP +This is a list of all functions that can be called using a key or mouse +bind: +.IP \[bu] 2 +\f[V]moveup\f[R] +.RS 2 +.IP \[bu] 2 +Move up by MAX(passed argument, 1) +.RE +.IP \[bu] 2 +\f[V]movedown\f[R] +.RS 2 +.IP \[bu] 2 +Move down by MAX(passed argument, 1) +.RE +.IP \[bu] 2 +\f[V]moveleft\f[R] +.RS 2 +.IP \[bu] 2 +Move left by MAX(passed argument, 1) +.RE +.IP \[bu] 2 +\f[V]moveright\f[R] +.RS 2 +.IP \[bu] 2 +Move right by MAX(passed argument, 1) +.RE +.IP \[bu] 2 +\f[V]movestart\f[R] +.RS 2 +.IP \[bu] 2 +Move to the first item +.RE +.IP \[bu] 2 +\f[V]moveend\f[R] +.RS 2 +.IP \[bu] 2 +Move to the last item +.RE +.IP \[bu] 2 +\f[V]movenext\f[R] +.RS 2 +.IP \[bu] 2 +Move to the next page +.RE +.IP \[bu] 2 +\f[V]moveprev\f[R] +.RS 2 +.IP \[bu] 2 +Move to the previous page +.RE +.IP \[bu] 2 +\f[V]moveitem\f[R] +.RS 2 +.IP \[bu] 2 +Move to item passed argument +.RE +.IP \[bu] 2 +\f[V]paste\f[R] +.RS 2 +.IP \[bu] 2 +Paste from clipboard, 0 means clipboard selection, 1 means primary +selection +.RE +.IP \[bu] 2 +\f[V]restoresel\f[R] +.RS 2 +.IP \[bu] 2 +Move back to the first item +.RE +.IP \[bu] 2 +\f[V]clear\f[R] +.RS 2 +.IP \[bu] 2 +Clear input +.RE +.IP \[bu] 2 +\f[V]clearins\f[R] +.RS 2 +.IP \[bu] 2 +Clear input text and switch to insert mode +.RE +.IP \[bu] 2 +\f[V]viewhist\f[R] +.RS 2 +.IP \[bu] 2 +Toggle history and item buffer +.RE +.IP \[bu] 2 +\f[V]moveword\f[R] +.RS 2 +.IP \[bu] 2 +Navigate through input text by 1 word, -1 means start, +1 means end +.RE +.IP \[bu] 2 +\f[V]deleteword\f[R] +.RS 2 +.IP \[bu] 2 +Delete input text by 1 word +.RE +.IP \[bu] 2 +\f[V]movecursor\f[R] +.RS 2 +.IP \[bu] 2 +Move cursor (caret) by MAX(passed argument, 1) +.RE +.IP \[bu] 2 +\f[V]navhistory\f[R] +.RS 2 +.IP \[bu] 2 +Navigate through history buffer, -1 means forward, +1 means backwards +.RE +.IP \[bu] 2 +\f[V]backspace\f[R] +.RS 2 +.IP \[bu] 2 +Backspace 1 character from input text +.RE +.IP \[bu] 2 +\f[V]selectitem\f[R] +.RS 2 +.IP \[bu] 2 +Select the current selected item +.RE +.IP \[bu] 2 +\f[V]quit\f[R] +.RS 2 +.IP \[bu] 2 +Quit spmenu +.RE +.IP \[bu] 2 +\f[V]complete\f[R] +.RS 2 +.IP \[bu] 2 +Tab complete the selected item +.RE +.IP \[bu] 2 +\f[V]setimgsize\f[R] +.RS 2 +.IP \[bu] 2 +Set image size to passed argument +.RE +.IP \[bu] 2 +\f[V]defaultimg\f[R] +.RS 2 +.IP \[bu] 2 +Reset image size to the default +.RE +.IP \[bu] 2 +\f[V]toggleinput\f[R] +.RS 2 +.IP \[bu] 2 +Toggle input +.RE +.IP \[bu] 2 +\f[V]togglelarrow\f[R] +.RS 2 +.IP \[bu] 2 +Toggle left arrow +.RE +.IP \[bu] 2 +\f[V]togglerarrow\f[R] +.RS 2 +.IP \[bu] 2 +Toggle right arrow +.RE +.IP \[bu] 2 +\f[V]toggleitem\f[R] +.RS 2 +.IP \[bu] 2 +Toggle items +.RE +.IP \[bu] 2 +\f[V]toggleprompt\f[R] +.RS 2 +.IP \[bu] 2 +Toggle prompt +.RE +.IP \[bu] 2 +\f[V]togglecaps\f[R] +.RS 2 +.IP \[bu] 2 +Toggle caps lock indicator +.RE +.IP \[bu] 2 +\f[V]togglepowerline\f[R] +.RS 2 +.IP \[bu] 2 +Toggle powerlines +.RE +.IP \[bu] 2 +\f[V]togglecaret\f[R] +.RS 2 +.IP \[bu] 2 +Toggle caret (cursor) +.RE +.IP \[bu] 2 +\f[V]togglehighlight\f[R] +.RS 2 +.IP \[bu] 2 +Toggle highlighting +.RE +.IP \[bu] 2 +\f[V]togglematchcount\f[R] +.RS 2 +.IP \[bu] 2 +Toggle match count +.RE +.IP \[bu] 2 +\f[V]togglemode\f[R] +.RS 2 +.IP \[bu] 2 +Toggle mode +.RE +.IP \[bu] 2 +\f[V]toggleregex\f[R] +.RS 2 +.IP \[bu] 2 +Toggle regex mode +.RE +.IP \[bu] 2 +\f[V]toggleimg\f[R] +.RS 2 +.IP \[bu] 2 +Toggle images +.RE +.IP \[bu] 2 +\f[V]flipimg\f[R] +.RS 2 +.IP \[bu] 2 +Flip image, 0 means vertically, 1 means horizontally +.RE +.IP \[bu] 2 +\f[V]setimgpos\f[R] +.RS 2 +.IP \[bu] 2 +Move to the next image position +.RE +.IP \[bu] 2 +\f[V]setimggaps\f[R] +.RS 2 +.IP \[bu] 2 +Set image gaps to passed argument +.RE +.IP \[bu] 2 +\f[V]setlines\f[R] +.RS 2 +.IP \[bu] 2 +Set lines to passed argument +.RE +.IP \[bu] 2 +\f[V]setcolumns\f[R] +.RS 2 +.IP \[bu] 2 +Set columns to passed argument +.RE +.IP \[bu] 2 +\f[V]setprofile\f[R] +.RS 2 +.IP \[bu] 2 +Open profile menu if available +.RE +.IP \[bu] 2 +\f[V]switchmode\f[R] +.RS 2 +.IP \[bu] 2 +Switch between Normal mode and Insert mode +.RE +.IP \[bu] 2 +\f[V]screenshot\f[R] +.RS 2 +.IP \[bu] 2 +Take a screenshot of spmenu +.RE .SS License .PP spmenu is licensed under the MIT license.