Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work with kitty on a xterm protocol extension to use terminal's *native* multiple cursors (to enable different cursor shapes and blinking) #2194

Closed
maximbaz opened this issue Jul 7, 2018 · 6 comments

Comments

@maximbaz
Copy link
Contributor

maximbaz commented Jul 7, 2018

I want to see a beam cursor in insert mode and an underline cursor in replace mode, and a hollow block cursor when terminal is currently unfocused.

Kitty's author is open to work on a new xterm protocol extension to implement native multiple cursors support in terminals. He is looking for collaboration with kakoune developers in order to design the new protocol that can truly fulfill the needs of the editor.

Please join the discussion here: kovidgoyal/kitty#720


Old ticket description, no longer relevant

First of all, I've seen #1385, the argument "there is always a selection, so cursor should always be block" is simply wrong — kakoune knows when I'm in normal, insert and replace mode, it should just render different cursor shapes at corresponding points of time.

I've also seen #1393, and an argument:

We have experimented with visible ncurses cursor some time ago, and it broke many terminals. Kakoune will keep full control of cursor display for the time being.

Sure, let kakoune control the cursor, but teach it to use different shapes anyway. Do you need Unicode characters to use as cursors? Here you go: and . Since current cursor is probably , we can use this one for hollow cursor (when kak is unfocused): .

P.S. If I could get a "hollow block" cursor when the terminal is unfocused, I would be even happier, but I the beam and underline cursors should be the priority.

@ekie
Copy link
Contributor

ekie commented Jul 11, 2018

i am still using a patched kak to support this. if there is a interest i can work on a new pull request.

@maximbaz
Copy link
Contributor Author

Awesome, I'm interested, is there a way for me to try?

Could you also describe a bit your patch, does it make all cursors change form or only primary, and does it draw cursors as Unicode characters or exposes the ncurses cursor (which seems to be a no-go from the quote I posted in the first message)?

Having all cursors change form would be ideal of course 🙂

@net
Copy link
Contributor

net commented Jul 11, 2018

Unicode cursors won't help, as they'd overwrite the existing character in their cell.

That there is always a selection of at least one char has little to do with kakoune knowing which mode it's in. Even in insert mode there is a selection, and the cursor is part of the selection.

There are in my mind two inconsistencies that occur during insert mode:

  1. When appending to a selection, the selection and cursor advance to the character after the selection. This is not only visual: <a-;>y will yank the extended selection.

  2. When prepending to a selection whose anchor is to the left and cursor to the right, the cursor jumps to the left side of the selection, and remains there after existing. The same occurs when appending to a selection whose cursor is to the left.

I suppose this is kakoune's intended behavior: selections always include cursors, and text is always inserted before cursors. I'm not, however, aware of any pragmatic benefits.

If selections were to be left unmodified when prepending and appending, the problem is then communicating during insert mode where text will be inserted. One solution is to render [prepend] or [append] after insert in the mode line. Another solution is to render a vertical bar cursor at the insertion point in supported terminals.

@maximbaz
Copy link
Contributor Author

I've started a discussion in kitty terminal emulator about extending xterm protocol for native terminal support for multiple cursors. The author is not opposed to the idea, and actually is looking for collaboration with kakoune developers in order to properly design this feature that can actually meet the needs of the editor.

Everyone who is interested in joining the discussion, please do!

kovidgoyal/kitty#720

@maximbaz
Copy link
Contributor Author

Unicode cursors won't help, as they'd overwrite the existing character in their cell.

Yeah, someone on IRC explained this to me already... I was under the impression that we can draw one Unicode character on top of another (so that we can draw a cursor char and then a letter on top of it in reversed color), but it's not how this works, we can only put one character in a cell and modify its background and foreground color (so currently the "cursor" is just a white background color).

That's why I created kovidgoyal/kitty#720, I think this should be solved on the terminal level, and not by doing magic with background colors. The native terminal cursor has many capabilities that we can never replicate ourselves, such as cursor shape or blinking. I really hope we get the discussion in kovidgoyal/kitty#720 rolling and implement this. Kitty's protocol extensions have already proven to be successful, e.g. image protocol is being integrated in ranger so that it can draw pictures without relying on w3m hacks.

That there is always a selection of at least one char has little to do with kakoune knowing which mode it's in. Even in insert mode there is a selection, and the cursor is part of the selection.

Exactly my point, I think we agree on this. The fact that kakoune always has some selection shouldn't stop us from having different cursor shapes when a user is in insert or replace more, the cursor shape is there to help understand what a next keypress will do to the buffer, just like the indicator in modeline.

There are in my mind two inconsistencies that occur during insert mode

I think this deserves a ticket of its own, here I have a very specific wish to have kakoune support native multiple cursors with all of it's features, such as shapes and blinking.

@maximbaz maximbaz changed the title Use different cursor shapes in normal, insert and replace modes Work with kitty on a xterm protocol extension to use terminal's *native* multiple cursors (to enable different cursor shapes and blinking) Jul 12, 2018
@maximbaz
Copy link
Contributor Author

Closing for now as sadly no terminal is currently wishing to implement native multiple cursors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants