Work on supporting mouse interactions via simple hyperlinks

This commit is contained in:
Kovid Goyal
2024-05-04 09:45:57 +05:30
parent ffed63a048
commit 0b743464fb
3 changed files with 83 additions and 0 deletions

View File

@@ -70,6 +70,7 @@ func main() (rc int, err error) {
lp.SetCursorVisible(true)
return ``
}
lp.OnMouseEvent = h.on_mouse_event
lp.OnResize = func(_, _ loop.ScreenSize) error {
return h.draw_screen()
}

View File

@@ -5,6 +5,7 @@ import (
"strings"
"sync"
"kitty/tools/tui"
"kitty/tools/tui/loop"
"kitty/tools/tui/readline"
"kitty/tools/utils"
@@ -30,6 +31,7 @@ type handler struct {
state State
err_mutex sync.Mutex
err_in_worker_thread error
mouse_state tui.MouseState
// Listing
rl *readline.Readline
@@ -278,6 +280,10 @@ func (h *handler) on_wakeup() (err error) {
return h.draw_screen()
}
func (h *handler) on_mouse_event(event *loop.MouseEvent) (err error) {
return h.mouse_state.UpdateState(event)
}
func (h *handler) on_key_event(event *loop.KeyEvent) (err error) {
if event.MatchesPressOrRepeat("ctrl+c") {
event.Handled = true