mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.94k stars 716 forks source link

Inactive cursor when application not active #3652

Open pickfire opened 4 years ago

pickfire commented 4 years ago

Feature

Switch the block cursor to empty block cursor when application is inactive like what would be seen in terminal emulators usually, vi, vim and neovim does that too. Sometimes I may be confused if I am still using kakoune since the cursor is still showing block cursor since I am used to seeing the cursor to determine which terminal I am in.

Usecase

Let the user clearly identify which application is in, kakoune is the only one that is special to not follow this in my knowledge. Probably related to rendering method.

Screwtapello commented 4 years ago

This is basically the same as the common request to render the cursor as a vertical bar in insert mode (#1385, #2194).

In short: terminals maintain a particular character cell as "the cursor", and tend to support various custom graphical effects for highlighting its position, such as drawing an underline, or a bar to the left, or a rectangle around it, in a custom colour that's none of the standard terminal colours. Because Kakoune supports multiple selections, it cannot use the (single) terminal cursor to represent its own cursor, and so it has to draw cursors itself. Because Kakoune draws cursors itself, pretty much all it can do is change the foreground and background colours, no extra decorations or custom colours.

That said, since Kakoune has FocusIn and FocusOut hooks, it would be possible to change the cursor colours (or any other part of the Kakoune window) to indicate which window has focus. If you're already using ModeChange hooks to change the cursor colour to indicate normal/insert mode, adding an orthogonal indicator could get messy, but it should be possible.

pickfire commented 4 years ago

@Screwtapello Is there any reasons why multiple cursors support isn't being proposed in https://gitlab.freedesktop.org/terminal-wg/specifications/?

Screwtapello commented 4 years ago

The usual network-effect reasons, I guess: terminals don't want to implement a feature unless apps want to use it; apps won't bother with a feature unless it's widely supported in terminals. In addition, Kakoune's selections are minimum-one-character-long because Kakoune can only represent them by setting a character's background colour. If Kakoune could represent selections with real terminal cursors, that restriction would no longer be present, but changing the selection model to allow zero-length selections would have a lot of implications throughout Kakoune's design.

There's another Kakoune-inspired editor called breeze that is designed around zero-length selections, but it's not nearly as mature as Kakoune and I think the author's busy with other things these days. Still, it might be interesting just as another point in the design space.

pickfire commented 4 years ago

But at the end, there could still only be one main cursor, why doesn't kakoune just draw the normal cursor (or with I-shape on insert) for the main cursor while a block cursor grayed out for the other cursors?

I saw breeze back then, looks interesting, I wish I could help it to improve on some parts I don't quite like with kakoune (indentation, wrapping, highlighting, insert mode readline keys).

Screwtapello commented 4 years ago

A comment on #1393 mentions "we have experimented with visible ncurses cursor some time ago, and it broke many terminals", but that was before I was following Kakoune closely, so I don't know what the breakage was.

lenormf commented 4 years ago

I think the issues you're referring to are #1318 #1392 #1524

EpocSquadron commented 3 years ago

@pickfire there is now active-window.kak that changes highlight colors based on what window is active which might fit your needs.

casonadams commented 3 years ago

What if we set the cursor to be an _? It isn't quite a | but is an indicator. Have a look at the plugin I created insert-indicator