mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
hints kitten: Allow clicking on matched text to select it in addition to typing the hint
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package hints
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -183,7 +184,8 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
} else {
|
||||
mark_text = mark_text[len(hint):]
|
||||
}
|
||||
return hint_style(hint) + text_style(mark_text)
|
||||
ans := hint_style(hint) + text_style(mark_text)
|
||||
return fmt.Sprintf("\x1b]8;;mark:%d\a%s\x1b]8;;\a", m.Index, ans)
|
||||
}
|
||||
|
||||
render := func() string {
|
||||
@@ -230,6 +232,30 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
draw_screen()
|
||||
return nil
|
||||
}
|
||||
lp.OnRCResponse = func(data []byte) error {
|
||||
var r struct {
|
||||
Type string
|
||||
Mark int
|
||||
}
|
||||
if err := json.Unmarshal(data, &r); err != nil {
|
||||
return err
|
||||
}
|
||||
if r.Type == "mark_activated" {
|
||||
if m, ok := index_map[r.Mark]; ok {
|
||||
chosen = append(chosen, m)
|
||||
if o.Multiple {
|
||||
ignore_mark_indices.Add(m.Index)
|
||||
reset()
|
||||
} else {
|
||||
lp.Quit(0)
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
lp.OnText = func(text string, _, _ bool) error {
|
||||
changed := false
|
||||
for _, ch := range text {
|
||||
|
||||
Reference in New Issue
Block a user