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

Add option to change cursor shape on mode change #323

Closed
sudormrfbin opened this issue Jun 20, 2021 · 16 comments · Fixed by #1154
Closed

Add option to change cursor shape on mode change #323

sudormrfbin opened this issue Jun 20, 2021 · 16 comments · Fixed by #1154
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@sudormrfbin
Copy link
Member

An option similar to neovim's 'guicursor' is something I miss, which can for example change the cursor to bar for insert and back to block on normal and selection mode.

@sudormrfbin sudormrfbin added the C-bug Category: This is a bug label Jun 20, 2021
@archseer
Copy link
Member

This is a terminal limitation: it only has one cursor so we can only change shape of the primary selection. I had that initially but removed it for the sake of consistency.

@sudormrfbin
Copy link
Member Author

It's a very easy way to be aware of the mode you're in, and we could mention in the docs that only the primary selection's cursor will change. Also a question: will the primary cursor always be visible in the screen, even with multiple selections ?

@teenjuna
Copy link
Contributor

I agree with @sudormrfbin. This is actually a very useful feature that I also miss. However, perhaps we might think of another way to help the user quickly understand in which mode he currently is without looking on the bottom left or trying to type something. Even changing the color of the mode's indicator will enable the user to use his peripheral vision and understand the mode faster.

@pickfire
Copy link
Contributor

pickfire commented Jun 21, 2021

I tried this, currently it's broken. Although it did change the style, it breaks IME input, try typing in some japanese text then you know what I am saying, but it works fine for ascii. Maybe the IME thing could be another bug that we need to solve.

@DrZingo
Copy link
Contributor

DrZingo commented Jun 22, 2021

I have different shapes and different color on my cursor in vim. blue block = normal, green bar = insert, red underscore = replace. But I find it more useful to have different colors in the statusbar for each mode.
image
image
image

@archseer archseer added the A-helix-term Area: Helix term improvements label Jun 23, 2021
@pickfire
Copy link
Contributor

pickfire commented Jun 25, 2021

I tested again, bar cursor seemed to work with IME. But the color is a bit weird, maybe need to have different theme. But not working well with multiple cursors, only main cursor is bar.

@sudormrfbin
Copy link
Member Author

I'm going to take a stab at this and see how it turns out.

@pickfire
Copy link
Contributor

pickfire commented Jun 26, 2021

@sudormrfbin I did test this locally and works. But I think you might want to change the theming along with this, it looks ugly if you only change the cursor shape based on mode. I think we should have sort of a new mode for replace so we can use the _ cursor.

One more issue I have when I tested it out is only the main cursor will change shape but other cursors is the same block shape, which looks inconsistent and made it ugly. Not sure how to fix it.

@sudormrfbin
Copy link
Member Author

@pickfire Yeah the theming looks weird with it so I made some changes (in the rendering code itself):

command

  • Selections are not rendered when in insert mode - they are shown again after exiting insert mode (IMO this should've been the default, selections in insert mode look distracting)
  • Cursor styling is removed for the primary cursor only in insert mode when it's bar (otherwise a bg = "#ffffff" will look like a block cursor and bar cursor combined)

One more issue I have when I tested it out is only the main cursor will change shape but other cursors is the same block shape, which looks inconsistent and made it ugly. Not sure how to fix it.

We can't do anything here since it's a limitation of the terminal itself, so the best thing we can try is to change the primary cursor to a bar and make the others look like a block cursor.

@pickfire
Copy link
Contributor

I wonder if there's sort of hack we can do to display a bar. Maybe we just replace the last character with a bar for all other cursors?

@sudormrfbin
Copy link
Member Author

Replacing seems a bit too drastic and hacky, and there were some discussions (that were abandoned) in kovidgoyal/kitty#720 and mawww/kakoune#2194 regarding an xterm extension for supporting multiple cursors.

@pickfire
Copy link
Contributor

pickfire commented Jun 26, 2021

i wonder @Kethku would be interested in this. neovide cursors are cool, then we have multiple animated cursors, how nice.

@archseer
Copy link
Member

One more issue I have when I tested it out is only the main cursor will change shape but other cursors is the same block shape, which looks inconsistent and made it ugly. Not sure how to fix it.

This was discussed earlier in this thread, it's a terminal limitation sadly. I had the shape changes built in but later removed them.

@bestouff
Copy link

Really in nvim the three shapes of cursor to tell which mode is the current one without having to look at the status bar (and find the cursor position back, which is uneasy on big terminals) are very ergonomic. It's a big loss.

sudormrfbin added a commit to sudormrfbin/helix that referenced this issue Nov 24, 2021
Fixes helix-editor#323. Due to terminal limitations we can only
change the shape of the primary cursor.
sudormrfbin added a commit to sudormrfbin/helix that referenced this issue Nov 24, 2021
Fixes helix-editor#323. Due to terminal limitations we can only
change the shape of the primary cursor.
@bestouff
Copy link

Moreover: the terminal often changes the cursor on focus entering/exiting (hover) the terminal. One more ergonomic feature lost with "hand-made" cursors.
Maybe do like in (n)vim in ctrl-V mode, where multiple lines are selected but the terminal cursor is still part of one line:
select

@sudormrfbin
Copy link
Member Author

#1154 uses the real terminal cursor as the primary cursor and draws the other cursors, so that problem would be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants