summaryrefslogtreecommitdiff
path: root/popups.go
diff options
context:
space:
mode:
Diffstat (limited to 'popups.go')
-rw-r--r--popups.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/popups.go b/popups.go
index c83bce4..db314e4 100644
--- a/popups.go
+++ b/popups.go
@@ -70,6 +70,10 @@ func showModelSelectionPopup() {
pages.RemovePage("modelSelectionPopup")
return nil
}
+ if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
+ pages.RemovePage("modelSelectionPopup")
+ return nil
+ }
return event
})
modal := func(p tview.Primitive, width, height int) tview.Primitive {
@@ -163,6 +167,10 @@ func showAPILinkSelectionPopup() {
pages.RemovePage("apiLinkSelectionPopup")
return nil
}
+ if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
+ pages.RemovePage("apiLinkSelectionPopup")
+ return nil
+ }
return event
})
modal := func(p tview.Primitive, width, height int) tview.Primitive {
@@ -229,6 +237,10 @@ func showUserRoleSelectionPopup() {
pages.RemovePage("userRoleSelectionPopup")
return nil
}
+ if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
+ pages.RemovePage("userRoleSelectionPopup")
+ return nil
+ }
return event
})
modal := func(p tview.Primitive, width, height int) tview.Primitive {
@@ -297,6 +309,10 @@ func showBotRoleSelectionPopup() {
pages.RemovePage("botRoleSelectionPopup")
return nil
}
+ if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
+ pages.RemovePage("botRoleSelectionPopup")
+ return nil
+ }
return event
})
modal := func(p tview.Primitive, width, height int) tview.Primitive {
@@ -322,6 +338,16 @@ func showFileCompletionPopup(filter string) {
if len(complMatches) == 0 {
return
}
+ // If only one match, auto-complete without showing popup
+ if len(complMatches) == 1 {
+ currentText := textArea.GetText()
+ atIdx := strings.LastIndex(currentText, "@")
+ if atIdx >= 0 {
+ before := currentText[:atIdx]
+ textArea.SetText(before+complMatches[0], true)
+ }
+ return
+ }
widget := tview.NewList().ShowSecondaryText(false).
SetSelectedBackgroundColor(tcell.ColorGray)
widget.SetTitle("file completion").SetBorder(true)
@@ -337,6 +363,17 @@ func showFileCompletionPopup(filter string) {
}
pages.RemovePage("fileCompletionPopup")
})
+ widget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
+ if event.Key() == tcell.KeyEscape {
+ pages.RemovePage("fileCompletionPopup")
+ return nil
+ }
+ if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
+ pages.RemovePage("fileCompletionPopup")
+ return nil
+ }
+ return event
+ })
modal := func(p tview.Primitive, width, height int) tview.Primitive {
return tview.NewFlex().
AddItem(nil, 0, 1, false).