summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-03-02 12:09:27 +0300
committerGrail Finder <wohilas@gmail.com>2026-03-02 12:09:27 +0300
commit07b06bb0d32ce86b8aa1b8d6157eedca89c52152 (patch)
treed969997ac2555044b4c931b065f55b4880d9627c
parent3389b1d83bc9fcc605fdff813c826410d07cfe28 (diff)
Enha: tabcompletion is back in textarea
-rw-r--r--popups.go60
-rw-r--r--tui.go12
2 files changed, 72 insertions, 0 deletions
diff --git a/popups.go b/popups.go
index 9998daa..aa08e5e 100644
--- a/popups.go
+++ b/popups.go
@@ -406,6 +406,66 @@ func showShellFileCompletionPopup(filter string) {
app.SetFocus(widget)
}
+func showTextAreaFileCompletionPopup(filter string) {
+ baseDir := cfg.FilePickerDir
+ if baseDir == "" {
+ baseDir = "."
+ }
+ complMatches := scanFiles(baseDir, filter)
+ if len(complMatches) == 0 {
+ return
+ }
+ 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)
+ for _, m := range complMatches {
+ widget.AddItem(m, "", 0, nil)
+ }
+ widget.SetSelectedFunc(func(index int, mainText string, secondaryText string, shortcut rune) {
+ currentText := textArea.GetText()
+ atIdx := strings.LastIndex(currentText, "@")
+ if atIdx >= 0 {
+ before := currentText[:atIdx]
+ textArea.SetText(before+mainText, true)
+ }
+ pages.RemovePage("textAreaFileCompletionPopup")
+ app.SetFocus(textArea)
+ })
+ widget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
+ if event.Key() == tcell.KeyEscape {
+ pages.RemovePage("textAreaFileCompletionPopup")
+ app.SetFocus(textArea)
+ return nil
+ }
+ if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
+ pages.RemovePage("textAreaFileCompletionPopup")
+ app.SetFocus(textArea)
+ return nil
+ }
+ return event
+ })
+ modal := func(p tview.Primitive, width, height int) tview.Primitive {
+ return tview.NewFlex().
+ AddItem(nil, 0, 1, false).
+ AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
+ AddItem(nil, 0, 1, false).
+ AddItem(p, height, 1, true).
+ AddItem(nil, 0, 1, false), width, 1, true).
+ AddItem(nil, 0, 1, false)
+ }
+ pages.AddPage("textAreaFileCompletionPopup", modal(widget, 80, 20), true, true)
+ app.SetFocus(widget)
+}
+
func updateWidgetColors(theme *tview.Theme) {
bgColor := theme.PrimitiveBackgroundColor
fgColor := theme.PrimaryTextColor
diff --git a/tui.go b/tui.go
index d1ca5f0..366f466 100644
--- a/tui.go
+++ b/tui.go
@@ -1071,6 +1071,18 @@ func init() {
chatRoundChan <- &models.ChatRoundReq{Role: persona, UserMsg: msgText}
return nil
}
+ if event.Key() == tcell.KeyTab {
+ currentF := app.GetFocus()
+ if currentF == textArea {
+ currentText := textArea.GetText()
+ atIndex := strings.LastIndex(currentText, "@")
+ if atIndex >= 0 {
+ filter := currentText[atIndex+1:]
+ showTextAreaFileCompletionPopup(filter)
+ }
+ }
+ return nil
+ }
if event.Key() == tcell.KeyPgUp || event.Key() == tcell.KeyPgDn {
currentF := app.GetFocus()
app.SetFocus(focusSwitcher[currentF])