mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 15:04:50 +02:00
Add modifier-based hyperlink target display
This commit is contained in:
@@ -714,11 +714,15 @@ a double backslash.
|
||||
'''
|
||||
)
|
||||
|
||||
opt('show_hyperlink_targets', 'no',
|
||||
option_type='to_bool', ctype='bool',
|
||||
opt('show_hyperlink_targets', 'never', choices=('ctrl', 'cmd', 'shift', 'always', 'never'),
|
||||
ctype='show_hyperlink_targets',
|
||||
long_text='''
|
||||
When the mouse hovers over a terminal hyperlink, show the actual URL that will
|
||||
be activated when the hyperlink is clicked.
|
||||
be activated when the hyperlink is clicked. Set to :code:`ctrl`, :code:`cmd` or
|
||||
:code:`shift` to show only while the corresponding modifier key is pressed
|
||||
(:kbd:`Ctrl`, :kbd:`Super` (macOS :kbd:`Cmd`), :kbd:`Shift`). If multiple modifiers
|
||||
are pressed, the URL is shown as long as the configured modifier is among them.
|
||||
:code:`always` to always show, or :code:`never` to never show.
|
||||
''')
|
||||
|
||||
|
||||
|
||||
11
kitty/options/parse.py
generated
11
kitty/options/parse.py
generated
@@ -1290,7 +1290,16 @@ class Parser:
|
||||
ans['shell_integration'] = shell_integration(val)
|
||||
|
||||
def show_hyperlink_targets(self, val: str, ans: dict[str, typing.Any]) -> None:
|
||||
ans['show_hyperlink_targets'] = to_bool(val)
|
||||
val = val.lower()
|
||||
if val == 'yes':
|
||||
val = 'always'
|
||||
elif val == 'no':
|
||||
val = 'never'
|
||||
if val not in self.choices_for_show_hyperlink_targets:
|
||||
raise ValueError(f"The value {val} is not a valid choice for show_hyperlink_targets")
|
||||
ans["show_hyperlink_targets"] = val
|
||||
|
||||
choices_for_show_hyperlink_targets = frozenset(('ctrl', 'cmd', 'shift', 'always', 'never'))
|
||||
|
||||
def single_window_margin_width(self, val: str, ans: dict[str, typing.Any]) -> None:
|
||||
ans['single_window_margin_width'] = optional_edge_width(val)
|
||||
|
||||
2
kitty/options/to-c-generated.h
generated
2
kitty/options/to-c-generated.h
generated
@@ -605,7 +605,7 @@ convert_from_opts_url_excluded_characters(PyObject *py_opts, Options *opts) {
|
||||
|
||||
static void
|
||||
convert_from_python_show_hyperlink_targets(PyObject *val, Options *opts) {
|
||||
opts->show_hyperlink_targets = PyObject_IsTrue(val);
|
||||
opts->show_hyperlink_targets = show_hyperlink_targets(val);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -98,6 +98,17 @@ underline_hyperlinks(PyObject *x) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline ShowHyperlinkTargets
|
||||
show_hyperlink_targets(PyObject *x) {
|
||||
const char *in = PyUnicode_AsUTF8(x);
|
||||
if (!in) return SHOW_HYPERLINK_TARGETS_NEVER;
|
||||
if (strcmp(in, "always") == 0) return SHOW_HYPERLINK_TARGETS_ALWAYS;
|
||||
if (strcmp(in, "ctrl") == 0) return SHOW_HYPERLINK_TARGETS_CTRL;
|
||||
if (strcmp(in, "shift") == 0) return SHOW_HYPERLINK_TARGETS_SHIFT;
|
||||
if (strcmp(in, "cmd") == 0) return SHOW_HYPERLINK_TARGETS_CMD;
|
||||
return SHOW_HYPERLINK_TARGETS_NEVER;
|
||||
}
|
||||
|
||||
static inline BackgroundImageLayout
|
||||
bglayout(PyObject *layout_name) {
|
||||
const char *name = PyUnicode_AsUTF8(layout_name);
|
||||
|
||||
5
kitty/options/types.py
generated
5
kitty/options/types.py
generated
@@ -28,6 +28,7 @@ choices_for_macos_show_window_title_in = typing.Literal['all', 'menubar', 'none'
|
||||
choices_for_placement_strategy = typing.Literal['top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right']
|
||||
choices_for_pointer_shape_when_grabbed = choices_for_default_pointer_shape
|
||||
choices_for_scrollbar = typing.Literal['scrolled', 'always', 'never', 'hovered', 'scrolled-and-hovered']
|
||||
choices_for_show_hyperlink_targets = typing.Literal['ctrl', 'cmd', 'shift', 'always', 'never']
|
||||
choices_for_strip_trailing_spaces = typing.Literal['always', 'never', 'smart']
|
||||
choices_for_tab_bar_align = typing.Literal['left', 'center', 'right']
|
||||
choices_for_tab_bar_style = typing.Literal['fade', 'hidden', 'powerline', 'separator', 'slant', 'custom']
|
||||
@@ -646,7 +647,7 @@ class Options:
|
||||
selection_foreground: kitty.fast_data_types.Color | None = Color(0, 0, 0)
|
||||
shell: str = '.'
|
||||
shell_integration: frozenset[str] = frozenset({'enabled'})
|
||||
show_hyperlink_targets: bool = False
|
||||
show_hyperlink_targets: choices_for_show_hyperlink_targets = 'never'
|
||||
single_window_margin_width: FloatEdges = FloatEdges(left=-1.0, top=-1.0, right=-1.0, bottom=-1.0)
|
||||
single_window_padding_width: FloatEdges = FloatEdges(left=-1.0, top=-1.0, right=-1.0, bottom=-1.0)
|
||||
startup_session: str | None = None
|
||||
@@ -1149,4 +1150,4 @@ special_colors = frozenset({
|
||||
})
|
||||
|
||||
|
||||
secret_options = ('remote_control_password', 'file_transfer_confirmation_bypass')
|
||||
secret_options = ('remote_control_password', 'file_transfer_confirmation_bypass')
|
||||
|
||||
Reference in New Issue
Block a user