style(ui): redesign new menu (#18)

- 2 mode classic (the old one) and modern
a2a17cab3a4bdf27abd2a956f9d53a0c4a685909
- add icon 3a11c7a6beb1dcf11e89977f380376fdea9fba89
- fix some bugs
This commit is contained in:
VERSE
2026-07-03 11:50:35 +07:00
committed by GitHub
parent 24fddaccfe
commit ea82216dc9
11 changed files with 365 additions and 76 deletions
+9 -5
View File
@@ -47,13 +47,13 @@ func Lookup(input string) []Suggestion {
shellAliasesMu.RUnlock()
if input == "" {
return nil
return topLevelSuggestions("", aliases)
}
tokens := Tokenize(input)
if len(tokens) == 1 && tokens[0] == "" {
return nil
return topLevelSuggestions("", aliases)
}
// NOTE: remember that wrapper already check if we type nothing, but I just want to make sure
// in the future, maybe we will write unit test or using Lookup in another module
@@ -277,7 +277,7 @@ func topLevelSuggestions(query string, aliases map[string]string) []Suggestion {
for name, target := range aliases {
if !seen[name] && (query == "" || HasPrefix(name, query)) {
results = append(results, Suggestion{
Cmd: target, Desc: "alias: " + name, Icon: "root",
Cmd: name, Desc: target, Icon: "alias",
})
seen[name] = true
}
@@ -299,7 +299,11 @@ func topLevelSuggestions(query string, aliases map[string]string) []Suggestion {
}
}
if match {
results = append(results, Suggestion{Cmd: name, Desc: spec.Description, Icon: name})
icon := spec.Icon
if icon == "" {
icon = name
}
results = append(results, Suggestion{Cmd: name, Desc: spec.Description, Icon: icon})
seen[name] = true
}
}
@@ -307,7 +311,7 @@ func topLevelSuggestions(query string, aliases map[string]string) []Suggestion {
for name := range pathCmds {
if !seen[name] && (query == "" || HasPrefix(name, query)) {
results = append(results, Suggestion{
Cmd: name, Desc: "system command", Icon: "root",
Cmd: name, Desc: "system command", Icon: "system",
})
}
}