Enha: toggle visibility of status line
This commit is contained in:
@@ -63,7 +63,7 @@ func colorText() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateStatusLine() {
|
func updateStatusLine() {
|
||||||
position.SetText(makeStatusLine())
|
statusLineWidget.SetText(makeStatusLine())
|
||||||
helpView.SetText(fmt.Sprintf(helpText, makeStatusLine()))
|
helpView.SetText(fmt.Sprintf(helpText, makeStatusLine()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
57
tui.go
57
tui.go
@@ -23,7 +23,7 @@ var (
|
|||||||
textArea *tview.TextArea
|
textArea *tview.TextArea
|
||||||
editArea *tview.TextArea
|
editArea *tview.TextArea
|
||||||
textView *tview.TextView
|
textView *tview.TextView
|
||||||
position *tview.TextView
|
statusLineWidget *tview.TextView
|
||||||
helpView *tview.TextView
|
helpView *tview.TextView
|
||||||
flex *tview.Flex
|
flex *tview.Flex
|
||||||
imgView *tview.Image
|
imgView *tview.Image
|
||||||
@@ -32,6 +32,7 @@ var (
|
|||||||
renameWindow *tview.InputField
|
renameWindow *tview.InputField
|
||||||
roleEditWindow *tview.InputField
|
roleEditWindow *tview.InputField
|
||||||
fullscreenMode bool
|
fullscreenMode bool
|
||||||
|
positionVisible bool = true
|
||||||
// pages
|
// pages
|
||||||
historyPage = "historyPage"
|
historyPage = "historyPage"
|
||||||
agentPage = "agentPage"
|
agentPage = "agentPage"
|
||||||
@@ -87,6 +88,7 @@ var (
|
|||||||
[yellow]Alt+1[white]: toggle shell mode (execute commands locally)
|
[yellow]Alt+1[white]: toggle shell mode (execute commands locally)
|
||||||
[yellow]Alt+4[white]: edit msg role
|
[yellow]Alt+4[white]: edit msg role
|
||||||
[yellow]Alt+5[white]: toggle system and tool messages display
|
[yellow]Alt+5[white]: toggle system and tool messages display
|
||||||
|
[yellow]Alt+6[white]: toggle status line visibility
|
||||||
|
|
||||||
=== scrolling chat window (some keys similar to vim) ===
|
=== scrolling chat window (some keys similar to vim) ===
|
||||||
[yellow]arrows up/down and j/k[white]: scroll up and down
|
[yellow]arrows up/down and j/k[white]: scroll up and down
|
||||||
@@ -171,6 +173,26 @@ func toggleShellMode() {
|
|||||||
updateStatusLine()
|
updateStatusLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateFlexLayout() {
|
||||||
|
if fullscreenMode {
|
||||||
|
// flex already contains only focused widget; do nothing
|
||||||
|
return
|
||||||
|
}
|
||||||
|
flex.Clear()
|
||||||
|
flex.AddItem(textView, 0, 40, false)
|
||||||
|
flex.AddItem(textArea, 0, 10, false)
|
||||||
|
if positionVisible {
|
||||||
|
flex.AddItem(statusLineWidget, 0, 2, false)
|
||||||
|
}
|
||||||
|
// Keep focus on currently focused widget
|
||||||
|
focused := app.GetFocus()
|
||||||
|
if focused == textView {
|
||||||
|
app.SetFocus(textView)
|
||||||
|
} else {
|
||||||
|
app.SetFocus(textArea)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func executeCommandAndDisplay(cmdText string) {
|
func executeCommandAndDisplay(cmdText string) {
|
||||||
// Parse the command (split by spaces, but handle quoted arguments)
|
// Parse the command (split by spaces, but handle quoted arguments)
|
||||||
cmdParts := parseCommand(cmdText)
|
cmdParts := parseCommand(cmdText)
|
||||||
@@ -456,8 +478,10 @@ func init() {
|
|||||||
//
|
//
|
||||||
flex = tview.NewFlex().SetDirection(tview.FlexRow).
|
flex = tview.NewFlex().SetDirection(tview.FlexRow).
|
||||||
AddItem(textView, 0, 40, false).
|
AddItem(textView, 0, 40, false).
|
||||||
AddItem(textArea, 0, 10, true). // Restore original height
|
AddItem(textArea, 0, 10, true) // Restore original height
|
||||||
AddItem(position, 0, 2, false)
|
if positionVisible {
|
||||||
|
flex.AddItem(statusLineWidget, 0, 2, false)
|
||||||
|
}
|
||||||
// textView.SetBorder(true).SetTitle("chat")
|
// textView.SetBorder(true).SetTitle("chat")
|
||||||
textView.SetDoneFunc(func(key tcell.Key) {
|
textView.SetDoneFunc(func(key tcell.Key) {
|
||||||
if key == tcell.KeyEnter {
|
if key == tcell.KeyEnter {
|
||||||
@@ -516,14 +540,16 @@ func init() {
|
|||||||
})
|
})
|
||||||
focusSwitcher[textArea] = textView
|
focusSwitcher[textArea] = textView
|
||||||
focusSwitcher[textView] = textArea
|
focusSwitcher[textView] = textArea
|
||||||
position = tview.NewTextView().
|
statusLineWidget = tview.NewTextView().
|
||||||
SetDynamicColors(true).
|
SetDynamicColors(true).
|
||||||
SetTextAlign(tview.AlignCenter)
|
SetTextAlign(tview.AlignCenter)
|
||||||
// Initially set up flex without search bar
|
// Initially set up flex without search bar
|
||||||
flex = tview.NewFlex().SetDirection(tview.FlexRow).
|
flex = tview.NewFlex().SetDirection(tview.FlexRow).
|
||||||
AddItem(textView, 0, 40, false).
|
AddItem(textView, 0, 40, false).
|
||||||
AddItem(textArea, 0, 10, true). // Restore original height
|
AddItem(textArea, 0, 10, true) // Restore original height
|
||||||
AddItem(position, 0, 2, false)
|
if positionVisible {
|
||||||
|
flex.AddItem(statusLineWidget, 0, 2, false)
|
||||||
|
}
|
||||||
editArea = tview.NewTextArea().
|
editArea = tview.NewTextArea().
|
||||||
SetPlaceholder("Replace msg...")
|
SetPlaceholder("Replace msg...")
|
||||||
editArea.SetBorder(true).SetTitle("input")
|
editArea.SetBorder(true).SetTitle("input")
|
||||||
@@ -749,6 +775,14 @@ func init() {
|
|||||||
textView.SetText(chatToText(cfg.ShowSys))
|
textView.SetText(chatToText(cfg.ShowSys))
|
||||||
colorText()
|
colorText()
|
||||||
}
|
}
|
||||||
|
if event.Key() == tcell.KeyRune && event.Rune() == '6' && event.Modifiers()&tcell.ModAlt != 0 {
|
||||||
|
// toggle status line visibility
|
||||||
|
if name, _ := pages.GetFrontPage(); name != "main" {
|
||||||
|
return event
|
||||||
|
}
|
||||||
|
positionVisible = !positionVisible
|
||||||
|
updateFlexLayout()
|
||||||
|
}
|
||||||
if event.Key() == tcell.KeyF1 {
|
if event.Key() == tcell.KeyF1 {
|
||||||
// chatList, err := loadHistoryChats()
|
// chatList, err := loadHistoryChats()
|
||||||
chatList, err := store.GetChatByChar(cfg.AssistantRole)
|
chatList, err := store.GetChatByChar(cfg.AssistantRole)
|
||||||
@@ -841,16 +875,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// focused is the fullscreened widget here
|
// focused is the fullscreened widget here
|
||||||
flex.Clear().
|
updateFlexLayout()
|
||||||
AddItem(textView, 0, 40, false).
|
|
||||||
AddItem(textArea, 0, 10, false).
|
|
||||||
AddItem(position, 0, 2, false)
|
|
||||||
|
|
||||||
if focused == textView {
|
|
||||||
app.SetFocus(textView)
|
|
||||||
} else { // default to textArea
|
|
||||||
app.SetFocus(textArea)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user