mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
get multiple JSON messages working
This commit is contained in:
@@ -12,8 +12,16 @@ import (
|
||||
|
||||
var _ = fmt.Print
|
||||
var debugprintln = tty.DebugPrintln
|
||||
|
||||
var json_decoder *json.Decoder
|
||||
|
||||
func json_decode(v any) error {
|
||||
if err := json_decoder.Decode(v); err != nil {
|
||||
return fmt.Errorf("Failed to decode JSON from kitty with error: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() (rc int, err error) {
|
||||
json_decoder = json.NewDecoder(os.Stdin)
|
||||
lp, err := loop.New()
|
||||
|
||||
@@ -187,7 +187,7 @@ func (h *handler) initialize() {
|
||||
h.rl = readline.New(h.lp, readline.RlInit{DontMarkPrompts: true, Prompt: "Family: "})
|
||||
h.draw_screen()
|
||||
go func() {
|
||||
h.set_worker_error(json_decoder.Decode(&h.fonts))
|
||||
h.set_worker_error(json_decode(&h.fonts))
|
||||
h.lp.WakeupMainThread()
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user