Add a new shortcut to pass the current selection to an external program
This commit is contained in:
parent
f947c2eecb
commit
227d21184a
@ -1,6 +1,8 @@
|
||||
Changelog
|
||||
==============
|
||||
|
||||
kitty is a modern, hackable, OpenGL based terminal emulator.
|
||||
|
||||
version 0.4.0 [future]
|
||||
-----------------------
|
||||
|
||||
@ -31,3 +33,5 @@ version 0.4.0 [future]
|
||||
the background color, for enhanced visibility.
|
||||
|
||||
- Allow combining multiple independent actions into a single shortcut
|
||||
|
||||
- Add a new shortcut to pass the current selection to an external program
|
||||
|
||||
@ -94,6 +94,7 @@ def parse_shortcut(sc):
|
||||
|
||||
|
||||
KeyAction = namedtuple('KeyAction', 'func args')
|
||||
shlex_actions = {'pass_selection_to_program'}
|
||||
|
||||
|
||||
def parse_key_action(action):
|
||||
@ -106,6 +107,8 @@ def parse_key_action(action):
|
||||
sep, rest = rest.split(' ', 1)
|
||||
parts = re.split(r'\s*' + re.escape(sep) + r'\s*', rest)
|
||||
args = tuple(map(parse_key_action, filter(None, parts)))
|
||||
elif func in shlex_actions:
|
||||
args = shlex.split(rest)
|
||||
return KeyAction(func, args)
|
||||
|
||||
|
||||
|
||||
@ -218,6 +218,7 @@ map ctrl+shift+v paste_from_clipboard
|
||||
map ctrl+shift+s paste_from_selection
|
||||
map ctrl+shift+c copy_to_clipboard
|
||||
map shift+insert paste_from_selection
|
||||
map ctrl+shift+o pass_selection_to_program
|
||||
|
||||
# Scrolling
|
||||
map ctrl+shift+up scroll_line_up
|
||||
|
||||
@ -23,7 +23,7 @@ from .fast_data_types import (
|
||||
)
|
||||
from .rgb import to_color
|
||||
from .terminfo import get_capabilities
|
||||
from .utils import color_as_int, load_shaders, parse_color_set, sanitize_title
|
||||
from .utils import color_as_int, load_shaders, parse_color_set, sanitize_title, open_url, open_cmd
|
||||
|
||||
|
||||
class DynamicColor(Enum):
|
||||
@ -256,6 +256,14 @@ class Window:
|
||||
if text:
|
||||
get_boss().glfw_window.set_clipboard_string(text)
|
||||
|
||||
def pass_selection_to_program(self, *args):
|
||||
text = self.text_for_selection()
|
||||
if text:
|
||||
if args:
|
||||
open_cmd(args, text)
|
||||
else:
|
||||
open_url(text)
|
||||
|
||||
def scroll_line_up(self):
|
||||
if self.screen.is_main_linebuf():
|
||||
self.screen.scroll(SCROLL_LINE, True)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user