If you live in the terminal, kitty is made for you! Cross-platform, fast, feature-rich, GPU based.
Find a file
Jökull Sólberg 64abd87a9e Add wide gamut color support with OKLCH and LAB formats
Implements modern wide gamut color formats with CSS Color Module Level 4
gamut mapping, addressing PR feedback with Go implementation, performance
benchmarks, and reorganized documentation.

Features:
- OKLCH (perceptually uniform color space)
- CIE LAB (device-independent color space)
- CSS Color 4 compliant gamut mapping algorithm
- Inline comment support in color config parsing

Addressing PR Feedback:

1. Go Implementation (tools/utils/style/):
   - Complete OKLCH and LAB parsing with gamut mapping
   - Matches Python implementation structure
   - Comprehensive test suite (all tests passing)
   - Performance benchmarks showing acceptable overhead

2. Performance Benchmarks:
   - OKLCH: ~4.6 µs/op
   - LAB: ~1.5 µs/op
   - 10 mixed colors: ~13 µs total
   - Typical config (50 colors): <0.5ms startup impact

3. Documentation Reorganization:
   - Moved detailed color docs to docs/wide-gamut-colors.rst
   - Configuration docs now link to separate documentation
   - Reduces size of main configuration documentation

Gamut Mapping:
- Binary search chroma reduction from CSS Color Module Level 4
- Preserves lightness and hue while reducing chroma for out-of-gamut colors
- Uses deltaE OK (JND threshold: 0.02) for perceptual difference
- Ensures graceful degradation on sRGB displays

Python Implementation:
- parse_oklch(): OKLCH color parsing with gamut mapping
- parse_lab(): CIE LAB parsing with gamut mapping via OKLCH conversion
- lab_to_oklch(): LAB to OKLCH conversion for consistent gamut mapping
- oklch_to_srgb_gamut_map(): CSS Color 4 gamut mapping algorithm
- srgb_to_oklab(): Reverse conversion for deltaE calculations
- deltaE_ok(): Perceptual color difference in OKLab space

Go Implementation:
- colorspaces.go: All color space conversions and gamut mapping
- wrapper.go: ParseColor() updated to support OKLCH and LAB
- Comprehensive test coverage with benchmarks
- Matches Python implementation behavior

Robustness:
- NaN and infinity validation in all color parsing functions
- Defense-in-depth with validation at parsing and gamut mapping levels
- Returns None/error for invalid input (consistent error handling)
- Validates before clamping operations to prevent NaN propagation

Files changed:
- Python: kitty/rgb.py, kitty_tests/datatypes.py (+250 lines)
- Go: tools/utils/style/colorspaces.go, wrapper.go (+350 lines, tests)
- Docs: docs/wide-gamut-colors.rst (moved from inline)
- Config: kitty/options/definition.py (simplified, links to docs)

References:
- CSS Color Module Level 4: https://www.w3.org/TR/css-color-4/
- OKLCH Color Space: https://bottosson.github.io/posts/oklab/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-27 14:34:34 +00:00
.github Bump actions/cache from 4 to 5 in the actions group 2025-12-22 03:22:12 +00:00
3rdparty ... 2024-07-14 12:34:24 +05:30
bypy Bump version of libpng for CVE 2025-12-07 11:45:13 +05:30
docs Add wide gamut color support with OKLCH and LAB formats 2025-12-27 14:34:34 +00:00
gen Output the set of special colors separately 2025-11-08 00:55:10 +05:30
glad More robust detection of support for GL_FRAMEBUFFER_SRGB 2025-08-11 09:13:49 +05:30
glfw Fix #9306 2025-12-20 08:54:22 +05:30
kittens Fix warning when generating docs 2025-12-05 20:11:23 +05:30
kitty Add wide gamut color support with OKLCH and LAB formats 2025-12-27 14:34:34 +00:00
kitty_tests Add wide gamut color support with OKLCH and LAB formats 2025-12-27 14:34:34 +00:00
logo
shell-integration choose files: Add default mappings to choose a file and insert it into the terminal 2025-11-23 11:41:21 +05:30
terminfo Allow backspace to wrap cursor to previous line 2025-07-23 08:56:54 +05:30
tools Add wide gamut color support with OKLCH and LAB formats 2025-12-27 14:34:34 +00:00
.editorconfig Fix indentation in codeql yml file 2025-04-14 10:21:10 +05:30
.gitattributes Allow backspace to wrap cursor to previous line 2025-07-23 08:56:54 +05:30
.gitignore Nicer way to include grapheme test data in Go tests 2025-03-27 03:20:27 +05:30
__main__.py
benchmark.py Make mypy 1.16 happy 2025-05-30 10:06:38 +05:30
Brewfile See if dropping pkgconf fixes CI build 2024-11-23 19:48:05 +05:30
build-terminfo
CHANGELOG.rst
CONTRIBUTING.md
count-lines-of-code Update the list of nerd font names when updating other unicode data as well 2025-05-21 13:19:27 +05:30
dev.sh
embeds.go Code to serialize/unserialize loaded images 2025-10-07 17:25:47 +05:30
go.mod Fix #9323 2025-12-24 16:35:10 +05:30
go.sum Fix #9323 2025-12-24 16:35:10 +05:30
INSTALL.md
key_encoding.json
LICENSE
Makefile
publish.py Use a full qualified name for SBOM generation 2025-09-18 17:42:05 +05:30
pyproject.toml Specify python dependencies in pyproject.toml 2025-09-16 16:42:01 +05:30
README.asciidoc Update some docs 2025-10-07 20:20:19 +05:30
rsync-and-build.sh Slightly improve rsync script 2025-05-09 15:33:22 +05:30
SECURITY.md ... 2025-09-14 21:31:43 +05:30
session.vim
setup.py Set building flag globally 2025-12-04 14:59:59 +05:30
shell.nix fix: add missing pkgs and manually add font for nix shell 2025-05-10 14:42:46 +02:00
staticcheck.conf
test.py
update-on-ox Allow turning off stripping in update-on-ox 2024-08-18 15:30:38 +05:30

= kitty - the fast, feature-rich, cross-platform, GPU based terminal

If you live in the terminal, *kitty* is made for **you**!

See https://sw.kovidgoyal.net/kitty/[the kitty website].

image:https://github.com/kovidgoyal/kitty/workflows/CI/badge.svg["Build status", link="https://github.com/kovidgoyal/kitty/actions?query=workflow%3ACI"]

https://sw.kovidgoyal.net/kitty/faq/[Frequently Asked Questions]

To ask other questions about kitty usage, use either the https://github.com/kovidgoyal/kitty/discussions/[discussions on GitHub] or the
https://www.reddit.com/r/KittyTerminal[Reddit community]

Packaging status in various repositories:

image:https://repology.org/badge/vertical-allrepos/kitty-terminal.svg?columns=3&header=kitty["Packaging status", link="https://repology.org/project/kitty-terminal/versions"]