kueblc / LDT

Lightweight in browser syntax highlighting
https://kueblc.github.io/LDT/
159 stars 17 forks source link

Suggestion: A dedicated layer for the caret allows a fully transparent textarea (and thus vivid colors) #26

Closed pygy closed 8 months ago

pygy commented 8 months ago

As seen here.

On the left is LDT's source, on the right a demo that highlights what's been added.

Please note that this is whipped out of an old project of mine where I tweaked LDT quite a bit. I've however imported the latest version of TextareaDecorator() which is where the meat of the patch lies (There's also some CSS, some of which may not be necessary).

kueblc commented 8 months ago

Hi Pierre,

Thanks for sharing your suggestion! I appreciate the time you took to describe your enhancement.

I believe you will be happy to find that the current LDT does in fact have an essentially fully transparent textarea, thanks to the addition of the caret-color property. This allows us to set the native caret color independent of the text color.

Reimplementing native behavior like the caret is something I'd like to avoid for LDT. Other rich text solutions like CodeMirror already take the approach of reimplementing standard behaviors; what sets LDT apart is behaving like a native component without all the added weight.

Thanks again for sharing your thoughts and please don't hesitate if you have any others to share.

pygy commented 8 months ago

That's awesome, I didn't know about caret-color.

I understand you'd rather avoid reimplementing native stuff, I didn't know you could do without (the aforementioned hacking dates back to 2015-16, and I hadn't tried updating LDT in the mean time... Since you were mentioning a semi-transparent textarea, I thought things hadn't changed in that regard).