Commit graph

194 commits

Author SHA1 Message Date
Kovid Goyal
e4988b522d
hints: Migrate from regexp2 v1 to v2
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Use Capture.ByteRange() from v2 instead of a hand-rolled rune to byte
offset mapping. The old mapping required capture offsets to be monotonic
across matches, so a capture inside a lookaround overlapping a later match
in non-ASCII text caused all matches to be silently dropped.

Also propagate match errors instead of discarding them. Drops the v1
dependency, v2 was already pulled in by chroma.
2026-11-07 05:54:16 +05:30
Kovid Goyal
81535d9b33
hints: Cleanup previous PR
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
- Guard against the quotes post processor producing start > end for a match
  consisting of just a single ASCII quote
- Use char_before() in the URL trailing punctuation loop and avoid computing
  the closing bracket twice
- Add PR reference to changelog entry
2026-10-24 06:36:26 +05:30
xucian
f9b2fbb3b1 hints: Fix Unicode quotes not being removed from paths and URLs
The post-processors index the text by byte, so when looking at the
character before a position they decoded only the last byte of
multi-byte quotes such as ‘’ and “” and never matched them. URLs kept
the closing quote and paths kept both quotes. When the closing quote was
just outside the match, the start was also advanced by a single byte,
splitting the opening quote and producing invalid UTF-8, for example,
for the file name in wget's "Saving to: ‘index.html’".

This worked before the hints kitten was ported to Go.
2026-10-23 23:40:40 +03:00
Kovid Goyal
0762c21c44
Cleanup previous PR
Use Unicode word boundaries with the stdlib regexp engine

Go's regexp only treats ASCII characters as word characters for \b, while
regexp2 uses Unicode ones, so switching the builtin path pattern to the
stdlib engine changed which paths were marked next to non-ASCII text, for
example config.yaml文件 marked config.yaml. Match against a proxy of the
text in which every non-ASCII rune is replaced by a single ASCII byte that
is a word character iff the rune is one, then map the offsets back.
2026-09-28 06:55:24 +05:30
Artem Lytkin
0ceca31ef1 hints kitten: Use Go's stdlib regexp for the builtin patterns
regexp2 backtracks on the path pattern, retrying it at every position
of a long line that has no spaces, so the path and linenum types took
seconds on a screen full of such text (about 36s for a 380x100 window
of hex). The builtin patterns dont need lookarounds, so use the linear
time stdlib engine for them. User supplied --regex patterns stay on
regexp2 so lookarounds keep working (#6265).
2026-09-27 00:09:06 +03:00
Hassan Raza
e31a5e4e07
Fix empty hints selection handling 2026-08-28 11:49:17 +05:00
Hassan Raza
1229f19f6d
Restore hints named-group program arguments 2026-08-27 21:55:56 +05:00
Kovid Goyal
7f0b072f0d
autoformat 2026-08-05 05:32:56 +05:30
Hector Tellez
501f28acdf Fixes bug where hints starting with the first alphabet's character are _almost never_ generated.
* Switches to "positional notation" to fix the bug.
* Consolidates `encode_hint` and `generate_prefix_free_hint` into `encode_hint`.
* Moves prefix_free_hints.go to hints_generator.go; `encode_hint` and `decode_hint` were moved here too.
* The "prefix-free" logic was made 0-index based instead of 1-index based for two reasons:
  1. To simplify 1-off discrepancies.
  2. To keep backwards compatibility with the old usage of `encode_hint`.
* Slight perfomance improvement added by reusing the runt-to-index map instead of rebuilding for each call to `decode_hint`.
* Unit tests added; for all new logic and old affected logic.

Fixes #10231
2026-07-07 02:07:51 -07:00
Kovid Goyal
facec19834
Cleanup previous PR 2026-07-04 12:52:34 +05:30
Kovid Goyal
c64ff282d0
Merge branch 'master' of https://github.com/tellezhector/kitty 2026-07-04 12:41:38 +05:30
Kovid Goyal
a65b4c70a7
Migrate type checker to ty
Much faster than mypy. Matches usage of ruff from same developer.
2026-07-04 09:18:00 +05:30
Hector Tellez
5d1215b11d Implements option to generate prefix-free hints
- Declares --prefix-free CLI flag in main.py.
- Implements dynamic index offset shifting in marks.go to prevent
  generating hints that prefix other hints.
- Integrates prefix-free encoding in main.go.
- Includes tests.

Implements #10195
2026-07-01 09:24:30 -07:00
gogongxt
56f276580f Fix hints kitten breaking multi-byte UTF-8 characters when overlaying hint labels
In highlight_mark(), mark_text was sliced using byte-based indexing
(mark_text[:len(hint)] and mark_text[len(hint):]). Since len(hint)
equals the rune count (hint is always ASCII), but len(mark_text) is a
byte count, this could slice in the middle of a multi-byte UTF-8
sequence (e.g. CJK characters), producing an invalid byte sequence
rendered as the Unicode replacement character (�).

Fix by converting mark_text to []rune first, then slicing at rune
boundaries. The hint is ASCII so len(hint) == rune count, requiring
no conversion on the hint side.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 17:09:42 +08:00
Kevin Lui
be7a010b9c hints: Fix trailing punctuation being included in detected URLs 2026-04-07 22:57:36 -07:00
Jack Duvall
c48111d92c Highlight full extent of hint matches, not just the prefix label
Add --hints-text-background-color option (default: auto) that can apply
a background color to the matched text after the hint label. This makes
it more clear exactly which text each hint covers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 11:23:30 -04:00
Carl Lei
505a0e15cd kitten/hints/marks support for IPv6 addresses ending in ::
IPv6 addresses can end in zeros, and for example ifconfig.me is at
2600:1901:0:b2bd::.
2025-11-27 09:34:12 +08:00
Kovid Goyal
37da04aad6
choose files: Add default mappings to choose a file and insert it into the terminal 2025-11-23 11:41:21 +05:30
Kovid Goyal
6f588a0c29
run modernize 2025-11-11 17:09:37 +05:30
alex-huff
a1e63ee87c hints: make default regex ignore trailing whitespace 2025-09-28 11:54:44 -05:00
Kovid Goyal
7ff25fd77c
Add an extra linenum-action so that the callback can use remote control without needing to turn it on globally 2025-08-29 17:13:56 +05:30
Kovid Goyal
5faa7bda5d
hints kitten: Preserve line breaks when the hint is over a line break
Fixes #8674
2025-05-24 14:09:27 +05:30
Kovid Goyal
8e720cc1da
... 2025-05-24 13:25:22 +05:30
Kovid Goyal
54395da696
... 2025-05-24 09:23:05 +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
d548a6fcf4
rename typing module to avoid conflicts with stdlib typing 2025-04-28 09:20:10 +05:30
Kovid Goyal
96d5c9c7c6
A new option to clear selections when they no longer reflect the contents of the clipboard 2025-03-12 11:41:27 +05:30
Kovid Goyal
da1626090a
Update codebase to Python 3.10 using pyupgrade 2025-02-03 10:56:50 +05:30
Kovid Goyal
8931062a70
hints kitten: Workaround for some broken light color themes that make the hints text color too low contrast to read
Fixes #7330
2025-01-17 20:22:10 +05:30
Kovid Goyal
2d02ff1c5f
Implement using effective kitty config options for kittens
Also centralise reading of kitty options
2025-01-05 20:16:43 +05:30
Kovid Goyal
9d48fa9126
hints/unicode_input kittens: Do not lose keypresses that are sent very rapidly via an automation tool immediately after the kitten is launched
We now buffer the key events until the kitten tells us it is ready.
Without this the key presses are delivered to the underlying window
as the kitten's overlay window was not being focused until the kitten
set the ready message.

Fixes #7089
2024-12-12 13:11:12 +05:30
Kovid Goyal
405f5ce148
Use stdlib maps/slices 2024-06-24 07:54:13 +05:30
Kovid Goyal
8c1e365eb5
hints kitten: Allow clicking on matched text to select it in addition to typing the hint 2024-05-14 15:22:03 +05:30
Kovid Goyal
5e125c35d1
hints kitten: Report the pattern used when no matches are found 2024-04-20 05:14:03 +05:30
Kovid Goyal
c3c99113c7
hints kitten: Use default editor rather than hardcoding vim to open file at specific line
Fixes #7186
2024-03-04 21:49:06 +05:30
Kovid Goyal
a5f3142514
hints kitten: The option to set the text color for hints now allows arbitrary colors
Fixes #7150
2024-02-25 10:02:38 +05:30
Kovid Goyal
bc3c9ce2fa
Fix #7100 2024-02-05 20:48:49 +05:30
Kovid Goyal
9bea8bb5bc
remove no longer needed code 2024-02-05 13:54:22 +05:30
Kovid Goyal
8cc2cad4d9
Use list of legal chars in URL from the WHATWG standard
Notably this excludes some ASCII chars: <>{}[]`|
See https://url.spec.whatwg.org/#url-code-points

Fixes #7095
2024-02-05 13:27:22 +05:30
Kovid Goyal
77292a16d6
Make shebangs consistent
Follow PEP 0394 and use /usr/bin/env python so that the python in the
users venv is respected. Not that the kitty python files are meant to be
executed standalone anyway, but, whatever.

Fixes #6810
2023-11-11 08:32:05 +05:30
Kovid Goyal
dc6edf9191
Improve the docs for how to match multi-line hints
See #6692
2023-10-17 15:23:58 +05:30
Kovid Goyal
70a588cb36
... 2023-10-17 15:23:43 +05:30
Kovid Goyal
0a2f164062
Change kitty +kitten -> kitten in docs
All kittens except for the broadcast and panel kittens have now been
ported to Go and so can be run with just kitten rather than kitty
+kitten. So update the docs to use this canonical form for launching
kittens
2023-09-21 12:25:02 +05:30
Kovid Goyal
4f72bb9894
Replace utils.Once with stdlib sync.OnceValue 2023-08-09 12:08:42 +05:30
Kovid Goyal
49ea26968c
Bump go version to 1.21
Allows us to use the much faster builtin min/max functions
for two variable min/max
2023-08-09 11:58:16 +05:30
Kovid Goyal
8670ede032
DRYer 2023-06-29 07:39:42 +05:30
Kovid Goyal
da1276d84a
Correct the naming of the window arg to call_remote_control 2023-06-10 09:47:37 +05:30
Kovid Goyal
0873e3ea09
... 2023-05-31 07:22:49 +05:30
Kovid Goyal
9bbb2a9ef4
Fix #6315 2023-05-31 07:08:55 +05:30
Kovid Goyal
e59e42a6c2
simplify API of utils.Once 2023-05-26 22:42:07 +05:30