Why does the cursor stop blinking when the window is out of focus?

0

I have seen this both on Linux (Ubuntu 13.10) and Windows (7) that when a window (editor, browser, terminal etc) containing a text box with a blinking cursor goes out of focus it's cursor stops blinking.

Why is it so? Some detail on the internal process (the how) of this would be appreciated.

Bleeding Fingers

Posted 2014-01-08T18:53:06.627

Reputation: 254

Answers

0

The blinking one is the prompt that is ready for input (because it's in the foreground).

It's a visual cue so you know which command box your input will go to.

More info from Wikipedia:

In most command-line interfaces or text editors, the text cursor or caret navigation, is an underscore, a solid rectangle, or a vertical line, which may be flashing or steady, indicating where text will be placed when entered (the insertion point).

and

The blinking of the text cursor is usually temporarily suspended when it is being moved; otherwise, the cursor may change position when it is not visible, making its location difficult to follow.

As to "How" it's implemented, that would depend on the command line interface being used, and will probably vary from vendor to vendor, and many of those vendors are closed-source.

Often the cursor appearance is also affected/controlled by the video adapter, but generally only in true video text modes.

If I were to implement my own, I'd image a timer that toggles the cursor's visibility state would be used, and that timer would be suspended when the window loses focus (perhaps also setting the state in not-visible), and started again when focus returns. But that's simplifying the crap out of it. ;)

Ƭᴇcʜιᴇ007

Posted 2014-01-08T18:53:06.627

Reputation: 103 763

Command interpreters have nothing at all to do with the implementatations of either GUI carets or TUI cursors. – JdeBP – 2014-01-08T19:59:15.390

@JdeBP bad choice of words. Fixed. – Ƭᴇcʜιᴇ007 – 2014-01-10T00:26:36.677