-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from mochouaaaaa/master
fix(mux): Unable to use its own operations in neovim
- Loading branch information
Showing
2 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,38 @@ | ||
from kitty.key_encoding import KeyEvent, parse_shortcut | ||
from kittens.tui.handler import result_handler | ||
|
||
|
||
def main(): | ||
pass | ||
|
||
|
||
def encode_key_mapping(window, key_mapping): | ||
mods, key = parse_shortcut(key_mapping) | ||
event = KeyEvent( | ||
mods=mods, | ||
key=key, | ||
shift=bool(mods & 1), | ||
alt=bool(mods & 2), | ||
ctrl=bool(mods & 4), | ||
super=bool(mods & 8), | ||
hyper=bool(mods & 16), | ||
meta=bool(mods & 32), | ||
).as_window_system_event() | ||
|
||
return window.encoded_key(event) | ||
|
||
|
||
@result_handler(no_ui=True) | ||
def handle_result(args, result, target_window_id, boss): | ||
boss.active_tab.neighboring_window(args[1]) | ||
window = boss.window_id_map.get(target_window_id) | ||
|
||
keymap = args[2] | ||
|
||
handle_result.no_ui = True | ||
cmd = window.child.foreground_cmdline[0] | ||
if cmd == 'nvim': | ||
encoded = encode_key_mapping(window, keymap) | ||
window.write_to_child(encoded) | ||
elif cmd == 'tmux': | ||
pass | ||
else: | ||
boss.active_tab.neighboring_window(args[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters