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

visibility issue with non-blinking block cursor #1101

Closed
rovf opened this issue Apr 23, 2021 · 21 comments
Closed

visibility issue with non-blinking block cursor #1101

rovf opened this issue Apr 23, 2021 · 21 comments

Comments

@rovf
Copy link

rovf commented Apr 23, 2021

A non-blinking block cursor completely hides the character below. This is a nuisance when doing inline-editing of a command or using a texteditor: The character below the cursore, i.e. the editing place, becomes invisible.

It would be great if something could be done to make the character under a non-blinking block cursor somehow visible. Three possibilities come to my mind, but I can't tell which one can possibly be implemented:

  1. Make the block cursor transparent, if blinking is off. Perhaps a transparency level could be made configurable.
  2. Invent a new cursor type "inverting block cursor", which shows the character below, but with foreground colour and cursor colour be exchanged.
  3. Invent a new blink-setting: CursorBlinks=onSpace .... Blinking is on only if the cursor is on a white space. A Block cursor with this setting would be represented as a massive block when we type a command, but turn into a blinking cursor as soon as we start command line editing.
@mintty
Copy link
Owner

mintty commented Apr 23, 2021

I don't reproduce this. For me, the character under the cursor is visible. What are your relevant settings?

@rovf
Copy link
Author

rovf commented Apr 23, 2021 via email

@mintty
Copy link
Owner

mintty commented Apr 23, 2021

The cursor position character is clearly visible, please test on the command line.
Maybe your editor does not use the terminal cursor but display one itself?

@rovf
Copy link
Author

rovf commented Apr 26, 2021

Same effect on the command line. See the enclosed screenshot. The cursor is on top of the ls command in the command line, but the letter s is not visible.

capture_20210426_101236

@mintty
Copy link
Owner

mintty commented Apr 26, 2021

That's not your config file above, right?
For me, it looks like this:
grafik
Any dynamic colour settings from your shell? Which shell do you use?

@rovf
Copy link
Author

rovf commented Apr 26, 2021

Nearly. The colours are a bit different. The other settings are the same.

I also suspected a shell issue. The shell here is zsh, and I use the syntax colouring package from zsh, which colours the commanline. However, I tried the same in a bash subshell, where I don't have such modifications. The effect is the same. Would you like a screenshot of this too?

@rovf
Copy link
Author

rovf commented Apr 26, 2021

OK, I now see, why you can't reproduce it. It was my mistake when I wrote

CursorType=block

Actually, the offending setting is

CursorType=line

The cursor does LOOK like a block cursore with this setting, and that's why I mistakingly assumed I had the block cursor turned on. Actually, the cursor setting in my scripts come via the -o option, not from the config file. As a reproducible example, I have included a configuration file, and if I put the file into my theme directory and start mintty with the command

mintty -o ThemeFile=cfg.txt -o CursorType=line -o CursorBlinks=no -o OpaqueWhenFocused=yes -o Transparency=off -o LigaturesSupport=1 -o PgUpDnScroll=yes

I can see the effect described in this issue. Actually, the line cursor looks like a somewhat smaller block rather than a vertical line. Perhaps the problem is the width of the line cursor in pixels? Can this be adjusted by some setting?

cfg.txt

@mintty
Copy link
Owner

mintty commented Apr 26, 2021

Please try reset; cat then enter ls <Backspace>

@rovf
Copy link
Author

rovf commented Apr 27, 2021

A backspace would erase the previous character. We want to have the cursor on top of it. Hence would be the appropriate key to test, I think.

In the enclosed screenshot, I did as you said, but pressed twice after ls. Hence the cursor is on top of the "l", but we can see only the "s". The reset did not make any visible effect.

capture_20210427_113629

@mintty
Copy link
Owner

mintty commented Apr 27, 2021

Colours are different again but that shouldn't matter. Last idea I have for now: mintty /bin/cat.

@rovf
Copy link
Author

rovf commented Apr 28, 2021

Well, I actually tried for the safe side a

mintty -o ThemeFile=cfg.txt -o CursorType=line -o CursorBlinks=no /bin/cat

(where cfg.txt is the config file I had uploaded here earlier), and you can see the result in the screenshot.

Could you post a screenshot how the effect of the very same command looks when you are doing it?

capture_20210428_081337

@mintty
Copy link
Owner

mintty commented Apr 28, 2021

The config is actually merged with your default config if you have one. Anyway, here is my result:
grafik

@rovf
Copy link
Author

rovf commented Apr 28, 2021

Now we have something: I guess your line cursor is opaque too, like mine. It's just that yours is so thin that it fits between two characters, while mine is several pixels wide and covers a good part of the character. Now it's really a Windows-question: Can Windows be told to make a line cursor inverting, like a block cursor, or is this simply not possible?

@mintty
Copy link
Owner

mintty commented Apr 28, 2021

Well, then it's actually not a line cursor anymore (by Windows settings), so why don't you just use a mintty block cursor?

@mintty
Copy link
Owner

mintty commented Apr 28, 2021

I don't know why your Windows system parameters got so misconfigured about caret width but I've commit a change to limit the line cursor width like that of underlines, strikeouts etc.

@rovf
Copy link
Author

rovf commented Apr 28, 2021

Not sure that this has to do with Windows system parameters. If this were the case, the line cursor would look like this everywhere. Checking a few applications, I found that Microsoft Windows indeed has the same line cursor shape like I see on mintty; the NVIM text editor, the Firefox browser and the communication platform Slack show a thin line cursor, exact like in your screenshot. The Windows command console window has a line cursor which is a little bit wider, but not as wide as the one in mintty (maybe 3 pixels wide). The PsPad text editor shows a line cursor which has the same width than a block cursor, but occupies the lower half of the character. From this, I have the impression that each application defines its own shape.

@rovf
Copy link
Author

rovf commented Apr 28, 2021

Actually, my favorite line cursor would be similar to what command console (ConEmu) is using (see screenshot): Not so thin that the line is hard to see, but thick enough that it does not obscure the character.
capture_20210428_162916

@mintty
Copy link
Owner

mintty commented Apr 28, 2021

I think many applications define their own shape. For the line cursor, however, mintty uses:
SystemParametersInfo(SPI_GETCARETWIDTH, 0, &caret_width, 0);
to retrieve a width, which then used to be limited by the cell width, now by the mintty-calculated line width.
It would also be possible to use an external image or icon file for the cursor (this is actually just possible with 3.5.0 for the mouse pointer, not the text cursor however), but someone would have to implement that.

@rovf
Copy link
Author

rovf commented Apr 29, 2021

I see. So an application can define the caret width, but there is also a system-wide default value for this. This would explain the differences I see between the individual applications.

Would it be much work to have the caret width of the line cursor being configurable in mintty, and use the system default only if there is no configuration specified?

@mintty
Copy link
Owner

mintty commented Apr 29, 2021

No, but without additional implementation effort the widened caret will overlap the character at the cursor position, just as you encountered with a full-width caret.
Note that there is already a dynamic escape sequence to change the height of the underscore cursor (https://github.com/mintty/mintty/wiki/CtrlSeqs#cursor-style, second table). An option to consider would be to apply that setting also to the line cursor.

@mintty
Copy link
Owner

mintty commented Sep 3, 2021

Released 3.5.1.

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

2 participants