-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Allow theming with arbitrary CSS color strings #1346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Really nice PR, this is addressing one of the bigger areas of concern, thanks! If I'm reading the code correctly, passing alpha values like There's also one test failling: |
|
|
||
| // Colors 0-15 + 16-255 | ||
| // Much thanks to TooTallNate for writing this. | ||
| const vcolors: number[][] = (function(): number[][] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've wanted this gone for a long time 😛
|
This looks great, I haven't tested the code but if everything works fine and the tests pass then I'm 👍 |
|
I've fixed the test, and amended the commit!
This parses alpha channels.
Selections work as expected. They're partially transparent. |
| dom = new jsdom.JSDOM(''); | ||
| window = dom.window; | ||
| document = window.document; | ||
| (<any>window).HTMLCanvasElement.prototype.getContext = () => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make sense to pull in node-canvas (which JSDom integrates with) as a dev dependency if we want to test more rendering-related codepaths, but this works for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to improve the testing situation, I was thinking about puppeteer but I'm not sure if that's the right tool for the job thinking about it some more. #1247
This mostly worked before, but clearColor made the assumption that the colors were always in #RRBBGG format. See the discussion here: xtermjs#1327 (comment) This changes the internal representation of a color so that we hold onto into an object containing the original css string along with an RGBA value encoded as a 32-bit uint. clearColor can then use that RGBA representation. Additionally, this deduplicates some code between ColorManager and Terminal. Terminal was generating the 256 ansi colors the same way ColorManager was, so this just makes Terminal use the same constant.
Fixes xterm/xterm.js#1357.
|
I merged bgw#2 (Block transparent colors without allowTransparency) into this PR, and I'm not aware of any outstanding issues, so I think this is ready to be merged. I'll do the node-canvas stuff as a separate PR once this stuff lands. |
|
Thanks @bgw 👍 |

This mostly worked before, but
clearColormade the assumption that the colors were always in#RRGGBBformat. See the discussion here: #1327 (comment)This changes the internal representation of a color so that we hold onto into an object containing the original css string along with an RGBA value encoded as a 32-bit uint.
clearColorcan then use that RGBA representation.Additionally, this deduplicates some code between
ColorManagerandTerminal.Terminalwas generating the 256 ansi colors the same wayColorManagerwas, so this just makesTerminaluse the same constant.256 colors still works:
and so does the 24-bit color approximation:
The static char atlas looks sane, so
clearColoris working:We can change the theme using arbitrary css strings:
And
clearColorstill works properly, but now using a pink background: