mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Add a new shortcut to pass the current selection to an external program
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
Changelog
|
Changelog
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
kitty is a modern, hackable, OpenGL based terminal emulator.
|
||||||
|
|
||||||
version 0.4.0 [future]
|
version 0.4.0 [future]
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
@@ -31,3 +33,5 @@ version 0.4.0 [future]
|
|||||||
the background color, for enhanced visibility.
|
the background color, for enhanced visibility.
|
||||||
|
|
||||||
- Allow combining multiple independent actions into a single shortcut
|
- 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')
|
KeyAction = namedtuple('KeyAction', 'func args')
|
||||||
|
shlex_actions = {'pass_selection_to_program'}
|
||||||
|
|
||||||
|
|
||||||
def parse_key_action(action):
|
def parse_key_action(action):
|
||||||
@@ -106,6 +107,8 @@ def parse_key_action(action):
|
|||||||
sep, rest = rest.split(' ', 1)
|
sep, rest = rest.split(' ', 1)
|
||||||
parts = re.split(r'\s*' + re.escape(sep) + r'\s*', rest)
|
parts = re.split(r'\s*' + re.escape(sep) + r'\s*', rest)
|
||||||
args = tuple(map(parse_key_action, filter(None, parts)))
|
args = tuple(map(parse_key_action, filter(None, parts)))
|
||||||
|
elif func in shlex_actions:
|
||||||
|
args = shlex.split(rest)
|
||||||
return KeyAction(func, args)
|
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+s paste_from_selection
|
||||||
map ctrl+shift+c copy_to_clipboard
|
map ctrl+shift+c copy_to_clipboard
|
||||||
map shift+insert paste_from_selection
|
map shift+insert paste_from_selection
|
||||||
|
map ctrl+shift+o pass_selection_to_program
|
||||||
|
|
||||||
# Scrolling
|
# Scrolling
|
||||||
map ctrl+shift+up scroll_line_up
|
map ctrl+shift+up scroll_line_up
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from .fast_data_types import (
|
|||||||
)
|
)
|
||||||
from .rgb import to_color
|
from .rgb import to_color
|
||||||
from .terminfo import get_capabilities
|
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):
|
class DynamicColor(Enum):
|
||||||
@@ -256,6 +256,14 @@ class Window:
|
|||||||
if text:
|
if text:
|
||||||
get_boss().glfw_window.set_clipboard_string(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):
|
def scroll_line_up(self):
|
||||||
if self.screen.is_main_linebuf():
|
if self.screen.is_main_linebuf():
|
||||||
self.screen.scroll(SCROLL_LINE, True)
|
self.screen.scroll(SCROLL_LINE, True)
|
||||||
|
|||||||
Reference in New Issue
Block a user