News for hackers. Stuff that matters.
Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by nolok on Thursday March 23, 2017 @11:31AM (#13940618)
> I'm not sure why this implementation is slow

I'm guessing the culprit for that is in this part of the bug report:

> Zooming into a single frame, we see that while we render only 2 fps, the main thread is performing some work at 60 fps (every 16 ms)

As for

> why they needed to implement it themselves and not let the OS handle the blinking cursor

They're not editing inside a text editor field anymore, they need to blink on html. I guess they're not using a deprecated <blink> tag is because it's not customizable in any way.

Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by kibwen on Thursday March 23, 2017 @12:17PM (#13941161)
I don't believe that any modern browser still supports the blink tag; IIRC Firefox was the last to get rid of it, a year or two ago. You can hack it up in CSS, though.
Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by ethbro on Thursday March 23, 2017 @03:07PM (#13943084)
Truly, the web has come full circle.
Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by Mister_Snuggles on Thursday March 23, 2017 @03:05PM (#13943061)
On Win32[0], the blinking caret can be shown anywhere inside a window, not just on a text field. The sample program builds a basic text editor without cheating and using a textbox control.

I'm sure other operating systems have this kind of facility - after all, how does the built in text edit control draw its caret?

[0] https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...

Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by coldtea on Thursday March 23, 2017 @03:50PM (#13943544)
>On Win32[0], the blinking caret can be shown anywhere inside a window, not just on a text field. (...) I'm sure other operating systems have this kind of facility - after all, how does the built in text edit control draw its caret?

The "built in text edit control" IS a native text field already.

Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by Mister_Snuggles on Thursday March 23, 2017 @03:58PM (#13943647)
My point is that the built-in text edit control needs some way to draw it's caret, so surely a universal method to draw a blinking caret exists somewhere.
Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by coldtea on Thursday March 23, 2017 @04:35PM (#13944004)
Well, they could just make a C extension to Electron that draws a blinking colored line (that's all it is) using the OSes arbitrary drawing facilities.

No need to have an official OS caret function (especially if you're not a native text field, and caret aside, the rest of your text editing will be different/broken in subtle ways compared to the OS).

Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by Someone on Thursday March 23, 2017 @05:52PM (#13944704)
I'm not aware of any system where one can create that caret without a text edit control to hold it. That means that, if the standard text edit control isn't suited for what you want to do, you can't have the caret.

Certainly, on the original Mac OS (a system on which I worked on OS patches for detecting the location of the caret) the method that application used for drawing the caret varied widely. I've seen it implemented by drawing a line, by drawing a rectangle, either in one go or in two parts (that happened in applications that supported a split caret, even if the caret wasn't split), with various transfer modes. Slanted carets typically were application-specific, too.

Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by Mister_Snuggles on Thursday March 23, 2017 @06:40PM (#13945003)
> I'm not aware of any system where one can create that caret without a text edit control to hold it.

Windows allows this. In a parent comment I posted a link to the API docs. All Windows requires is a window to hold the caret, it doesn't care what kind of window it is.

Re:VS Code uses 13% CPU when idle due to blinking cursor ren... by Touche on Thursday March 23, 2017 @12:17PM (#13941164)
Thanks, so they are probably not using a contenteditable element. In that case it makes sense that they would need to use a CSS animation to blink the cursor.