Skip to content

Recolouring support#129

Merged
tecosaur merged 9 commits intomainfrom
recolouring
Jan 4, 2026
Merged

Recolouring support#129
tecosaur merged 9 commits intomainfrom
recolouring

Conversation

@tecosaur
Copy link
Copy Markdown
Member

@tecosaur tecosaur commented Oct 26, 2025

The road to appropriate colours across the wide range of colour schemes and light/dark variability of the terminals people use, and for when 4-bit ANSI colours aren't sufficient.

  • Colour blending
  • Retheming hook
  • Light/dark support

@tecosaur tecosaur force-pushed the recolouring branch 2 times, most recently from f81a594 to c4c2119 Compare October 26, 2025 05:53
@tecosaur tecosaur changed the title Introduce colour blending utility Introduce recolouring support Oct 26, 2025
@tecosaur tecosaur changed the title Introduce recolouring support Recolouring support Oct 26, 2025
@tecosaur tecosaur force-pushed the recolouring branch 6 times, most recently from faacad2 to a8b8fae Compare October 26, 2025 09:28
@tecosaur
Copy link
Copy Markdown
Member Author

The associated REPL PR: JuliaLang/julia#59958

@tecosaur tecosaur force-pushed the recolouring branch 11 times, most recently from 96b8ccf to 5da5a96 Compare November 2, 2025 10:26
@tecosaur tecosaur force-pushed the recolouring branch 3 times, most recently from 9b31697 to 7e5812f Compare November 3, 2025 16:34
@tecosaur
Copy link
Copy Markdown
Member Author

tecosaur commented Nov 9, 2025

I'm about to start pushing some unrelated changes that build on this work.

Once I've sorted out what goes in what patches, and the commit order, I'll adjust this PR to be scoped to just recolouring again and put the remaining changes in a separate PR.

For now, here are the just-recolouring changes: https://github.com/JuliaLang/StyledStrings.jl/compare/9bb8ffdd8c2858cced7b6b6fcee85be41c9a1867..7e5812fb50191628079735bc30eaf2fde5a9dfa1

@tecosaur tecosaur force-pushed the recolouring branch 19 times, most recently from 5f8b929 to 921b63b Compare December 27, 2025 04:03
When making terminal-friendly interfaces, it is easy to run into the
limits of 4-bit ANSI colouring. This is easily seen when trying to show
selections or highlighting, and a shaded background is required. Without
knowing if the terminal is light or dark, and what shades its ANSI
colours are, it is not possible to pick an appropriate colour.

To generate appropriate colours, some form of blending is required.
Instead of encouraging packages to just pick a colour, or do ad-hoc
blending themselves, it makes sense for us to provide a single colour
blending function that does a good job: here, by transforming the sRGB
colour into OKLab space to do the blending in, and then back to sRGB at
the end. This extra work pays off in markedly better results.

While terminal colour detection and retheming is left for later, this
work together with the base colours lays the foundation for consistently
appropriate colouring.
This will make it easier to reapply modifications after recolouring.
These were never supposed to make the cut in the first place.
@tecosaur
Copy link
Copy Markdown
Member Author

tecosaur commented Jan 4, 2026

I think that this is a good start, and that we can refine the approach more before this is released with Julia 1.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants