Replies: 2 comments 1 reply
-
You can use a custom kitten to implement similar functionality. Here is an example of using hints kitten as the text selection UI. dynamic_abbrev_hints.py import string
from typing import Any, Dict, List
from kitty.boss import Boss
from kittens.tui.handler import result_handler
def main(args: List[str]) -> None:
pass
@result_handler(no_ui=True)
def handle_result(args: List[str], data: str, target_window_id: int, boss: Boss) -> None:
w = boss.active_window
if w is None:
return
s = w.screen
if s.cursor.x == 0:
return
line = str(s.visual_line(s.cursor.y))
chars = string.ascii_uppercase + string.ascii_lowercase + string.digits + '-_.'
x = s.cursor.x
while x > 0 and line[x - 1] in chars:
x -= 1
if x == s.cursor.x:
return
word = line[x:s.cursor.x]
def done(data: Dict[str, Any], target_window_id: int, self: Boss) -> None:
if data and data.get('match'):
m = data['match'][0]
w = boss.window_id_map.get(target_window_id)
if w is not None:
w.write_to_child(m[len(word):])
boss.run_kitten_with_metadata('hints', args=('--type', 'regex', '--regex', word.replace('.', '\.') + '[a-zA-Z0-9-_.]*'), custom_callback=done) kitty -o 'map f1 kitten dynamic_abbrev_hints.py' Type some text and press F1. After selecting the matching text, the remaining characters will be filled in. https://sw.kovidgoyal.net/kitty/kittens/custom/ The above is just one way to do it, but you can actually just use the |
Beta Was this translation helpful? Give feedback.
-
Feel free to do so, it should be a pretty simple script using kitty
remote control features or by writing a kitten
|
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm using Kitty as my everyday terminal.
Recently, I've found a much needed capability in xterm :
dabbrev-expand()
that could expand the word before the cursor by searching in the preceding text on the screen.Do you think that such a feature could be added to kitty ?
best regards,
pfb
Beta Was this translation helpful? Give feedback.
All reactions