Comments (2)
Our most commonly used cursor "color" is one that inverses the underlying color to always keep it visible:
However, there's a problem: If the underlying color is very close to gray (or some equivalent) then the inverse will also be gray which causes the cursor to be invisible. To solve that issue, we compute color distances when drawing the cursor and nudge the cursor and inverted text colors to be further apart. Finally, we also need to stretch the cursor when hovering over a wide glyph and it's unclear how that would look like with this grid shape.
While the 5x5 grid glyph can technically be implemented just like the empty box cursor as a set of rectangles, this one would result in not just 4 but 25 rectangles. Every single one of those would consist of 2 individual triangles during rendering. That's certainly anything but optimal.
The proper solution here would be to draw the glyph into our glyph cache and use it as a pixel-by-pixel lookup texture to invert every underlying pixel where the lookup texture is lit/white. This would need to be implemented in the pixel shader. But there's multiple problems with that:
- Requires us to port the color distance algorithm to HLSL.
- Requires us to invert the text at the time it is being blended into the swap chain. This is because text rendering is gamma corrected based on the text color and this information is lost once the blending finished. Inverting the color retroactively leads to either too thin or too fat looking stems in the glyphs.
- Right now, we upload the pixel shader constant buffer as an immutable buffer, which is quite efficient. This change would require us to turn that into a dynamic buffer because the constant buffer would need to store the changing location of the cursor in the viewport. Graphics drivers may handle dynamic constant buffers by allocating large ring buffers so that they can be efficiently pipelined. We'll have to test all of our relevant hardware on how they react to such a change. After all, we're trying to optimize the renderer for power draw and memory usage, while graphics drivers are always trying to optimize us as if we were a video game. This conflict of interests continues to be an issue for us.
I think rendering cursor in the pixel shader is the right way to do it, no matter what. The importance of this feature VS the time required for testing it is the real issue unfortunately. đ
from terminal.
@lhecker
Hey, I know that segmented 0! đ
Thanks for all the details. And yeah, I was hoping it could just be an extra label and character in a list of cursors.
I didn't think about the way you invert the character under the cursor.
On the Apple II, the cursor is not xor-blitted with the character at that position, it simply toggles between the character and the cursor. So I was thinking about that behavior which is basically just changing the character at the cursor position on the blink interval.
The work involved isn't worth it for the nostalgia thrill, and apps can still achieve the same result by swapping the character explicitely.
from terminal.
Related Issues (20)
- Version: 1.20.10572.0 reopens last tabs whenever it feels like it HOT 5
- Windows Terminal will not open HOT 6
- WSL import profile folders setting HOT 3
- [Console]::Beep() does not activate "Bell Notifications" HOT 5
- Paste with Ctrl removes leading special character in SSH HOT 1
- Can't open as administrator HOT 2
- Ctrl + PageUp/PageDown should be the default keyboard shortcuts for changing the current tab. HOT 1
- VT renderer works incorrectly when cursor is moved between writes HOT 9
- Is there any convenient way to modify the terminal's encoding? HOT 3
- Don't push the buffer contents into the scrollback on session restore HOT 4
- Open windows from a previous session should not re-run processes or have ability to selectively stop that HOT 2
- Auto Reverting Font to Consolas HOT 6
- [Feat.] Allow Remote Config Backup+Restore
- Unused/obsolete code in XtermEngine HOT 1
- Cannot save settings.json from the UI when it is a symbolic link HOT 2
- persistedWindowLayout doesn't restore CWD in split panes HOT 1
- The default working directory of new tabs should match the previous tab HOT 1
- cursor shape wrong with nvim HOT 1
- Cascadia Ęż (U+077F : Arabic Letter Kaf With Two Dots Above) rendering problem in Terminal HOT 4
- Still cannot drop files to Terminal running as admin HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â€ïž Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terminal.