Blinking statusline when selections are out of current view

Hi guys,

I have the following use case:

  • I often use multiple selections to do some editing
  • sometimes these selections are outside of the view
  • after editing I forget from time to time to dismiss all selections but the main selection.
  • When I edit I mess up parts of my file which are outside of the current view

To fix this I would like to have the part of the statusline which show the selection count blinking whenever I have selections out of the current view.

I think I remember some thread some time ago detecting when there are selections out of view (can’t find it at the moment) but I don’t know if it possible (and how) to make parts of the statusline blinking.

Thanks in advance for any help

Terminals generally don’t support blinking these days, and Kakoune doesn’t support doing things on a timer, so I don’t think you can do things exactly the way you propose.

I’ve been bitten by this too; I worked on a plugin that added a scrollbar to the left-hand side of the screen, and drew little dots on the scrollbar to represent the number of cursors in each part of the document. Unfortunately it’s stopped working with recent changes to Kakoune and I haven’t gotten around to getting it working again.

1 Like

Thank you very much.

I will definitely look into this plugin and see if I am able to fix anything.

Not being able to blink is really unfortunate, because everything static seems not to catch my attention when I am concentrating (like focusing on coding)

A different direction, but kakoune-focus might be useful: it uses the replace-ranges highlighter to hide lines without selections.

1 Like

I’ve lost track of multiple selections too. If blinking is not possible then how about a yellow highlight on the selection count sels (position) area of the status line when selections are out of view? I’ve also lost track of multiple selections even when they are all visible so welcome any user interface thoughts on that scenario.

1 Like

This is a really useful plugin and I am already experimenting with it. But the use case where I run into problems is where I worked with multiple selections and forgot to dismiss them after I am done. With the kakoune-focus plugin I feel like I have to decide to use this kind of “folding” before I start.

Having a high and unusual contrast in the statusline seems like being worth a try. Do you know how to do that?

Till know git (often in connection with automatically running unit test) helps me finding the places of the other cursors and fixing the mistakes relatively fast. However having something that warns me before I mess up would be nicer.

I’ve been able to build the debug version and run it under the GNU debugger but I’m not familiar with either C++ or the Kakoune code base so I’ve only been able to get as far as the main Kakoune program loop and haven’t been able to find the specific source code related to my issues with kakoune command line history behaviour. Would appreciate a quick overview of how you are using the unit test cases if you get a chance.

Yeah non-visible cursor can be mentally taxing.
There used to be a native scrollbar branch but it was never merged.
Today this information is already in the statusline (it says something like 3 sels (2) in the default modeline). Having to look over there can make it harder to maintain focus.
I think I’d like to have this information somewhere close to the main selection’s cursor.
Maybe some arrows that indicate where any non-visible selections are. Like info -style above but put it on whitespace to not overlap with text.

1 Like

Sorry my answer was misleading. I did not mean the unit tests of kakoune but the unit tests of the projects I am working with.

Normally I set up a script that automatically runs my unit tests as soon as I save a file. After that it goes like this:

  • I use multiple cursor to edit something
  • Save → unit test run → ok
  • I forget to dismiss them because some of them are not in the view anymore
  • I edit some more and mess everything up
  • Save → unit test run → error!
  • git diff
  • I realize my error and fix the mistakes

It is just a workaround and not something built in to kakoune. And it works only if you commit quite often (but thats usefull anyway)

Or different colours for a single cursor, multiple cursors all visible and multiples cursor with some not visible. Or retain the white cursor but change it’s shape. If there are cursors off the screen to the bottom it could be a triangle pointing down, if there are cursors off the screen to the top it could be a triangle pointing up. Multiple cursors all visible could be a circle or asterisk (since it stands for multiple characters in a regex). I offer these suggestions in the hope of inspiring someone with more graphical talents…

1 Like
set-face global HiddenSelection 'white,bright-red+F'

declare-option range-specs hidden_selections_indicator_ranges
declare-option str hidden_selections_above_and_below_indicator '●'
declare-option str hidden_selections_above_indicator '▲'
declare-option str hidden_selections_below_indicator '▼'

# add-highlighter shared/hidden_selections_indicator replace-ranges hidden_selections_indicator_ranges

define-command update_hidden_selections_indicator_ranges %{
  set-option window hidden_selections_indicator_ranges %val{timestamp}

  try %{
    # Determine multiple selections.
    execute-keys -draft '<a-,>'

    try %{
      # Determine hidden selections above and below.
      execute-keys -draft -save-regs '^tb' 'Zgt"tZgbx;"bZe"tzb"tz"b<a-z>u<a-z>a<a-,>'
      set-option -add window hidden_selections_indicator_ranges "%val{cursor_line}.%val{cursor_char_column}+1|{HiddenSelection}%opt{hidden_selections_above_and_below_indicator}"
    } catch %{
      # Determine hidden selections above.
      execute-keys -draft -save-regs '^t' 'Zgt"tZb"tzGe<a-z>a<a-,>'
      set-option -add window hidden_selections_indicator_ranges "%val{cursor_line}.%val{cursor_char_column}+1|{HiddenSelection}%opt{hidden_selections_above_indicator}"
    } catch %{
      # Determine hidden selections below.
      execute-keys -draft -save-regs '^b' 'Zgbx;"bZe"bzGg<a-z>a<a-,>'
      set-option -add window hidden_selections_indicator_ranges "%val{cursor_line}.%val{cursor_char_column}+1|{HiddenSelection}%opt{hidden_selections_below_indicator}"
    } catch %{

hook global NormalIdle '' update_hidden_selections_indicator_ranges
hook global InsertIdle '' update_hidden_selections_indicator_ranges
hook global PromptIdle '' update_hidden_selections_indicator_ranges

# add-highlighter global/hidden_selections_indicator ref hidden_selections_indicator_ranges
add-highlighter global/hidden_selections_indicator replace-ranges hidden_selections_indicator_ranges

I’d like to have sels left in the status line alongside other indicators, like in Helix.

left = ["mode", "selections", "read-only-indicator", "file-modification-indicator"]
center = []
right = []

TIL that the modeline is mirrored in the terminal title, which is sometimes easier to spot than the modeline on the bottom left. We could change the modeline to include the number of hidden selections if nonzero