yori icon indicating copy to clipboard operation
yori copied to clipboard

Improvements to slmenu

Open stianhoiland opened this issue 1 year ago • 3 comments

In addition to #130, I have discovered some other desired use cases for slmenu.

When the list is very long, it is not possible to page up or page down. This would be good to have.

And really, I'm desiring a simple filter functionality in slmenu, so that the widget accepts keyboard input and interactively filters the list in accordance. In addition, and also accommodating this use, would be a switch for showing the slmenu list in a full screen (like yedit--is this called alternative screen?).

These features would make slmenu very powerful and more generally useful. But you may also feel like this is outside its purview.

stianhoiland avatar Dec 14 '24 19:12 stianhoiland

As motivation and as a curiosity, I will share some of the use cases that have me wanting this functionality.

In an auto-inited .ys1 script I have some aliases that do useful things, especially by bridging the Yori CLI to the Windows and Terminal GUI:

set YORICOMPLETEWITHTRAILINGSLASH=1
set YORIPROMPT=$E$[33;1m$P$$G_OR_ADMIN_G$$E$[0m
alias wait=ysleep
alias sleep=shutdn -e
alias clear=cls
alias say=yspeak $*$
alias edit=yedit -b $*$
alias code=cd D:\Users\stian\OneDrive\Code\C\$*$
alias run=start $*$
alias open=start .
alias dev="%ProgramFiles%\Microsoft Visual Studio\2022\Preview\Common7\Tools\VsDevCmd.bat"
alias sudo=start -e $*$
alias admin=start -e wt -d . yori
alias superedit=start -e wt -d . yori -c edit $*$
alias editalias=superedit ~appdir\YoriInit.d\Stian.ys1
alias new=wt -w 0 yori -k $*$
alias split=wt -w 0 sp yori -k $*$
alias launch=launcher $*$

This last alias launch calls a Launcher.ys1 script which looks like so:

start `dir /s /m ".\*%*%*.{exe,msi}" | slmenu -l 10`

(Can't directly define this as the alias since the backtick'd expression will evaluate when Yori launches.)

It may seem silly, but it's very useful. The launch command takes a string and then searches the current dir and any subdirs (/s) for anything executable, then displays them in slmenu for choice and executes your choice with start.

This technique could obviously be extended, but this gives the gist.

It's this usage which motivates the desired extensions to slmenu :)

stianhoiland avatar Dec 14 '24 19:12 stianhoiland

Can you say more about what makes it impossible to page up or page down? That should work.

I added support for full screen slmenu in commit 2eaab5fb61325b441f70a8f93887bcbf86693e4c .

I see your point about why it would be good to have search and filter options in slmenu, but need to think more about the UX for it. In addition it’d be nice for the list control to take multiple keystrokes to find an entry, but that probably won’t help with your scenario since all entries have the same prefix.

malxau avatar Dec 23 '24 07:12 malxau

Two more changes here: commit e272fb38e90e8fe2279605d5f5f767fd4391c126 implements logic so multiple keystrokes can be used to navigate in a list box, and commit e22fedb8682d0b73f5a83410165d4ab1be7ccd7a adds a find dialog to slmenu to search in larger lists. I think it could do with a “Find Next” type thing, which is a little frustrating since there’s currently no good way to bind the F3 key to a button.

Anyway, I’m curious how these change work in your scenario.

malxau avatar Dec 30 '24 06:12 malxau