Start work on porting themes kitten to Go

This commit is contained in:
Kovid Goyal 2023-03-11 10:14:03 +05:30
parent 3741d3d1be
commit f9b0b54ee5
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
7 changed files with 508 additions and 24 deletions

View file

@ -4,11 +4,10 @@ package completion
import (
"fmt"
"os/exec"
"strings"
"kitty/tools/cli"
"kitty/tools/utils"
"kitty/tools/themes"
)
var _ = fmt.Print
@ -64,20 +63,7 @@ func complete_plus_open(completions *cli.Completions, word string, arg_num int)
}
func complete_themes(completions *cli.Completions, word string, arg_num int) {
kitty := utils.KittyExe()
if kitty != "" {
out, err := exec.Command(kitty, "+runpy", "from kittens.themes.collection import *; print_theme_names()").Output()
if err == nil {
mg := completions.AddMatchGroup("Themes")
scanner := utils.NewLineScanner(utils.UnsafeBytesToString(out))
for scanner.Scan() {
theme_name := strings.TrimSpace(scanner.Text())
if theme_name != "" && strings.HasPrefix(theme_name, word) {
mg.AddMatch(theme_name)
}
}
}
}
themes.CompleteThemes(completions, word, arg_num)
}
func EntryPoint(tool_root *cli.Command) {