mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 06:54:58 +02:00
hints kitten: Allow clicking on matched text to select it in addition to typing the hint
This commit is contained in:
@@ -21,6 +21,7 @@ from kitty.typing import (
|
||||
MouseEvent,
|
||||
ScreenSize,
|
||||
TermManagerType,
|
||||
WindowType,
|
||||
)
|
||||
|
||||
from .operations import MouseTracking, pending_update
|
||||
@@ -29,6 +30,9 @@ if TYPE_CHECKING:
|
||||
from kitty.file_transmission import FileTransmissionCommand
|
||||
|
||||
|
||||
OpenUrlHandler = Optional[Callable[[BossType, WindowType, str, int, str], bool]]
|
||||
|
||||
|
||||
class ButtonEvent(NamedTuple):
|
||||
mouse_event: MouseEvent
|
||||
timestamp: float
|
||||
@@ -223,23 +227,26 @@ class HandleResult:
|
||||
type_of_input: Optional[str] = None
|
||||
no_ui: bool = False
|
||||
|
||||
def __init__(self, impl: Callable[..., Any], type_of_input: Optional[str], no_ui: bool, has_ready_notification: bool):
|
||||
def __init__(self, impl: Callable[..., Any], type_of_input: Optional[str], no_ui: bool, has_ready_notification: bool, open_url_handler: OpenUrlHandler):
|
||||
self.impl = impl
|
||||
self.no_ui = no_ui
|
||||
self.type_of_input = type_of_input
|
||||
self.has_ready_notification = has_ready_notification
|
||||
self.open_url_handler = open_url_handler
|
||||
|
||||
def __call__(self, args: Sequence[str], data: Any, target_window_id: int, boss: BossType) -> Any:
|
||||
return self.impl(args, data, target_window_id, boss)
|
||||
|
||||
|
||||
|
||||
def result_handler(
|
||||
type_of_input: Optional[str] = None,
|
||||
no_ui: bool = False,
|
||||
has_ready_notification: bool = Handler.overlay_ready_report_needed
|
||||
has_ready_notification: bool = Handler.overlay_ready_report_needed,
|
||||
open_url_handler: OpenUrlHandler = None,
|
||||
) -> Callable[[Callable[..., Any]], HandleResult]:
|
||||
|
||||
def wrapper(impl: Callable[..., Any]) -> HandleResult:
|
||||
return HandleResult(impl, type_of_input, no_ui, has_ready_notification)
|
||||
return HandleResult(impl, type_of_input, no_ui, has_ready_notification, open_url_handler)
|
||||
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user