Commit graph

1484 commits

Author SHA1 Message Date
Kovid Goyal
dc9bf889a6
Fix chunking of t=k not handling metadata present only on first chunk 2026-04-19 12:52:00 +05:30
distsystem
875ca70a55 Fix crash in overlay line drawing on uninitialized linebuf view
screen_draw_overlay_line accessed self->linebuf->line->cpu_cells
without ever calling linebuf_init_line on the shared view. Render
paths that initialize a stack-local Line via render_line_for_virtual_y
left the view's cpu_cells as NULL (the value set by alloc_line via
PyType_GenericAlloc), and the multicell-trim loop then dereferenced
NULL + xstart * sizeof(CPUCell), producing a SIGSEGV at a small
address (e.g. 0x1e for xstart=2). The crash was reachable any time
an IME pre-edit overlay was rendered with the cursor not in column 0
on a screen whose linebuf->line had not been re-pointed by some
unrelated prior call.

Fix by initializing the view at the overlay row on entry. Add a
test_draw_overlay_line method on Screen so the behavior can be
exercised directly from a regression test.
2026-04-18 13:10:07 +08:00
copilot-swe-agent[bot]
e8e2b31182
Fix memory safety issues, protocol bugs, and add tests for DnD implementation
Fixes:
- Memory leak: drag_free_remote_item now frees children array
- Memory leak: drag_free_offer now frees pending data
- Memory leak: toplevel_data_for_drag frees old URI string before replacement
- Protocol bug: drag_notify missing OSC prefix in escape code output
- Protocol bug: drag_notify missing colon separators between metadata keys
- Buffer overflow: add_payload symlink case ensures capacity for null terminator
- Integer overflow: expand_rgb_data uses size_t casts for multiplication
- Memory leak: realloc anti-pattern fixed in 7 locations (drop_register_window,
  drop_dispatch_data, drag_add_mimes, drag_add_pre_sent_data, drag_add_image,
  add_payload default case, queue_payload_to_child)
- UB: queue_payload_to_child guards memcpy with NULL source + 0 count

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/3c7e550c-e8e8-413e-a54b-87d61cb8e574

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-14 09:33:23 +00:00
copilot-swe-agent[bot]
519fd49ce6
Fix bugs in t=k remote drag implementation and add comprehensive tests
Bug fixes in dnd.c:
- mktempdir_in_cache: add missing 'return ans' after successful strdup
- mktempdir_in_cache (utils.py): use O_RDONLY instead of O_RDWR for directories
- remote_items allocation: use mi.num_uris instead of ds.num_mimes
- Off-by-one: uri_item_idx > changed to >= for bounds checks
- Off-by-one: entry_num > changed to >= for bounds checks
- populate_dir_entries: fix missing last entry after final null separator
- add_payload directory finalization: create directory on disk with mkdirat
- get_errno_name: add EFBIG, EISDIR, ENOSPC error codes

Test infrastructure:
- Add dnd_test_force_drag_dropped() to simulate DROPPED state
- Make notify_drag_data_ready() succeed in test mode

Comprehensive t=k tests added:
- Single file, empty file, single symlink transfer
- Chunked file transfer with m=1
- Single directory with children
- Directory with symlinks
- Multiple URIs
- Deep directory trees (breadth-first and depth-first, 3+ levels)
- Mixed file/dir/symlink at top level
- Completion signal
- Error handling (client errors, invalid state)
- DoS limits (REMOTE_DRAG_LIMIT, PRESENT_DATA_CAP)
- Invalid input (bad base64, too large chunks, invalid indices/handles)
- URI list with comments
- Multiple chunks for directory listing

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/9da0bff7-6a1a-490f-a4c5-8cb328e056ce

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-13 15:54:34 +00:00
Kovid Goyal
864ef70484
Have the client send machine id to terminal rather than vice versa
The terminal is the trusted by user party here.
2026-04-12 11:00:23 +05:30
Kovid Goyal
9ebe692bf7
Allow drop clients to use machine id as well 2026-04-12 09:27:16 +05:30
Kovid Goyal
df20d4aa7c
Add machine id and stub for t=k transfers 2026-04-11 17:20:53 +05:30
copilot-swe-agent[bot]
74c3bbe06d
Implement software rendering for Unicode 16 legacy computing symbols
Add rendering for codepoints U+1FBCE-U+1FBEF, U+1CC1B-U+1CC3F,
and U+1CE16-U+1CE19 in decorations.c with registration in fonts.c
and test coverage in kitty_tests/fonts.py.

Characters implemented:
- U+1FBCE-1FBCF: Left two-thirds and one-third blocks
- U+1FBD0-1FBDF: 16 diagonal box drawing characters
- U+1FBE0-1FBE3: Justified half white circles (outlines)
- U+1FBE4-1FBE5: Upper/lower centre quarter blocks
- U+1FBE8-1FBEB: Justified half black circles (filled)
- U+1FBEC-1FBEF: Justified quarter black circles (filled)
- U+1CC1B-1CC1E: Box drawing variants with offset junctions
- U+1CC1F-1CC20: Double diagonal lines
- U+1CC30-1CC3F: Twelfth and quarter circle arcs
- U+1CE16-1CE19: Box drawings light vertical T-junctions

Fixes #9851
2026-04-11 14:17:21 +05:30
copilot-swe-agent[bot]
76c76381b8
Add missing block elements from Unicode Symbols for Legacy Computing Supplement
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/0e5a33d1-c34e-4e8a-b161-7469ab770c05

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-11 04:24:29 +00:00
Kovid Goyal
5e158f90a7
Fix some responses from terminal sometimes leaking into shell on after kitten exit
Always do a roundtrip at kitten exit, except for special purpose
kittens. This slows down exit by one round trip time (capped at 2
seconds), however it ensures that we never get terminal response leak.

Fixes #9839
2026-04-10 15:14:38 +05:30
copilot-swe-agent[bot]
b8cbb7f68d
Address code review: use < 2 condition, fix docstring, assert first handle = 2
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/6973699c-a979-4d97-8213-1a4a501044a1

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-10 07:39:40 +00:00
copilot-swe-agent[bot]
afa63ccec7
Implement new drop protocol X/Y key handling from b466f8b
- dnd.c: drop_send_dir_listing now uses drop_append_request_keys (echoes
  all request keys including Y for sub-dirs) and emits :X=handle instead
  of :Y=handle:X=2.  Directory handles are now the X value itself.
- dnd.c: drop_alloc_dir_handle starts handle counter at 1 so first
  handle is 2, keeping 0 (absent) and 1 (symlink) reserved as per protocol.
- dnd.py: add is_dir_event() / dir_handle() helpers; update all tests to
  use int(X) > 1 as directory indicator and X as the handle value.
- dnd.py: rename test_Y_key_in_dir_listing_response to
  test_X_key_is_handle_in_dir_listing_response with updated assertions.
- dnd.py: test_uri_directory_transfer_tree expanded to verify unambiguous
  identification (Y=parent, x=entry echoed) at all three directory levels.

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/6973699c-a979-4d97-8213-1a4a501044a1

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-10 07:35:09 +00:00
copilot-swe-agent[bot]
0a8713972c
Change drag offer error responses from t=R to t=E in dnd.c and dnd.py
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/b0dd4978-d0b4-42a3-81e0-51b5ce155db9

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-09 17:14:44 +00:00
copilot-swe-agent[bot]
0f47a23c36
Update DnD tests for new protocol: use x/y/Y disambiguation instead of request_id
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/cdeecb3c-8589-4622-8f6b-21b724e4d5fd

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-09 15:35:23 +00:00
copilot-swe-agent[bot]
4d2b63fce8
Revert to 1-based directory entry indexing in DnD protocol
- dnd.c: entry_num==0 closes handle; entry_num>=1 reads at entry_num-1
- parse-dnd-command.h: revert cell_y default to 0 (from {0} init)
- gen/apc_parsers.py: remove post_init for DnD parser
- docs/dnd-protocol.rst: update to say 1-based indexing
- tests: all .index() calls add +1, rename test_dir_entry_one_based_index

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/d4074aba-3aeb-4d2b-adc1-d6c6f2b539e7

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-09 11:52:31 +00:00
copilot-swe-agent[bot]
7e0e3eb6ac
Fix os.makedirs to os.mkdir for single-level directory in test
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/d09883e5-f460-471d-9dcf-e64e7b96882f

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-09 11:38:49 +00:00
copilot-swe-agent[bot]
d548afc94a
Implement DnD protocol changes for symlinks and directory handling
- Remove unique identifier (device:inode) from directory listings
- Change directory entry indexing from 1-based to 0-based
- Add symlink handling in directories: respond with t=r:X=1 and target
- Update parser to default cell_y to -1 for close handle detection
- Update and extend tests for all new behaviors

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/d09883e5-f460-471d-9dcf-e64e7b96882f

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-09 11:33:43 +00:00
Kovid Goyal
139a0fac25
Merge branch 'fix-inactive-text-alpha' of https://github.com/zzhaolei/kitty 2026-04-09 14:09:43 +05:30
zhaolei
40c2012eeb Support negative inactive_text_alpha values for active-window-only fading 2026-04-09 13:04:01 +08:00
copilot-swe-agent[bot]
4339deb647
Add comprehensive tests for request queue and request_id behavior
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/3a4975c2-8691-486b-8ff9-f8a2146b8756

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-09 03:20:41 +00:00
Kovid Goyal
47b5b2ea65
Prevent reading uri-list items for a drag and drop in same window 2026-04-09 06:38:58 +05:30
copilot-swe-agent[bot]
f6f1cae3b7
Fix issue #9834: preserve trailing spaces on soft-wrapped lines during copy
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/343539f7-deab-4eeb-9829-99bec57c3523

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-08 17:17:20 +00:00
copilot-swe-agent[bot]
9cd8558cfd
Address code review feedback: improve test names and docstrings
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/f9868553-29a2-48c4-85c2-b6b8f686dccc

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-08 15:47:31 +00:00
copilot-swe-agent[bot]
7d33569c1a
Add comprehensive drag protocol tests and fix double-free bug in drag_free_built_data
- Add 37 new tests covering the drag source side of the DND protocol
- Test drag offer registration/unregistration (t=o, t=O)
- Test drag MIME type offering with various operations (copy/move/both)
- Test pre-sent data for valid/invalid indices, chunked data, multiple MIMEs
- Test image thumbnails: valid RGBA/RGB, invalid formats, dimensions, chunking
- Test drag start failures (no window, no offer, image size mismatches)
- Test drag cancellation from client (t=E:y=-1)
- Test offer replacement, cleanup, and error propagation
- Test client_id propagation for drag operations
- Test resource cleanup on window close during drag build
- Fix double-free in drag_free_built_data: set ds.items=NULL after free
- Add drag_free_offer to destroy_fake_window_contents for proper cleanup

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/f9868553-29a2-48c4-85c2-b6b8f686dccc

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-08 15:43:37 +00:00
Kovid Goyal
a0958a05a9
Merge branch 'action_aliases_command_palette' of https://github.com/dmgerman/kitty 2026-04-07 19:40:55 +05:30
copilot-swe-agent[bot]
18fb31b416
Fix double-click word selection not extending beyond viewport edges
Add continue_word_upwards_scrollback() and continue_word_downwards_offscreen()
to extend word selection beyond viewport boundaries, mirroring the line
selection fix. Add tests for word selection wrapping into scrollback and
below viewport.

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/58191e45-d925-4996-b0d5-8b1bd4baa8d5

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-07 09:49:50 +00:00
copilot-swe-agent[bot]
82bf8923cc
Fix triple-click line selection not extending wrapped lines beyond viewport bottom
Similar to commit 625e984 which fixed extending into scrollback (above viewport),
this fix extends line selection below the viewport when a wrapped line continues
past the bottom edge. Adds continue_line_downwards_offscreen() and applies it
in both the initial selection and extending selection code paths.

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/e548ce84-fdb7-4fd1-b3df-e1166b45f5bd

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-07 09:31:17 +00:00
Daniel M German
3d89cb267c Add alias and combine support to the command palette
Users who define action_alias or kitten_alias in kitty.conf had no way
to discover or trigger these custom commands from the command palette.
Aliased keybindings were miscategorized (landing in "Miscellaneous"
with no help text), and combine bindings had the same problem.

Changes:

- Resolve aliases via opts.alias_map to get correct action names,
  categories, and help text for aliased keybindings
- Add dedicated "Action aliases" and "Kitten aliases" sections that
  list all user-defined aliases, with bound aliases showing their key
  and unbound aliases browsable as unmapped entries
- Add a "Combined actions" section for combine keybindings
- Make alias names searchable in the Go TUI so users can find
  bindings by typing the alias name
- Fix action column highlight positions to match the scored text,
  preventing visual corruption when searching for alias names

Also refactors collect_keys_data into focused single-responsibility
functions and reduces nesting depth across both Python and Go.
2026-04-06 09:45:39 -07:00
Kovid Goyal
03cf6f9348
Fix unclosed resource warning in test 2026-04-01 20:01:28 +05:30
Kovid Goyal
78f1607bf5
Cleanup previous PR 2026-04-01 19:52:40 +05:30
copilot-swe-agent[bot]
51fe3dc274
Implement DnD protocol: t=s URI file transfer and t=d directory listing with tests
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/a5aee38b-1746-4699-9dcc-2138f43cabe8

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-01 08:55:55 +00:00
Kovid Goyal
81d0e2dc8e
Cleanup previous PR 2026-04-01 13:05:56 +05:30
copilot-swe-agent[bot]
02aec3fa3e
Add DnD protocol test framework and tests
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/faa69cb9-991d-49f4-802b-263f4bb28ee9

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-01 07:22:47 +00:00
copilot-swe-agent[bot]
96d10e51a0
Fix drag resize direction bugs and add comprehensive tests
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/12198e55-3901-439b-9fba-9b5f5b470416

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-04-01 03:48:49 +00:00
copilot-swe-agent[bot]
35ca3a178d
Implement smooth animated scrolling for scroll_line_up and scroll_line_down
Fixes #9784
2026-03-31 21:02:53 +05:30
Kovid Goyal
fe0ecbd9ca
Regenerate palette colors when changing colors at runtime
Fixes #9763
2026-03-28 09:33:25 +05:30
copilot-swe-agent[bot]
0330db0b7a
Add tests for triple/double click mouse selection behaviors; fix extension_in_progress not being cleared on selection reset
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/3ee2e09c-5400-46f6-a556-0bba0e9dcff8

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-03-27 16:59:58 +00:00
Kovid Goyal
7e5aac2e2b
Allow setting color table value to none via OSC 21 2026-03-27 20:50:28 +05:30
Jake Stewart
1a62cde212
Add option to generate 256 color palette from first 16 colors
Needs more work to test and possibly implement reporting and setting
of the nullable color table colors.

Fixes #9426
2026-03-27 20:01:14 +05:30
Kovid Goyal
88ee80b327
Cleanup previous PR
Actually respect the fallback order when finding matching shortcuts
2026-03-26 09:30:14 +05:30
Павел Мешалкин
8ffdf7d7ee feat: add per-mapping --allow-fallback for layout-independent shortcuts
Add --allow-fallback option to the map command that controls shifted
and ascii (alternate_key) fallback for individual key mappings.

For non-Latin keyboard layouts, when the current layout key is
non-ascii (codepoint > 127 and < 0xE000), the alternate_key from
the base layout is used for matching if the mapping opts in via
--allow-fallback=shifted,ascii.

Default kitty bindings use --allow-fallback=shifted,ascii so they
work out of the box with non-Latin layouts. User custom mappings
default to --allow-fallback=shifted (preserving existing shifted_key
behavior without ascii fallback).

--allow-fallback=none disables all fallback for a mapping.

Python side: parse_options_for_map() in options/utils.py handles flag
parsing, ShortcutMapping uses it in __init__. get_shortcut() filters
candidates by per-mapping allow_fallback.

Go side: ParseMap() handles --allow-fallback, KeyAction stores
AllowFallback, ShortcutTracker.Match passes it to matching.
MatchesParsedShortcut defaults to shifted,ascii for hardcoded shortcuts.

Migrated kittens (themes, command_palette, diff, choose_files) to
use ShortcutTracker with configurable map entries.

Tests added for Python (5 test methods) and Go (ParseMap + key matching).
2026-03-25 19:34:13 +03:00
copilot-swe-agent[bot]
b252524def Add tests for graphics protocol crash fixes (commits e9661f0 and 48ab623)
Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/52901924-cb01-416f-8d4c-56bc2872a3c6
2026-03-23 03:39:38 +00:00
copilot-swe-agent[bot]
d37a9fd48a
Fix marker highlighting for CJK/wide chars not at position 0
Fixes #9705
Fixes #9706
2026-03-19 15:35:14 +05:30
Kovid Goyal
83160c10c4
Cleanup previous PR 2026-03-16 17:38:14 +05:30
Kovid Goyal
30756bb819
Cleanup previous PR 2026-03-15 08:38:59 +05:30
Alexey Shurygin
827c8dd614 Address PR review feedback 2026-03-15 01:33:38 +03:00
Alexey Shurygin
b66c6c4932 Fix: Dictation does not start on double Fn key press on Mac OS 2026-03-15 01:15:05 +03:00
copilot-swe-agent[bot]
551acca0e4
Implement maximize layout action for splits layout
Fixes #9629
Fixes #9630
2026-03-09 15:27:54 +05:30
copilot-swe-agent[bot]
5638d20921
Make showing of unmapped actions a runtime cached setting
Fixes #9591
2026-03-03 15:24:26 +05:30
copilot-swe-agent[bot]
f13c8cd44d
Allow optionally showing unmapped actions in the command palette
Also highlight letters matching the search query.
Fixes #9589
2026-03-03 14:29:10 +05:30
Kovid Goyal
813f8ba7cf
Merge branch 'show_keys' of https://github.com/dmgerman/kitty 2026-03-03 09:47:41 +05:30
Kovid Goyal
ced3a98aa8
Fix failing test
num_scaled_cells calculation was incorrect. Also optimize copying from
scratch when width is unchanged.
2026-02-24 09:53:06 +05:30
Daniel M German
6fa122af11 Fix action triggering by using kitten output instead of remote control
The RC approach sent actions targeting the overlay window itself rather
than the underlying window. Switch to the standard kitten output pattern:
the Go kitten outputs the selected action definition via
KittenOutputSerializer, and handle_result in Python calls boss.combine()
with the correct target window after the overlay closes.
2026-02-22 21:12:36 -08:00
Daniel M German
33b5b0a339 Add command_palette command to display bound keys
Add a Go-based command_palette kitten that provides a searchable,
interactive overlay for browsing and triggering keyboard shortcuts
and actions.

- New Go kitten at kittens/command_palette/ with FZF fuzzy search,
  grouped/flat views, and remote control action triggering
- Python collect_keys_data() does data collection, passed via stdin
- Navigation: arrows, ctrl+j/k (vim), ctrl+n/p (emacs), page up/down
- Enter triggers the selected action via RC command
- Help text displayed in footer for selected binding
- Added Go tests (main_test.go) and Python tests (command_palette.py)
2026-02-22 20:46:47 -08:00
Kovid Goyal
8df80afa79
URL detection: Allow trailing asterisks in URLs
Fixes #9543
2026-02-23 07:54:47 +05:30
Kovid Goyal
625e984b12
Fix line-at-once selection not extending wrapped lines into scrollback
Fixes #9437
2026-01-30 20:29:33 +05:30
Kovid Goyal
be0dd00606
icat kitten: When catting multiple images display the images in input order
Fixes #9413
2026-01-24 14:16:54 +05:30
Kovid Goyal
a214097b55
Close hyperlinks more eagerly when serializing to ANSI
Fixes #9405
2026-01-23 10:11:26 +05:30
Kovid Goyal
b52a9031ca
Fix selections test failing due to pixel scroll
Note this only fixes the test, there is still the actual issue of
the selection not being rendered for the top most line if that line is
partially scrolled offscreen
2026-01-08 12:40:40 +05:30
Kovid Goyal
573bfb688a
Move parsing of colors fully into C
Uses a perfect hash function for color name lookup
2025-12-31 14:21:45 +05:30
Kovid Goyal
e14e34948e
More cleanups for color parsing
Using rounding when converting float to uint8 for more accuracy.
Fix rgb:3 and rgbi: parsing in Go code. Various other minor cleanups.
2025-12-31 09:35:09 +05:30
Kovid Goyal
7c13c04c84
Move color parsing code to C for performance 2025-12-30 21:43:57 +05:30
Kovid Goyal
62d5fcc074
Merge branch 'wide-gamut-colors' of https://github.com/jokull/kitty 2025-12-30 13:19:44 +05:30
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
Kovid Goyal
6db24b66fa
Dont rewrap text in the alternate screen buffer
Avoids flicker during live resize with no resize_debounce_time. See
https://github.com/kovidgoyal/kitty/discussions/9142 for discussion.
2025-11-26 10:29:12 +05:30
Kovid Goyal
0037e3a97d
Add parse test for CSI 14;2 t 2025-11-24 11:23:21 +05:30
Kovid Goyal
478294a335
Fix typo that caused OSC 3008 to set title rather than just be ignored
Fixes #9226
2025-11-17 12:23:10 +05:30
Kovid Goyal
e6d7e91000
Avoid using lseek() to track disk cache file write offset
It's slow and not thread safe.
We use pwrite() so it's not reliable anyway.
2025-11-17 11:16:30 +05:30
Kovid Goyal
e49d940621
kitten @ ls: Also output the neighbors for every window 2025-11-16 21:01:55 +05:30
Kovid Goyal
456fa8691a
Fix #9211 2025-11-11 09:35:55 +05:30
Wukuyon
65890de60d Fix UTF-8 overlong and special range checks in simd-string-impl.h
Modified `start_classification` in `utf8_decode_to_esc` in `simd-string-impl.h`, which now:

Rejects `0xC0`, `0xC1` and `0xF5..0xFF` lead bytes in UTF-8 subsequences.

Enforces special ranges for the second subsequence bytes after `0xE0`, `0xED`, `0xF0` and `0xF4` bytes to prevent overlong sequences, surrogates, and code points above U+10FFFF.

Accumulates UTF-8 validation errors in a single vector to avoid many conditional branches.

Worsens unicode benchmark performance by about 4%.
2025-10-23 22:37:33 -06:00
Wukuyon
295951348c Add boundary case tests for test_utf8_simd_decode
These tests were generated from Node.js and match the WHATWG Encoding Specification's behavior (substitution of maximal subparts).
2025-10-23 21:43:20 -06:00
Wukuyon
77a3fc8dd2 Swap expected/actual variables in t function in test_utf8_simd_decode
For more useful debugging.
The expected value is what the scalar decoder returns.
The actual value is what the "which" SIMD decoder returns.
2025-10-23 21:43:20 -06:00
Kovid Goyal
26ea343f95
Fix failing tests 2025-10-22 13:21:53 +05:30
Kovid Goyal
1e1a1851d0
Add support for Unicode 17
This is preliminary, all tests pass, but needs more careful review.
2025-10-18 09:59:53 +05:30
Kovid Goyal
6586780371
Merge branch 'draw-borders-when-focused' of https://github.com/jackielii/kitty 2025-10-15 08:56:02 +05:30
Kovid Goyal
dd7caaa91b
... 2025-10-15 08:09:29 +05:30
Kovid Goyal
ee9a5386b9
When doing a reset also reset termios to its initial state 2025-10-15 07:56:45 +05:30
Jackie Li
6a2ee9253b
set_options() in layout tests 2025-10-14 19:43:07 +01:00
Kovid Goyal
16d411943a
Add integration test for go atexit implementation 2025-09-30 12:37:25 +05:30
Kovid Goyal
2f991691f9
Fix test failure with fish >= 4.1
fish now requires a response to a DA1 query
2025-09-29 14:01:57 +05:30
Kovid Goyal
3d0ec1c684
Only skip invalid UTF8 tests when actually using SIMD 2025-09-15 08:59:03 +05:30
Kovid Goyal
5d9a28f7a1
Move utf8_parsing tests to simd_decode
More robust as the tests are run against all three SIMD modes, no SIMD,
128bit and 256 bit
2025-09-15 08:53:03 +05:30
Kovid Goyal
42aa5957a5
Comment out all the failing invalid UTF-8 tests 2025-09-15 08:43:58 +05:30
Wukuyon
542c425488 test_utf8_parsing: Add more tests for UTF-8 maximal subpart replacement 2025-09-14 16:50:38 -06:00
Wukuyon
346384351e test_utf8_parsing: Add comments describing each assertion 2025-09-14 16:33:53 -06:00
Alexis (Poliorcetics) Bourget
4cccf929eb
fix: when parsing python_strings options, don't fail if ' is last
Previously, if the last character was `'` parsing would fail: from `abc'`
it would produce the literal `'''abc''''`, which has one too many
unescaped single quote at the end.

This also fixes the issue for solo `'''`, where before it would produce
`''''\\'''''`, again with one too many single quote at the end.

I added tests for both cases.
2025-09-06 20:33:15 +02:00
Kovid Goyal
44b5d8f656
Dont use negative numbers in multi cursor protocol
There are apparently many parsers out there that cant handle them.
2025-08-26 21:43:37 +05:30
Kovid Goyal
da641982e2
Start work on specifying a color for extra cursors 2025-08-26 18:56:31 +05:30
Kovid Goyal
518e06cfa4
Also report -2 in query response 2025-08-25 15:30:36 +05:30
Kovid Goyal
24049a1a5a
Implement round tripping of SGR blink (5/25) 2025-08-25 12:34:38 +05:30
Kovid Goyal
bacd13d3a7
extra cursors: Add some tests for invalid input handling 2025-08-24 20:25:38 +05:30
Kovid Goyal
8f5dc42a61
Parser for multi cursor escape code 2025-08-24 20:14:14 +05:30
Kovid Goyal
e6c1597834
Start work on multiple hardware cursors 2025-08-24 20:14:14 +05:30
Kovid Goyal
337cbf1435
Add an env var that can be used to eval an expression at startup of shell
This will come in handy to implement serialization as session
with running of current foreground command.
2025-08-16 11:58:30 +05:30
Kovid Goyal
a0b58ef205
Dont allow CUB to move cursor onto previous line
Reserve this behavior for actual backspace. Fixes #8900
2025-08-14 21:49:36 +05:30
Kovid Goyal
d52f2e7981
Rewrite rendering pipeline
This was needed to fix various corner cases when doing blending of colors
in linear space. The new architecture has the same performance as the
old in the common case of opaque rendering with no UI layers or images.

In the case of only positive z-index images there is a performance
decrease as the OS Window is now rendered to a offscreen texture and
then blitted to screen. However, in the future when we move to Vulkan or
I can figure out how to get Wayland to accept buffers with colors in
linear space, this performance penalty can be removed. The performance
penalty was not significant on my system but this is highly GPU
dependent. Modern GPUs are supposedly optimised for rendering to
offscreen buffers, so we will see. The awrit project might be a good
test case.

Now either we have 1-shot rendering for the case of opaque with only ext
or all the various pieces are rendered in successive draw calls into an
offscreen buffer that is blitted to the output buffer after all drawing
is done.

Fixes #8869
2025-08-11 00:47:02 +05:30
Kovid Goyal
b0439d4183
Function to erase the last command and its output 2025-08-07 08:45:45 +05:30
Kovid Goyal
f61b15b284
Fix incorrect handling of VS16 when it causes char to wrap to next line and is part of a draw command with more characters following it
Needed to initialize full text loop state rather than just segmentation
state on wrap. Fixes #8848
2025-07-26 09:25:01 +05:30
Kovid Goyal
45b2678db1
Allow backspace to wrap cursor to previous line
Fixes #8841
2025-07-23 08:56:54 +05:30
Kovid Goyal
12c1b0cbdf
remove leftover debug prints 2025-07-20 21:45:36 +05:30
Kovid Goyal
2e92d610d5
Implement metadata based previews in choose-files 2025-07-20 09:31:17 +05:30
Kovid Goyal
fd20fd23bb
Use clean HOME and CONF and CACHE dirs when running Go tests 2025-07-09 13:29:33 +05:30
Kovid Goyal
d7c4d42f41
Fix #8794 2025-07-09 12:49:12 +05:30
Kovid Goyal
c681a999d5
Fix hyperlink id not being applied to wide cells
Fixes #8796
2025-07-09 12:14:09 +05:30
Kovid Goyal
eabddc2870
Report support for OSC52 write to clipboard in DA1
There are apparently some applications that want to only turn on OSC52
if they can be sure the terminal supports it.
https://github.com/contour-terminal/vt-extensions/blob/master/clipboard-extension.md

Seems harmless enough, though IMO the correct query mechanism for
runtime controllable settings is XTGETTCAP, but, let's be a
good citizen and co-operate. The overhead is not too large and I
have more important windmills to tilt at.

Fixes #8788
2025-07-07 08:45:58 +05:30
Kovid Goyal
75f10d140f
Fix off-by-one in code to nuke incomplete multicell chars in line
Fixes #8758
2025-06-27 11:35:18 +05:30
Jacob Komissar
9549618bc9 Escape user input in zsh integration's _ksi_preexec
Also fix a bug in one of the test assertions to make the test work.
2025-06-23 18:44:52 -04:00
Kovid Goyal
bca017fa4c
Fix #8741 2025-06-20 20:11:23 +05:30
Kovid Goyal
8e55cf7552
Fix #8731 2025-06-14 20:19:21 +05:30
Kovid Goyal
61fd8c4003
Fix #8682 2025-05-27 12:10:14 +05:30
Kovid Goyal
c861259e3b
Rename go module from kitty -> github.com/kovidgoyal/kitty
Makes the code more easily re-useable in other projects
2025-05-16 08:43:39 +05:30
Kovid Goyal
68b4c3dd6d
Fix ambiguous width and private use characters not being rendered when used with variable width text-sizing protocol escape codes 2025-05-12 05:21:51 +05:30
Kovid Goyal
1237f7667c
... 2025-05-03 10:47:03 +05:30
Kovid Goyal
7dc673e485
Add XFCE to the X11 compatibility matrix 2025-05-03 10:39:41 +05:30
Kovid Goyal
07cda6ac45
Add GNOME to the X11 compatibility matrix 2025-05-03 08:57:55 +05:30
Kovid Goyal
8d213bba04
Make test more robust against env 2025-04-30 05:50:05 +05:30
Kovid Goyal
b9326f5c94
Add some formatting to CLIParser error messages 2025-04-29 07:26:48 +05:30
Kovid Goyal
909b8747d3
Add launcher test for list style options 2025-04-28 13:55:36 +05:30
Kovid Goyal
14792aa60e
Allow partial option matches in C CLI parser as well
Matches behavior of Go parser and is nice to have
2025-04-28 12:43:09 +05:30
Kovid Goyal
15781435ae
Cleanup reading of argv from files 2025-04-28 09:54:57 +05:30
Kovid Goyal
5c9c8aa424
Add unit testing for launcher code 2025-04-28 09:25:25 +05:30
Kovid Goyal
b0ae88ada9
Wire up the codegen C cli parser 2025-04-28 09:20:11 +05:30
Kovid Goyal
1413d8fb85
Fix handling of --help and --version 2025-04-28 09:20:11 +05:30
Kovid Goyal
27c5b6aac5
Generate option parser in C for kitty CLI 2025-04-28 09:20:10 +05:30
Kovid Goyal
62699f6799
Get basic C cli parsing working 2025-04-28 09:20:10 +05:30
Kovid Goyal
3f00dc1c9e
Work on improving CLI parsing
Can now set bool values explicitly with =
Handle multi short flag args like -abc
Add unit tests for CLI parsing
Generate go code to serialize CLI options as a cmdline

TODO: Implement setting of bool vals in C and Go parsing code
TODO: Help/rst output should somehow indicate this feature
2025-04-26 09:01:54 +05:30
Kovid Goyal
2093fb1310
Fix handling of empty quoted string in shlex 2025-04-26 08:55:32 +05:30
Kovid Goyal
7bd7709685
Move parsing of macos-launch-services-cmdline into native code
Avoids expensive re-exec and simplifies various things. Much faster
for single instance usage.
2025-04-25 14:39:36 +05:30
Kovid Goyal
639ad3e8a6
Make shlex code re-useable in launcher 2025-04-25 09:35:42 +05:30
Kovid Goyal
76ac66fc8c
Implement various filesystem utility functions in C so they can be used in the launcher 2025-04-24 20:37:51 +05:30
Kovid Goyal
f0f5e53dbe
Fix failing test 2025-04-23 09:07:13 +05:30
Kovid Goyal
82e2fe82d6
Add a couple more gseg tests 2025-04-11 13:34:16 +05:30
Kovid Goyal
3f919cbc56
Specify the algorithm for splitting text into cells 2025-04-11 09:34:21 +05:30
Kovid Goyal
b32a5492c5
Add test for wrap with combining char 2025-04-11 09:34:21 +05:30
Kovid Goyal
c01a941fe7
Get the unicode grapheme seg tests passing on screen, with minimal modification
We ignore tests including ACII control codes and we modify the results
when there are grapheme breaks before zero width characters.
2025-04-11 09:34:21 +05:30
Kovid Goyal
203e9f6c58
Port wcswidth to use grapheme segmentation 2025-04-11 09:34:21 +05:30
Kovid Goyal
2cad589f1c
Add tests for combining at screen edge 2025-04-11 09:34:21 +05:30
Kovid Goyal
4c2bd8ffb1
Implement zero width roundtripped chars in multicell segmentation as well 2025-04-11 09:34:21 +05:30
Kovid Goyal
f5e8de2e4f
Implement grapheme segmentation in the terminal layer 2025-04-11 09:34:21 +05:30
Kovid Goyal
d1938cb060
Fix failing test 2025-04-08 13:07:59 +05:30
Kovid Goyal
7e3e567916
Dont use subTest as it doesnt work with retry_on_failure 2025-04-07 05:22:15 +05:30
Kovid Goyal
f578e8d25b
Cleanup various test related things 2025-04-07 04:41:19 +05:30
Your Name
33167f2057 Change mouse_hide_wait to struct, and change mouse_show_* options to optional parameters for struct. mouse_show_* renamed to mouse_unhide_* 2025-04-04 11:22:56 +00:00
Your Name
464446e388 Prevent mouse cursor from showing on short, unintentional flicks 2025-04-04 04:33:47 +00:00
Kovid Goyal
66856e7b52
Use a multi-stage lookup table for grapheme segmentation 2025-03-31 21:51:28 +05:30
Arvin Verain
6d75f7cff4
test: Add method to easily set last_visited attributes 2025-03-28 22:38:19 +08:00
Arvin Verain
07f30122e6
test: Add more tests for cmd paging edge cases 2025-03-28 22:38:18 +08:00
Kovid Goyal
9e1601a9b5
Nicer way to include grapheme test data in Go tests 2025-03-27 03:20:27 +05:30
Kovid Goyal
f058c597ae
Dont rely on hard links 2025-03-26 21:59:24 +05:30