kakoune icon indicating copy to clipboard operation
kakoune copied to clipboard

src: Allow `:on-key` to display an information box

Open lenormf opened this issue 5 years ago • 4 comments

Key mappings that use on-key to emulate single hit prompts (like the t primitive) currently have no way of notifying the user that an input is pending.

This commit allows passing an -info flag to on-key, in order to display the given string in an information box until a key is hit, e.g.

on-key -info "hit a key" 'echo %val{key}'

lenormf avatar Nov 05 '19 21:11 lenormf

My usecase is for the following user-mapping, which I would like not to be running without any kind of notification that input is pending:

map -docstring "select after the given character" global user 't' %{: on-key 'exec / %val{key} \K.<lt>ret>'<ret>}

lenormf avatar Nov 05 '19 21:11 lenormf

aren't you better served by doing info 'hit a key'; on-key 'echo %val{key}'? that way you can use the full options of info, title and all.

occivink avatar Nov 05 '19 21:11 occivink

I just wanted a simple way to show a message on screen, adding a flag to :on-key as a shortcut is ideal for mappings.

Also the following will show the information box until the screen needs to be refreshed (as opposed to being hidden as soon as any key is hit):

:info test; on-key 'echo -debug %val{key}'

lenormf avatar Nov 05 '19 21:11 lenormf

Rebased on master.

lenormf avatar Sep 09 '21 05:09 lenormf