Enha: not allow popups outside of main page
This commit is contained in:
18
popups.go
18
popups.go
@@ -65,16 +65,19 @@ func showModelSelectionPopup() {
|
|||||||
chatBody.Model = modelName
|
chatBody.Model = modelName
|
||||||
cfg.CurrentModel = chatBody.Model
|
cfg.CurrentModel = chatBody.Model
|
||||||
pages.RemovePage("modelSelectionPopup")
|
pages.RemovePage("modelSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
updateCachedModelColor()
|
updateCachedModelColor()
|
||||||
updateStatusLine()
|
updateStatusLine()
|
||||||
})
|
})
|
||||||
modelListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
modelListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||||
if event.Key() == tcell.KeyEscape {
|
if event.Key() == tcell.KeyEscape {
|
||||||
pages.RemovePage("modelSelectionPopup")
|
pages.RemovePage("modelSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
||||||
pages.RemovePage("modelSelectionPopup")
|
pages.RemovePage("modelSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return event
|
return event
|
||||||
@@ -160,6 +163,7 @@ func showAPILinkSelectionPopup() {
|
|||||||
cfg.CurrentModel = chatBody.Model
|
cfg.CurrentModel = chatBody.Model
|
||||||
}
|
}
|
||||||
pages.RemovePage("apiLinkSelectionPopup")
|
pages.RemovePage("apiLinkSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
choseChunkParser()
|
choseChunkParser()
|
||||||
updateCachedModelColor()
|
updateCachedModelColor()
|
||||||
updateStatusLine()
|
updateStatusLine()
|
||||||
@@ -167,10 +171,12 @@ func showAPILinkSelectionPopup() {
|
|||||||
apiListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
apiListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||||
if event.Key() == tcell.KeyEscape {
|
if event.Key() == tcell.KeyEscape {
|
||||||
pages.RemovePage("apiLinkSelectionPopup")
|
pages.RemovePage("apiLinkSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
||||||
pages.RemovePage("apiLinkSelectionPopup")
|
pages.RemovePage("apiLinkSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return event
|
return event
|
||||||
@@ -230,6 +236,7 @@ func showUserRoleSelectionPopup() {
|
|||||||
textView.SetText(chatToText(filtered, cfg.ShowSys))
|
textView.SetText(chatToText(filtered, cfg.ShowSys))
|
||||||
// Remove the popup page
|
// Remove the popup page
|
||||||
pages.RemovePage("userRoleSelectionPopup")
|
pages.RemovePage("userRoleSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
// Update the status line to reflect the change
|
// Update the status line to reflect the change
|
||||||
updateStatusLine()
|
updateStatusLine()
|
||||||
colorText()
|
colorText()
|
||||||
@@ -237,10 +244,12 @@ func showUserRoleSelectionPopup() {
|
|||||||
roleListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
roleListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||||
if event.Key() == tcell.KeyEscape {
|
if event.Key() == tcell.KeyEscape {
|
||||||
pages.RemovePage("userRoleSelectionPopup")
|
pages.RemovePage("userRoleSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
||||||
pages.RemovePage("userRoleSelectionPopup")
|
pages.RemovePage("userRoleSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return event
|
return event
|
||||||
@@ -303,16 +312,19 @@ func showBotRoleSelectionPopup() {
|
|||||||
cfg.WriteNextMsgAsCompletionAgent = mainText
|
cfg.WriteNextMsgAsCompletionAgent = mainText
|
||||||
// Remove the popup page
|
// Remove the popup page
|
||||||
pages.RemovePage("botRoleSelectionPopup")
|
pages.RemovePage("botRoleSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
// Update the status line to reflect the change
|
// Update the status line to reflect the change
|
||||||
updateStatusLine()
|
updateStatusLine()
|
||||||
})
|
})
|
||||||
roleListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
roleListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||||
if event.Key() == tcell.KeyEscape {
|
if event.Key() == tcell.KeyEscape {
|
||||||
pages.RemovePage("botRoleSelectionPopup")
|
pages.RemovePage("botRoleSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
||||||
pages.RemovePage("botRoleSelectionPopup")
|
pages.RemovePage("botRoleSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return event
|
return event
|
||||||
@@ -364,14 +376,17 @@ func showFileCompletionPopup(filter string) {
|
|||||||
textArea.SetText(before+mainText, true)
|
textArea.SetText(before+mainText, true)
|
||||||
}
|
}
|
||||||
pages.RemovePage("fileCompletionPopup")
|
pages.RemovePage("fileCompletionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
})
|
})
|
||||||
widget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
widget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||||
if event.Key() == tcell.KeyEscape {
|
if event.Key() == tcell.KeyEscape {
|
||||||
pages.RemovePage("fileCompletionPopup")
|
pages.RemovePage("fileCompletionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
||||||
pages.RemovePage("fileCompletionPopup")
|
pages.RemovePage("fileCompletionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return event
|
return event
|
||||||
@@ -484,14 +499,17 @@ func showColorschemeSelectionPopup() {
|
|||||||
}
|
}
|
||||||
// Remove the popup page
|
// Remove the popup page
|
||||||
pages.RemovePage("colorschemeSelectionPopup")
|
pages.RemovePage("colorschemeSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
})
|
})
|
||||||
schemeListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
schemeListWidget.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||||
if event.Key() == tcell.KeyEscape {
|
if event.Key() == tcell.KeyEscape {
|
||||||
pages.RemovePage("colorschemeSelectionPopup")
|
pages.RemovePage("colorschemeSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
if event.Key() == tcell.KeyRune && event.Rune() == 'x' {
|
||||||
pages.RemovePage("colorschemeSelectionPopup")
|
pages.RemovePage("colorschemeSelectionPopup")
|
||||||
|
app.SetFocus(textArea)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return event
|
return event
|
||||||
|
|||||||
20
tui.go
20
tui.go
@@ -15,6 +15,11 @@ import (
|
|||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func isFullScreenPageActive() bool {
|
||||||
|
name, _ := pages.GetFrontPage()
|
||||||
|
return name != "main"
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
app *tview.Application
|
app *tview.Application
|
||||||
pages *tview.Pages
|
pages *tview.Pages
|
||||||
@@ -525,6 +530,9 @@ func init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyRune && event.Rune() == 'i' && event.Modifiers()&tcell.ModAlt != 0 {
|
if event.Key() == tcell.KeyRune && event.Rune() == 'i' && event.Modifiers()&tcell.ModAlt != 0 {
|
||||||
|
if isFullScreenPageActive() {
|
||||||
|
return event
|
||||||
|
}
|
||||||
showColorschemeSelectionPopup()
|
showColorschemeSelectionPopup()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -731,6 +739,9 @@ func init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyCtrlL {
|
if event.Key() == tcell.KeyCtrlL {
|
||||||
|
if isFullScreenPageActive() {
|
||||||
|
return event
|
||||||
|
}
|
||||||
// Show model selection popup instead of rotating models
|
// Show model selection popup instead of rotating models
|
||||||
showModelSelectionPopup()
|
showModelSelectionPopup()
|
||||||
return nil
|
return nil
|
||||||
@@ -744,6 +755,9 @@ func init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyCtrlV {
|
if event.Key() == tcell.KeyCtrlV {
|
||||||
|
if isFullScreenPageActive() {
|
||||||
|
return event
|
||||||
|
}
|
||||||
// Show API link selection popup instead of rotating APIs
|
// Show API link selection popup instead of rotating APIs
|
||||||
showAPILinkSelectionPopup()
|
showAPILinkSelectionPopup()
|
||||||
return nil
|
return nil
|
||||||
@@ -850,11 +864,17 @@ func init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyCtrlQ {
|
if event.Key() == tcell.KeyCtrlQ {
|
||||||
|
if isFullScreenPageActive() {
|
||||||
|
return event
|
||||||
|
}
|
||||||
// Show user role selection popup instead of cycling through roles
|
// Show user role selection popup instead of cycling through roles
|
||||||
showUserRoleSelectionPopup()
|
showUserRoleSelectionPopup()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyCtrlX {
|
if event.Key() == tcell.KeyCtrlX {
|
||||||
|
if isFullScreenPageActive() {
|
||||||
|
return event
|
||||||
|
}
|
||||||
// Show bot role selection popup instead of cycling through roles
|
// Show bot role selection popup instead of cycling through roles
|
||||||
showBotRoleSelectionPopup()
|
showBotRoleSelectionPopup()
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user