More work on porting themes UI to Go

This commit is contained in:
Kovid Goyal
2023-03-12 09:08:26 +05:30
parent f9b0b54ee5
commit dd783c842f
4 changed files with 204 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import (
"kitty/tools/cli"
"kitty/tools/themes"
"kitty/tools/tui/loop"
"kitty/tools/utils"
)
@@ -54,6 +55,35 @@ func main(_ *cli.Command, opts *Options, args []string) (rc int, err error) {
if len(args) == 1 {
return non_interactive(opts, args[0])
}
lp, err := loop.New()
if err != nil {
return 1, err
}
cv := utils.NewCachedValues("unicode-input", &CachedData{Category: "All"})
h := &handler{lp: lp, opts: opts, cached_data: cv.Load()}
defer cv.Save()
lp.OnInitialize = func() (string, error) {
lp.AllowLineWrapping(false)
lp.SetWindowTitle(`Choose a theme for kitty`)
h.initialize()
return "", nil
}
lp.OnWakeup = h.on_wakeup
lp.OnFinalize = func() string {
h.finalize()
lp.SetCursorVisible(true)
return ``
}
err = lp.Run()
if err != nil {
return 1, err
}
ds := lp.DeathSignalName()
if ds != "" {
fmt.Println("Killed by signal: ", ds)
lp.KillIfSignalled()
return 1, nil
}
return
}