mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-12 02:42:56 +02:00
Add various special purpose entry points
This commit is contained in:
@@ -47,3 +47,28 @@ func complete_kitty(completions *Completions, word string, arg_num int) {
|
||||
}, "")
|
||||
}
|
||||
}
|
||||
|
||||
func complete_plus_launch(completions *Completions, word string, arg_num int) {
|
||||
if arg_num == 1 {
|
||||
fnmatch_completer("Python scripts", CWD, "*.py")(completions, word, arg_num)
|
||||
if strings.HasPrefix(word, ":") {
|
||||
exes := complete_executables_in_path(word[1:])
|
||||
mg := completions.add_match_group("Python scripts in PATH")
|
||||
for _, exe := range exes {
|
||||
mg.add_match(":" + exe)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fnmatch_completer("Files", CWD, "*")(completions, word, arg_num)
|
||||
}
|
||||
}
|
||||
|
||||
func complete_plus_runpy(completions *Completions, word string, arg_num int) {
|
||||
if arg_num > 1 {
|
||||
fnmatch_completer("Files", CWD, "*")(completions, word, arg_num)
|
||||
}
|
||||
}
|
||||
|
||||
func complete_plus_open(completions *Completions, word string, arg_num int) {
|
||||
fnmatch_completer("Files", CWD, "*")(completions, word, arg_num)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,12 @@ func (self *MatchGroup) add_match(word string, description ...string) *Match {
|
||||
return &ans
|
||||
}
|
||||
|
||||
func (self *MatchGroup) add_prefix_to_all_matches(prefix string) {
|
||||
for _, m := range self.Matches {
|
||||
m.Word = prefix + m.Word
|
||||
}
|
||||
}
|
||||
|
||||
type Completions struct {
|
||||
Groups []*MatchGroup `json:"groups,omitempty"`
|
||||
|
||||
@@ -32,9 +38,7 @@ type Completions struct {
|
||||
|
||||
func (self *Completions) add_prefix_to_all_matches(prefix string) {
|
||||
for _, mg := range self.Groups {
|
||||
for _, m := range mg.Matches {
|
||||
m.Word = prefix + m.Word
|
||||
}
|
||||
mg.add_prefix_to_all_matches(prefix)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +81,12 @@ type Command struct {
|
||||
Subcommand_must_be_first bool
|
||||
}
|
||||
|
||||
func (self *Command) clone_options_from(other *Command) {
|
||||
for _, opt := range other.Options {
|
||||
self.Options = append(self.Options, opt)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Command) add_group(name string) *CommandGroup {
|
||||
for _, g := range self.Groups {
|
||||
if g.Title == name {
|
||||
|
||||
Reference in New Issue
Block a user