Implement URL clicking handler
This commit is contained in:
parent
920151a460
commit
e944945b7a
@ -1153,3 +1153,7 @@ def spawn(
|
||||
|
||||
def set_window_padding(os_window_id: int, tab_id: int, window_id: int, left: int, top: int, right: int, bottom: int) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def click_mouse_url(os_window_id: int, tab_id: int, window_id: int) -> None:
|
||||
pass
|
||||
|
||||
@ -472,8 +472,8 @@ HANDLER(add_click) {
|
||||
#undef N
|
||||
}
|
||||
|
||||
static inline void
|
||||
open_url(Window *w) {
|
||||
void
|
||||
mouse_open_url(Window *w) {
|
||||
Screen *screen = w->render_data.screen;
|
||||
detect_url(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y);
|
||||
screen_open_url(screen);
|
||||
|
||||
@ -1156,8 +1156,16 @@ pycreate_mock_window(PyObject *self UNUSED, PyObject *args) {
|
||||
return ans;
|
||||
}
|
||||
|
||||
static inline void
|
||||
click_mouse_url(id_type os_window_id, id_type tab_id, id_type window_id) {
|
||||
WITH_WINDOW(os_window_id, tab_id, window_id);
|
||||
mouse_open_url(window);
|
||||
END_WITH_WINDOW;
|
||||
}
|
||||
|
||||
THREE_ID_OBJ(update_window_title)
|
||||
THREE_ID(remove_window)
|
||||
THREE_ID(click_mouse_url)
|
||||
THREE_ID(detach_window)
|
||||
THREE_ID(attach_window)
|
||||
PYWRAP1(resolve_key_mods) { int mods; PA("ii", &kitty_mod, &mods); return PyLong_FromLong(resolve_mods(mods)); }
|
||||
@ -1177,6 +1185,7 @@ static PyMethodDef module_methods[] = {
|
||||
MW(current_os_window, METH_NOARGS),
|
||||
MW(next_window_id, METH_NOARGS),
|
||||
MW(set_options, METH_VARARGS),
|
||||
MW(click_mouse_url, METH_VARARGS),
|
||||
MW(set_in_sequence_mode, METH_O),
|
||||
MW(resolve_key_mods, METH_VARARGS),
|
||||
MW(handle_for_window_id, METH_VARARGS),
|
||||
|
||||
@ -292,3 +292,4 @@ void set_os_window_title_from_window(Window *w, OSWindow *os_window);
|
||||
void update_os_window_title(OSWindow *os_window);
|
||||
void fake_scroll(Window *w, int amount, bool upwards);
|
||||
Window* window_for_window_id(id_type kitty_window_id);
|
||||
void mouse_open_url(Window *w);
|
||||
|
||||
@ -26,10 +26,11 @@ from .fast_data_types import (
|
||||
GRAPHICS_ALPHA_MASK_PROGRAM, GRAPHICS_PREMULT_PROGRAM, GRAPHICS_PROGRAM,
|
||||
MARK, MARK_MASK, OSC, REVERSE, SCROLL_FULL, SCROLL_LINE, SCROLL_PAGE,
|
||||
STRIKETHROUGH, TINT_PROGRAM, KeyEvent, Screen, add_timer, add_window,
|
||||
cell_size_for_window, compile_program, encode_key_for_tty, get_boss,
|
||||
get_clipboard_string, init_cell_program, pt_to_px, set_clipboard_string,
|
||||
set_titlebar_color, set_window_padding, set_window_render_data,
|
||||
update_window_title, update_window_visibility, viewport_for_window
|
||||
cell_size_for_window, click_mouse_url, compile_program, encode_key_for_tty,
|
||||
get_boss, get_clipboard_string, init_cell_program, pt_to_px,
|
||||
set_clipboard_string, set_titlebar_color, set_window_padding,
|
||||
set_window_render_data, update_window_title, update_window_visibility,
|
||||
viewport_for_window
|
||||
)
|
||||
from .keys import keyboard_mode_name
|
||||
from .notify import NotificationCommand, handle_notification_cmd
|
||||
@ -794,6 +795,11 @@ class Window:
|
||||
self.title_stack.append(self.child_title)
|
||||
# }}}
|
||||
|
||||
# mouse actions {{{
|
||||
def mouse_click_url(self) -> bool:
|
||||
click_mouse_url(self.os_window_id, self.tab_id, self.id)
|
||||
# }}}
|
||||
|
||||
def text_for_selection(self) -> str:
|
||||
lines = self.screen.text_for_selection()
|
||||
if self.opts.strip_trailing_spaces == 'always' or (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user