def handle_result(args, result, target_window_id, boss): w = boss.window_id_map.get(target_window_id) tab = boss.active_tab if w is None: return if len(args) > 4: if not re.search(args[4], w.title): boss.active_tab.neighboring_window(args[2]) return else: # check the first word of the first foreground process foreground_process = w.child.foreground_processes[0]['cmdline'][0] if not re.search("n?vim", foreground_process, re.I): boss.active_tab.neighboring_window(args[2]) return mods, key, is_text = ku.parse_kittens_shortcut(args[3]) extended = w.screen.extended_keyboard for action in actions(extended): sequence = ( ('\x1b_{}\x1b\\' if extended else '{}') .format( keys.key_to_bytes( getattr(keys.defines, 'GLFW_KEY_{}'.format(key.upper())), w.screen.cursor_key_mode, extended, convert_mods(mods), action) .decode('ascii'))) print(repr(sequence)) w.write_to_child(sequence)
def handle_result(args, result, target_window_id, boss): w = boss.window_id_map.get(target_window_id) tab = boss.active_tab if w is None: return if len(args) > 4: if not re.search(args[4], w.title): getattr(tab, args[1])(args[2]) return else: if not re.search("n?vim", w.title): getattr(tab, args[1])(args[2]) return mods, key, is_text = ku.parse_kittens_shortcut(args[3]) if is_text: w.send_text(key) return extended = w.screen.extended_keyboard for action in actions(extended): sequence = (('\x1b_{}\x1b\\' if extended else '{}').format( keys.key_to_bytes(getattr(keys.defines, 'GLFW_KEY_{}'.format(key)), w.screen.cursor_key_mode, extended, mods, action).decode('ascii'))) w.write_to_child(sequence)
def handle_result(args, answer, target_window_id, boss): _kitten = args[0] action_if_tabs = ' '.join(args[1:-1]) if_no_tabs = args[-1] tm = boss.active_tab_manager if tm is None: return if len(tm.tabs) > 1: boss.dispatch_action(parse_key_action(action_if_tabs)) return w = boss.window_id_map.get(target_window_id) mods, key, is_text = parse_kittens_shortcut(if_no_tabs) if is_text: w.send_text(key) return extended = w.screen.extended_keyboard for action in _actions(extended): sequence = (('\x1b_{}\x1b\\' if extended else '{}').format( keys.key_to_bytes(getattr(keys.defines, 'GLFW_KEY_{}'.format(key)), w.screen.cursor_key_mode, extended, _mods_to_glfw(mods), action).decode('ascii'))) w.write_to_child(sequence)
def handle_result(args, result, target_window_id, boss): w = boss.window_id_map.get(target_window_id) tab = boss.active_tab if w is None: return # if w.screen.is_main_linebuf(): # getattr(tab, args[1])(args[2]) # return mods, key, is_text = ku.parse_kittens_shortcut(args[1]) if is_text: w.send_text(key) return
def pass_key(key_combination: str, w): """ pass key_combination to the kitty window w. Args: key_combination (str): keypress to pass. e.g. ctrl-j w (kitty window): window to pass the keys """ mods, key, is_text = ku.parse_kittens_shortcut(key_combination) extended = w.screen.extended_keyboard for action in actions(extended): sequence = (('\x1b_{}\x1b\\' if extended else '{}').format( keys.key_to_bytes( getattr(keys.defines, 'GLFW_KEY_{}'.format(key.upper())), w.screen.cursor_key_mode, extended, convert_mods(mods), action).decode('ascii'))) print(repr(sequence)) w.write_to_child(sequence)
def handle_result(args, result, target_window_id, boss): w = boss.window_id_map.get(target_window_id) tab = boss.active_tab if w is None: return if w.screen.is_main_linebuf(): getattr(tab, args[1])(args[2]) return mods, key, is_text = ku.parse_kittens_shortcut(args[3]) control_characters = { 'h': '\x08', 'j': '\x0A', 'k': '\x0B', 'l': '\x0C', } w.send_text('application,normal', control_characters[key])
def handle_result(args, result, target_window_id, boss): w = boss.window_id_map.get(target_window_id) tab = boss.active_tab if w is None: return title =w.title.strip() if w.screen.is_main_linebuf() or (w.screen.is_using_alternate_linebuf() and (not title.startswith("nvim") and not title.startswith("vi"))) or ("localhost" in w.title.strip()): getattr(tab, args[1])(args[2]) return print("2---------------------------------------------") # vim and kitty interactive move mods, key, is_text = ku.parse_kittens_shortcut(args[3]) # print(keys) # print(mods) # print(is_text) if is_text: w.send_text(key) return
def handle_result(args, result, target_window_id, boss): w = boss.window_id_map.get(target_window_id) if w is None: return if w.screen.is_main_linebuf(): getattr(w, args[1])() return mods, key, is_text = ku.parse_kittens_shortcut(args[2]) if is_text: w.send_text(key) return extended = w.screen.extended_keyboard for action in actions(extended): sequence = (('\x1b_{}\x1b\\' if extended else '{}').format( keys.key_to_bytes(getattr(keys.defines, 'GLFW_KEY_{}'.format(key)), w.screen.cursor_key_mode, extended, mods, action).decode('ascii'))) w.write_to_child(sequence)