mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Start work on panel kitten wrapper in Go
Needed because we need to use a special exe on macOS.
This commit is contained in:
@@ -222,7 +222,7 @@ func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
keep_going.Store(true)
|
||||
if !opts.DetectSupport && num_of_items > 0 {
|
||||
num_workers := utils.Max(1, utils.Min(num_of_items, runtime.NumCPU()))
|
||||
for i := 0; i < num_workers; i++ {
|
||||
for range num_workers {
|
||||
go run_worker()
|
||||
}
|
||||
}
|
||||
|
||||
60
kittens/panel/main.go
Normal file
60
kittens/panel/main.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package panel
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"kitty/tools/cli"
|
||||
"kitty/tools/utils"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func complete_kitty_listen_on(completions *cli.Completions, word string, arg_num int) {
|
||||
if !strings.Contains(word, ":") {
|
||||
mg := completions.AddMatchGroup("Address family")
|
||||
mg.NoTrailingSpace = true
|
||||
for _, q := range []string{"unix:", "tcp:"} {
|
||||
if strings.HasPrefix(q, word) {
|
||||
mg.AddMatch(q)
|
||||
}
|
||||
}
|
||||
} else if strings.HasPrefix(word, "unix:") && !strings.HasPrefix(word, "unix:@") {
|
||||
cli.FnmatchCompleter("UNIX sockets", cli.CWD, "*")(completions, word[len("unix:"):], arg_num)
|
||||
completions.AddPrefixToAllMatches("unix:")
|
||||
}
|
||||
}
|
||||
|
||||
func GetQuickAccessKittyExe() (kitty_exe string, err error) {
|
||||
if kitty_exe, err = filepath.EvalSymlinks(utils.KittyExe()); err != nil {
|
||||
return "", fmt.Errorf("Failed to find path to the kitty executable, this kitten requires the kitty executable to function. The kitty executable or a symlink to it must be placed in the same directory as the kitten executable. Error: %w", err)
|
||||
}
|
||||
if runtime.GOOS == "darwin" {
|
||||
q := filepath.Join(filepath.Dir(filepath.Dir(kitty_exe)), "kitty-quick-access.app", "Contents", "MacOS", "kitty-quick-access")
|
||||
if err := unix.Access(q, unix.X_OK); err == nil {
|
||||
kitty_exe = q
|
||||
}
|
||||
}
|
||||
return kitty_exe, nil
|
||||
|
||||
}
|
||||
|
||||
func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
kitty_exe, err := GetQuickAccessKittyExe()
|
||||
if err != nil {
|
||||
return 1, err
|
||||
}
|
||||
argv := []string{kitty_exe, "+kitten", "panel"}
|
||||
err = unix.Exec(kitty_exe, append(argv, args...), os.Environ())
|
||||
rc = 1
|
||||
return
|
||||
}
|
||||
|
||||
func EntryPoint(parent *cli.Command) {
|
||||
create_cmd(parent, main)
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"kitty/kittens/hyperlinked_grep"
|
||||
"kitty/kittens/icat"
|
||||
"kitty/kittens/notify"
|
||||
"kitty/kittens/panel"
|
||||
"kitty/kittens/query_terminal"
|
||||
"kitty/kittens/show_key"
|
||||
"kitty/kittens/ssh"
|
||||
@@ -53,6 +54,8 @@ func KittyToolEntryPoints(root *cli.Command) {
|
||||
ssh.EntryPoint(root)
|
||||
// transfer
|
||||
transfer.EntryPoint(root)
|
||||
// panel
|
||||
panel.EntryPoint(root)
|
||||
// unicode_input
|
||||
unicode_input.EntryPoint(root)
|
||||
// show_key
|
||||
|
||||
Reference in New Issue
Block a user