Open vefatica opened 3 years ago
@DHowett had a horrible idea in chat
if we did that, we could also add a subparameter to it
\e[7:25 q
sets vintage at 25% and therefore communicate the cursor state from conpty to terminal . . .
which is actually an amazing idea IMO. We don't currently support subparams in sequences, but we're not too far away from that.
I'm gonna summon @j4james to sanity check that using these sequences like this don't have an existing conflict. We might need to pick something silly like \e[9001:25 q
to avoid any existing conflicts, but I really like this idea.
I would generally not encourage the use of sub parameters, because they're non-standard, and tend to break parsers in unpredictable ways. If you were an app developer that wanted to use this option, you'd then have to detect the terminal type to determine whether it was safe to send the sequence or not.
So my preference would probably be to invent a completely new sequence for the size, if you really think you need it - something that would generally be treated as a no-op by terminals that don't support it (you can't always guarantee that, but the idea is to minimize the damage you're doing).
I should also add that I thought someone already had a sequence for this. I had a brief look yesterday when the issue was first raised and didn't find anything, but it's probably worth doing a bit more research before reinventing something that may already exist.
I just wanted to get back to my default (blinking "vintage"). In '\e[N q', N = 1/2 gives blink/non-blink block cursor, N = 3/4 the same for underscore, N = 5/6 the same for vertical bar. Since n = 8 gives the "vintage" size and shape, non-blinking, it seems reasonable that 7 give blinking "vintage" (it doesn't).
I don't know what your restrictions are. Returning to the default should be straightforward (maybe even '\e[0 q' which now duplicates '\e[1 q').
Where can I find the handling of control sequences in the code?
@vefatica you may be interested in #7379
Since n = 8 gives the "vintage" size and shape, non-blinking, it seems reasonable that 7 give blinking "vintage" (it doesn't).
Just to be clear, we don't technically support parameter 8 as "vintage". Every number that isn't a recognised parameter just ends up as that by default. Personally I think that's a bug - if it's a not a supported parameter we should be ignoring it. If we want to use 7/8 as blinking and non-blinking vintage then those should be explicitly supported parameters.
Yes, I figured parameters greater than 6 weren't supported. If unknown parameters are not ignored, and are going to lead to the default, it should respect whether the default is blinking or not (or at least preserve the current blink state).
As for supported parameters, "vintage" (blinking/non-blinking) really should be among them.
We didn't invent this sequence - it's just a standard that we are a following. Parameters 0 to 4 were originally defined by DEC, and 5 and 6 were later added by XTerm, and have since become a de facto standard. "Vintage" isn't a style that anyone else supports, so that would require a proprietary extension, which is not something that we want to rush into.
You have (I guess) respected the "de facto standard". What's the problem with augmenting it? [I'm serious.] I wonder if XTerm agonized over adding 5 and 6?
We have a specific resistance to extending any existing protocols like this. We'd much rather entirely invent our own sequence to use, that isn't even sorta used by anyone else, rather than extend an existing one.
I agree with @j4james's assessment - using \e[8 q
to restore to vintage
is a bug, that we should probably fix, as well as introduce a vintage cursor shape sequence.
FWIW, I found the escape sequence I was thinking of. It's a private CSI that was used by SCO Unixware:
ESC[= s ; e C
Sets cursor parameters (where s is the starting and e is the ending scanlines of the cursor).
Not exactly what we want, because I think we can only set the height rather than the scanline range (at least in conhost). Also there's the question of how many scanlines there are in a character (you assumedly wouldn't want it to depend on font size).
That said, it's worth noting that Kermit implemented this (when in "ANSI" mode) by calculating the requested height (i.e. e - s
), and then mapping certain height ranges to cursor sizes.
Assumedly this sequence would also function as a proxy for selecting the "vintage" cursor. And choosing whether the cursor should be blinking or not is already covered by the existing cursor blink mode (private mode 12).
I'm not sure about this, but it's at least something to consider.
As I mentioned at https://unix.stackexchange.com/a/597558/5132 , I've extended this to support 4 more shapes, myself. They are an outline box, a star, underline+overline, and a reversed "L" shape, inspired by some literature on real terminals. So if you do ever extend DECSCUSR, I'd appreciate it if we were compatible.
Thanks for the info - that's useful to know. We do have an "Empty Box" cursor style, which sounds the same as your "outline box", so that's something I think we could easily support if we were going to extend DECSCUSR. Am I right in assuming that 7 and 8 are the blinking and non-blinking versions of the outline box in your implementation?
What about these? (from https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) They work in the Windows console.
And, after settings are reloaded, the cursor shape is restored but the blink state is not restored. This might be related to #7571
Maybe there should be a "cursorBlink" (true/false) profile setting?
Moving to 2.0 b/c of #8560
From #16785:
The blocking issue for this is https://github.com/microsoft/terminal/issues/7382. We need to pass on the request for the overwrite-mode cursor via conpty, which requires an equivalent escape sequence for the half-height block cursor, but there isn't a standard way to achieve that.
It's also worth noting that this particular cursor change is achieved with an internal SetCursorDBMode call, which toggles the "double cursor" mode, independent of the actual cursor size - it's not using the public SetConsoleCursorInfo API. So that's something we need to bear in mind if we want to get this working in conpty.
I've been meaning to comment here that there's another escape sequence we could potentially use for this: CSI ? <size> c
, which is used by the Linux kernel console to set the height of the cursor. It's very similar to the way the Windows vintage cursor works, and it's also supported by Mintty, which is another advantage.
The only negative is that it's not really an appropriate escape sequence, because CSI c
is technically reserved by ANSI for device attribute queries, and on some terminals a CSI ? c
sequence will trigger a DA
report.
But it's at least something to consider if nobody has any better ideas.
Hello!
There are a lot of different issues I found online about vim in PowerShell 7 used in the Windows Terminal not displaying the correct cursor shape for insert mode, command mode, visual mode, replace mode et cetera. From what I could find, this thread is supposed to be the original one, I hope I am posting in the right place.
It's working by adding set termguicolors before the escape sequences in the C:\Program Files (x86)\Vim _vimrc file.
set termguicolors
let &t_SI = "\e[4 q" let &t_SR = "\e[6 q" let &t_EI = "\e[2 q" let &t_ti .= "\e[1 q" let &t_te .= "\e[0 q"
Without set termguicolors or set t_Co=256 it doesn't work, but with one of them it does. Hopefully the people in this thread that still has problems can solve them with this.
found it here: https://github.com/vim/vim/pull/11028
In Windows Terminal, can I get the "vintage" cursor (~30% blinking horizontal bar) with an escape sequence?
Both of these (below) give a non-blinking cursor of the desired size. Other similar pairs suggest that 7 should be blinking?
ESC[7 q ESC[8 q