Skip to content

Make certain that the cursor can invert/not-occlude/display the character under it #9610

Closed

Description

I've been using WSL for a while and it's been great, but using nvim with this issue still pending is at times unusable. Other terminals are not having this issue (see ConEmu or Hyper for example). I hope this issue gets re-opened.

Originally posted by Dimitar Dimitrov (@n1ghtmare) in #1203 (comment)

I'm with Dimitar Dimitrov (@n1ghtmare) on this one. Most syntax highlighting colors in Vim have a wide array of colors that very much clash with the cursor color when the cursor color isn't able to be swapped to a contrasted color dynamically. This has been demonstrated in the few screenshots I uploaded before. It affects everyone using terminal Vim or another terminal based text editor.

I know pianocomposer321 said to pick a better color for the cursor but this doesn't make a difference in the end. If he adjusted his screenshot to be over a comment instead of the keyword then the comment's character under the cursor would be invisible. Also in his current screenshot the contrast is very low, it would certainly not be good enough for a video recording or giving a talk.

As good as the MS terminal is, I still tend to use wsltty (which dynamically sets its cursor color based on contrast calculations) in my day to day because having a block cursor in terminal Vim is much better than the vintage cursor in the MS terminal. Not just from a legibility POV, but it allows you to configure Vim so that your cursor shape changes from the block cursor to a line cursor depending on if you're in normal or insert mode.

Originally posted by Nick Janetakis (@nickjj) in #1203 (comment)

Subscribers, thumbs-uppers from that comment: krage, Jay Freeman (saurik) (@saurik), krage

Activity

  1. ghost added
    Needs-Triage
    on Mar 25, 2021
  2. ghost added
    Needs-Tag-Fix
    on Mar 25, 2021
  3. skyline75489 commented on Mar 25, 2021

    @skyline75489
    Collaborator

    Is this blocked by #6193 or other issues? Or we can just implement the algorithm for calculating the contrasted color and call it a day

  4. zadjii-msft commented on Mar 25, 2021

    @zadjii-msft
    Member

    I KNEW THERE WAS AN EXISTING ISSUE!

    Part of the trick here is that when the Renderer is drawing runs of text, it doesn't know where the cursor is. So it needs to be able to split the run with the cursor in it, so it can draw {text left of the cursor, text where the cursor is, text to the right of the cursor }.

    Presumably, if there's a way of doing it without doing all the work in #6193, that'd be cool. I had all these ideas before in #6151 for different ways of specifying how the text at the cursor should look. Something like "cursorTextColor": null|"textForeground"|"#rrggbb".

  5. added
    Area-Rendering
    Issue-Feature
    Product-Terminal
    and removed
    Needs-Triage
    on Mar 25, 2021
  6. ghost removed
    Needs-Tag-Fix
    on Mar 25, 2021
  7. DHowett commented on Mar 26, 2021

    @DHowett
    MemberAuthor

    The thing I was toying with--which initially made me think that this would be easy--was drawing a D2D "fill effect" (that is: a command buffer that produces a flood fill) through the image/effect drawing pipeline with the XOR composition mode. It was promising, but it only worked where we weren't already drawing a background. Everything goes pear-shaped when you are drawing a background color. 😄

  8. DHowett commented on Mar 26, 2021

    @DHowett
    MemberAuthor

    However, it looks like we can use the 2-pass cursor renderer Mike Griese (@zadjii-msft) wrote to backplate the color for a destination-inversion cursor.

  9. DHowett commented on Mar 26, 2021

    @DHowett
    MemberAuthor

    it puts the cursor on its skin

  10. nickjj commented on Mar 27, 2021

    @nickjj

    Looks like a really good start, nice work. Could this be something that gets backported into the current stable release as a hotfix once you're happy with its performance and stability? It feels like such a huge feature that it transforms the entire experience for anyone who might be using Vim.

  11. 57 remaining items

  12. lhecker commented on May 4, 2023

    @lhecker
    Member

    Since it's easier to address, as you say, why not implement that before the automated inversion solutions?

    The "automated" mode is ~4 lines of code and took me <5min to write and test, whereas the other issues/feature-requests require a lot more work. Given that I'm technically already 110% booked out with work for months on end, I think you can see why I've picked the easy option for now. 🥲

    I hope to soon use block cursor like god intended (I'm currently using vintage shape because of this indistinguishable-character issue).

    You could try god's intended cursors right now, if you're curious. 😏
    Here is a preview build based on that PR. I put it on my own host for convenience (and because the file will automatically expire in a week that way), but it's properly built and digitally signed by Microsoft. Please let me know if you find any issues with the way the cursors work now!

  13. 3N4N commented on May 5, 2023

    @3N4N

    I hope to soon use block cursor like god intended (I'm currently using vintage shape because of this indistinguishable-character issue).

    You could try god's intended cursors right now, if you're curious. 😏 Here is a preview build based on that PR.

    Awesome! Been using for a few hours. Works great! Thanks a bunch.

  14. avih commented on May 6, 2023

    @avih

    IMHO, if you insist on choosing the FG color yourself and not letting the user specify it, then just pick either black or white - whichever has the better contrast to the chosen cursor BG color.

    IMO it would pretty much gurante to look better than any attempt to preserve the underlaying FG color but still modifying it so that it has some contrast to the BG.

    Just see how many failed atempts there were at that, to realise that it's not as simple as you think to do what the user prefer automatically.

  15. nickjj commented on May 6, 2023

    @nickjj

    I think if we stick with setting it manually then we're not going to address the root issue where characters are invisible based on syntax highlighting in terminal based editors such as Vim. You're going to have a wide range of dark and light text based on any variant of color themes.

  16. added a commit that references this issue on May 8, 2023
    4dd9493
  17. habamax commented on May 8, 2023

    @habamax

    I think if we stick with setting it manually then we're not going to address the root issue where characters are invisible based on syntax highlighting in terminal based editors such as Vim. You're going to have a wide range of dark and light text based on any variant of color themes.

    I have used vim for a long time in different terminals that allow setting bg and fg for a cursor -- never had an issue with syntax highlighting and cursor. If your terminal background is black, set cursor colors to white and black, do the opposite if terminal background is light/white. It always worked, it would have worked in windows terminal too.

    But anyway, if that new implementation would let us distinguish what is under cursor, I am all for it.

  18. nickjj commented on May 9, 2023

    @nickjj

    I have used vim for a long time in different terminals that allow setting bg and fg for a cursor -- never had an issue with syntax highlighting and cursor.

    Maxim Kim (@habamax) This issue has multiple screenshots showing how it would be an issue with a statically configured cursor color.

    Here's a screenshot you posted a while back:
    image

    • If you configured a static black cursor, reading your comments would be really hard because it's medium grey
    • If you configured a static white cursor, reading your function definitions would be really hard because it's almost white
    • Your current set up with a purple cursor on medium grey is also very hard to read

    Your screenshot is also a near-best case scenario because you have pretty bright colors and there's only a few colors shown at once.

  19. habamax commented on May 9, 2023

    @habamax

    Nick Janetakis (@nickjj) it is about other terminals that allow setup of cursor background AND FOREGROUND colors. Like gnome-terminal, for example:
    image

  20. added a commit that references this issue on May 16, 2023
    4977fc9
  21. gaoqiangks commented on Jun 24, 2023

    @gaoqiangks

    So, what's the solution? Many issues are closed but I still cann't find a solution.

  22. lhecker commented on Jun 24, 2023

    @lhecker
    Member

    Did you try Windows Terminal Preview 1.18 yet? If that doesn’t work for you it’d be great if you could open a new issue with a screenshot showing the problem and I‘ll try to fix it ASAP. 🙂

    If you’re asking about setting individual foreground and background colors for the cursor, I don’t think we have an issue tracking specifically that yet, but I‘ve already made it my goal to implement that for 1.19 anyways.

  23. gaoqiangks commented on Jun 25, 2023

    @gaoqiangks

    WT Preview 1.18 is much better. Thank you!

  24. weibeld commented on Jul 26, 2023

    @weibeld

    This is now being discusses in #15766.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-RenderingIn-PRIssue-FeatureProduct-Terminal

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions