diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-02-23 12:46:28 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-02-23 12:46:28 +0300 |
| commit | 04db7c2f01355f2c43843794522380607e807716 (patch) | |
| tree | 79446ff4d5f43b936e62a5381a8f4f30e2c86886 | |
| parent | 3d889e70b55e8bf4b7d94ac7d42d09ea16203f3e (diff) | |
Enha: not allow popups outside of main page
| -rw-r--r-- | popups.go | 18 | ||||
| -rw-r--r-- | tui.go | 20 |
2 files changed, 38 insertions, 0 deletions
@@ -65,16 +65,19 @@ func showModelSelectionPopup() { chatBody.Model = modelName cfg.CurrentModel = chatBody.Model pages.RemovePage("modelSelectionPopup") + app.SetFocus(textArea) updateCachedModelColor() updateStatusLine() }) modelListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEscape { pages.RemovePage("modelSelectionPopup") + app.SetFocus(textArea) return nil } if event.Key() == tcell.KeyRune && event.Rune() == 'x' { pages.RemovePage("modelSelectionPopup") + app.SetFocus(textArea) return nil } return event @@ -160,6 +163,7 @@ func showAPILinkSelectionPopup() { cfg.CurrentModel = chatBody.Model } pages.RemovePage("apiLinkSelectionPopup") + app.SetFocus(textArea) choseChunkParser() updateCachedModelColor() updateStatusLine() @@ -167,10 +171,12 @@ func showAPILinkSelectionPopup() { apiListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEscape { pages.RemovePage("apiLinkSelectionPopup") + app.SetFocus(textArea) return nil } if event.Key() == tcell.KeyRune && event.Rune() == 'x' { pages.RemovePage("apiLinkSelectionPopup") + app.SetFocus(textArea) return nil } return event @@ -230,6 +236,7 @@ func showUserRoleSelectionPopup() { textView.SetText(chatToText(filtered, cfg.ShowSys)) // Remove the popup page pages.RemovePage("userRoleSelectionPopup") + app.SetFocus(textArea) // Update the status line to reflect the change updateStatusLine() colorText() @@ -237,10 +244,12 @@ func showUserRoleSelectionPopup() { roleListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEscape { pages.RemovePage("userRoleSelectionPopup") + app.SetFocus(textArea) return nil } if event.Key() == tcell.KeyRune && event.Rune() == 'x' { pages.RemovePage("userRoleSelectionPopup") + app.SetFocus(textArea) return nil } return event @@ -303,16 +312,19 @@ func showBotRoleSelectionPopup() { cfg.WriteNextMsgAsCompletionAgent = mainText // Remove the popup page pages.RemovePage("botRoleSelectionPopup") + app.SetFocus(textArea) // Update the status line to reflect the change updateStatusLine() }) roleListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEscape { pages.RemovePage("botRoleSelectionPopup") + app.SetFocus(textArea) return nil } if event.Key() == tcell.KeyRune && event.Rune() == 'x' { pages.RemovePage("botRoleSelectionPopup") + app.SetFocus(textArea) return nil } return event @@ -364,14 +376,17 @@ func showFileCompletionPopup(filter string) { textArea.SetText(before+mainText, true) } pages.RemovePage("fileCompletionPopup") + app.SetFocus(textArea) }) widget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEscape { pages.RemovePage("fileCompletionPopup") + app.SetFocus(textArea) return nil } if event.Key() == tcell.KeyRune && event.Rune() == 'x' { pages.RemovePage("fileCompletionPopup") + app.SetFocus(textArea) return nil } return event @@ -484,14 +499,17 @@ func showColorschemeSelectionPopup() { } // Remove the popup page pages.RemovePage("colorschemeSelectionPopup") + app.SetFocus(textArea) }) schemeListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEscape { pages.RemovePage("colorschemeSelectionPopup") + app.SetFocus(textArea) return nil } if event.Key() == tcell.KeyRune && event.Rune() == 'x' { pages.RemovePage("colorschemeSelectionPopup") + app.SetFocus(textArea) return nil } return event @@ -15,6 +15,11 @@ import ( "github.com/rivo/tview" ) +func isFullScreenPageActive() bool { + name, _ := pages.GetFrontPage() + return name != "main" +} + var ( app *tview.Application pages *tview.Pages @@ -525,6 +530,9 @@ func init() { return nil } if event.Key() == tcell.KeyRune && event.Rune() == 'i' && event.Modifiers()&tcell.ModAlt != 0 { + if isFullScreenPageActive() { + return event + } showColorschemeSelectionPopup() return nil } @@ -731,6 +739,9 @@ func init() { return nil } if event.Key() == tcell.KeyCtrlL { + if isFullScreenPageActive() { + return event + } // Show model selection popup instead of rotating models showModelSelectionPopup() return nil @@ -744,6 +755,9 @@ func init() { return nil } if event.Key() == tcell.KeyCtrlV { + if isFullScreenPageActive() { + return event + } // Show API link selection popup instead of rotating APIs showAPILinkSelectionPopup() return nil @@ -850,11 +864,17 @@ func init() { return nil } if event.Key() == tcell.KeyCtrlQ { + if isFullScreenPageActive() { + return event + } // Show user role selection popup instead of cycling through roles showUserRoleSelectionPopup() return nil } if event.Key() == tcell.KeyCtrlX { + if isFullScreenPageActive() { + return event + } // Show bot role selection popup instead of cycling through roles showBotRoleSelectionPopup() return nil |
