commit 6254fed817b712dcf9568bd36e023d60c49de0ac from: Omar Polo date: Fri Jul 06 19:28:22 2018 UTC the behaviour of the ``first completion selected'' can be changed at runtime commit - b10f01c1bad5b79537132a542f3d0a28f31244c0 commit + 6254fed817b712dcf9568bd36e023d60c49de0ac blob - d7cad52e802c9dd9ebf3fed9e93282d494824adf blob + 1338a09ecdc438b0c6a594dfd54b1810c665e400 --- mymenu.1 +++ mymenu.1 @@ -106,6 +106,13 @@ The same as Backspace Delete the last word .It C-u Delete the whole line +.It C-i +Toggle the ``first selected'' style. Sometimes, especially with the -a +option, could be handy to disable that behaviour. Let's say that +you've typed ``fire'' and the first completion is ``firefox'' but you +really want to choose ``fire''. While you can type some spaces, this +keybinding is a more elegant way to change, at runtime, the behaviour +of the first completion. .El .Sh BUGS blob - ec8cbcd78fe11cd012e496736f70d2ad9d221e36 blob + de28704796b332ce657706a92bde2b5e2daa2f25 --- mymenu.1.md +++ mymenu.1.md @@ -164,6 +164,15 @@ C-u > Delete the whole line +C-i + +> Toggle the \`\`first selected'' style. Sometimes, especially with the -a +> option, could be handy to disable that behaviour. Let's say that +> you've typed \`\`fire'' and the first completion is \`\`firefox'' but you +> really want to choose \`\`fire''. While you can type some spaces, this +> keybinding is a more elegant way to change, at runtime, the behaviour +> of the first completion. + # BUGS * If, instead of a numeric value, a not-valid number that terminates @@ -189,4 +198,4 @@ sysexits(3) Omar Polo <omar.polo@europecom.net> -OpenBSD 6.3 - July 1, 2018 +OpenBSD 6.3 - July 6, 2018 blob - b4e31d55f5e6deea73ee91c7cd31779d93a6aa48 blob + 86fc24eb58628748f497c5590450bf130a4c9084 --- mymenu.c +++ mymenu.c @@ -73,7 +73,8 @@ enum action { DEL_CHAR, DEL_WORD, DEL_LINE, - ADD_CHAR + ADD_CHAR, + TOGGLE_FIRST_SELECTED }; struct rendering { @@ -771,6 +772,8 @@ enum action parse_event(Display *d, XKeyPressedEvent * return NEXT_COMPL; if (!strcmp(str, "")) // C-c return EXIT; + if (!strcmp(str, "\t")) // C-i + return TOGGLE_FIRST_SELECTED; } *input = strdup((char*)&symbol); @@ -1275,6 +1278,12 @@ int main(int argc, char **argv) { } break; } + + case TOGGLE_FIRST_SELECTED: + first_selected = !first_selected; + if (cs) + cs->selected = !cs->selected; + break; } }