Skip to content

Conversation

@tecosaur
Copy link
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
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
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 2 times, most recently from 1213898 to 8aafa47 Compare January 1, 2026 12:59
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.
@tecosaur tecosaur force-pushed the recolouring branch 13 times, most recently from 38d0a06 to 724a400 Compare January 3, 2026 06:38
@tecosaur tecosaur force-pushed the recolouring branch 2 times, most recently from 25c81bd to 9b97c72 Compare January 4, 2026 05:17
@tecosaur
Copy link
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.

@tecosaur tecosaur merged commit e1ec223 into main Jan 4, 2026
5 checks passed
@tecosaur tecosaur deleted the recolouring branch January 4, 2026 07:16
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