Terminal: Cursor does not blink

Created on 10 May 2019  路  8Comments  路  Source: microsoft/terminal

  • Your Windows build number: Microsoft Windows [Version 10.0.18362.86]
  • What you're doing and what's happening:
    Run Windows Terminal (Preview) and it started with cmd.exe. The cursor is not blink as in original console.
  • What's wrong / what should be happening instead:
    The cursor does not blink.
Area-Rendering Help Wanted Issue-Bug

Most helpful comment

This is a known issue at the moment - conhost has a timer for specifically blinking the cursor, but there's no such timer in the Terminal currently.

I don't _think_ this would be terribly difficult for someone to dig their hands into.

If someone wanted to implement this, they'd need to set up some sort of timer in UWP (not sure how to do that) in the TermControl class. That timer would then call methods on the Cursor object of the Terminal's TextBuffer which control the blink visibility. This is either SetIsOn or SetVisible, I can't recall ATM.

All 8 comments

This is a known issue at the moment - conhost has a timer for specifically blinking the cursor, but there's no such timer in the Terminal currently.

I don't _think_ this would be terribly difficult for someone to dig their hands into.

If someone wanted to implement this, they'd need to set up some sort of timer in UWP (not sure how to do that) in the TermControl class. That timer would then call methods on the Cursor object of the Terminal's TextBuffer which control the blink visibility. This is either SetIsOn or SetVisible, I can't recall ATM.

I have a blinking cursor working. Right now it just blinks all the time, but it should probably stop in certain circumstances, such as when typing, moving the cursor or unfocusing the window. Am I missing anything?

Edit: The PowerShell and cmd hosts seem to have different behaviour, and I can't figure out what the PowerShell host is doing (it seems to blink the cursor really fast when a key is held down?)

I've implemented the following behavior:

  • When the window is unfocused, the cursor goes away. This is consistent with both conhost and PowerShell, however some terminals like ConEmu leave the cursor on when the window is unfocused.
  • When a key is pressed, the cursor is shown and the timer is restarted. This is what ConEmu does. conhost is similar, but it seems to just show the cursor and not restart the timer, which makes it a little jitterier when testing both methods side by side. I still can't figure out what PowerShell is doing. Either way, I prefer this behavior and haven't noticed any significant performance impact in my testing.

Any other edge cases to cover?

Edit: The PowerShell and cmd hosts seem to have different behaviour, and I can't figure out what the PowerShell host is doing (it seems to blink the cursor really fast when a key is held down?)

Both powershell and cmd should have the same behaviour as they share the same host: conhost. That said, powershell is managed code and cmd is native, so you're probably seeing more jitter and flickering due to the overhead of CLR interop.

Here's a comparison between cmd, PowerShell and Windows Terminal, rapidly pressing k and then holding down j. Powershell's behaviour still seems pretty strange, but then again most people don't pay attention to cursor blinkage as much as I have been in the past few hours.

2019-05-10_17-49-04.gif

Anyway, I'm going to clean up a bit and make a PR.

Throwing my 2 pence in, the cursor should not blink, but remain visible when a key is being held down and text is being entered into the console. It would prevent a user typing in whilst the timer controlling the visibility is currently set to hidden.

This is how it works now. When you type, the timer gets reset and the cursor is visible.

I'm on Windows 10.19041, Terminal Preview 1.4.2652.0. I have a weird issue where the cursor blinks in PowerShell and cmd but not in WSL (Ubuntu 18.04 WSL2), once I've opened and closed neovim. Since there is a possibility that this might be a config issue I did not want to open a new issue, has anyone else experienced this and/or managed to fix it? It appears in zsh, sh and bash; with and without tmux attached.

Edit: After some googling, I realised neovim sets the cursor and does not change it back when leaving. You can either turn on the blinking cursor within neovim or reset the blinking while leaving

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carlos-zamora picture carlos-zamora  路  3Comments

xmm1989218 picture xmm1989218  路  3Comments

Wid-Mimosa picture Wid-Mimosa  路  3Comments

wkbrd picture wkbrd  路  3Comments

zadjii-msft picture zadjii-msft  路  3Comments