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
+6
View File
@@ -51,6 +51,12 @@ mode = "last"
debug = false
[ui]
# visual style: "modern" (icons, category pills, shortcut footer) or "classic" (minimalist, centered number, no icons)
style = "modern"
# enable Nerd Fonts icons in overlay menu
nerd-fonts = true
# enable inline ghost text
ghost-text = true
+6
View File
@@ -175,6 +175,12 @@ mode = "last"
debug = false
[ui]
# visual style: "modern" (icons, category pills, shortcut footer) or "classic" (minimalist, centered number, no icons)
style = "modern"
# enable Nerd Fonts icons in overlay menu
nerd-fonts = true
# enable inline ghost text
ghost-text = true
+4 -8
View File
@@ -1,7 +1,6 @@
package root
import (
"fmt"
"strings"
"github.com/versenilvis/iris/commands/core"
@@ -17,11 +16,8 @@ func MergeResults(query string, mode string) []core.Suggestion {
deduped := []core.Suggestion{}
// always call lookup to scan aliases and get spec suggestions
var cmdResults []core.Suggestion
if query != "" {
logger.Debugf("Merge Calling Lookup for '%s'", query)
cmdResults = core.Lookup(query)
}
logger.Debugf("Merge Calling Lookup for '%s'", query)
cmdResults := core.Lookup(query)
// search history if in history mode
var histResults []integration.HistResult
@@ -53,8 +49,8 @@ func MergeResults(query string, mode string) []core.Suggestion {
for _, h := range histResults {
addSuggestion(core.Suggestion{
Cmd: h.Cmd,
Desc: " history",
Icon: fmt.Sprintf("%d", h.ID),
Desc: "history",
Icon: "history",
})
}
for _, s := range cmdResults {
+42 -2
View File
@@ -323,6 +323,15 @@ func runWrapper() {
continue
}
if query == "" {
bufferMu.Lock()
naiveBuffer = ""
cursorOffset = 0
bufferMu.Unlock()
writeStdout([]byte(overlay.ClearAndDisable()))
continue
}
// sync local buffer with actual command line
bufferMu.Lock()
naiveBuffer = query
@@ -388,7 +397,7 @@ func runWrapper() {
var b strings.Builder
if !navCopy {
if bufCopy == "" {
if bufCopy == "" && !overlay.Visible {
writeStdout([]byte(overlay.ClearAndDisable()))
return
}
@@ -722,6 +731,7 @@ func runWrapper() {
}
userNavigated.Store(false)
overlay.UserNavigated = false
overlay.Visible = true
shouldOverlayDraw = true
// enter: enter behavior is a bit different from tab suggestions in code editor
// I want it to execute the command anyway and ignore the suggestions
@@ -808,7 +818,8 @@ func runWrapper() {
case 127, 0x08: // backspace: remove character
bufferMu.Lock()
if len(naiveBuffer) > 0 {
wasEmpty := len(naiveBuffer) == 0
if !wasEmpty {
runes := []rune(naiveBuffer)
if cursorOffset <= 0 {
if len(runes) > 0 {
@@ -825,11 +836,26 @@ func runWrapper() {
}
}
}
isEmptyNow := len(naiveBuffer) == 0
bufferMu.Unlock()
if wasEmpty {
if overlay.Visible {
writeStdout([]byte(overlay.ClearAndDisable()))
}
userNavigated.Store(false)
continue
}
if isEmptyNow {
writeStdout([]byte(overlay.ClearAndDisable()))
userNavigated.Store(false)
continue
}
shouldOverlayDraw = true
userNavigated.Store(false)
case 0x17: // ctrl+w: delete the last word in the buffer
bufferMu.Lock()
wasEmpty := len(naiveBuffer) == 0
trimBuf := strings.TrimRight(naiveBuffer, " ")
lastSpace := strings.LastIndex(trimBuf, " ")
if lastSpace >= 0 {
@@ -838,7 +864,21 @@ func runWrapper() {
naiveBuffer = ""
}
cursorOffset = 0
isEmptyNow := len(naiveBuffer) == 0
bufferMu.Unlock()
if wasEmpty {
if overlay.Visible {
writeStdout([]byte(overlay.ClearAndDisable()))
}
userNavigated.Store(false)
continue
}
if isEmptyNow {
writeStdout([]byte(overlay.ClearAndDisable()))
userNavigated.Store(false)
continue
}
shouldOverlayDraw = true
userNavigated.Store(false)
case 0x0c: // ctrl+l: clear screen but keep buffer and redraw menu