Enha: toggle visibility of status line
This commit is contained in:
@@ -63,7 +63,7 @@ func colorText() {
|
||||
}
|
||||
|
||||
func updateStatusLine() {
|
||||
position.SetText(makeStatusLine())
|
||||
statusLineWidget.SetText(makeStatusLine())
|
||||
helpView.SetText(fmt.Sprintf(helpText, makeStatusLine()))
|
||||
}
|
||||
|
||||
|
||||
57
tui.go
57
tui.go
@@ -23,7 +23,7 @@ var (
|
||||
textArea *tview.TextArea
|
||||
editArea *tview.TextArea
|
||||
textView *tview.TextView
|
||||
position *tview.TextView
|
||||
statusLineWidget *tview.TextView
|
||||
helpView *tview.TextView
|
||||
flex *tview.Flex
|
||||
imgView *tview.Image
|
||||
@@ -32,6 +32,7 @@ var (
|
||||
renameWindow *tview.InputField
|
||||
roleEditWindow *tview.InputField
|
||||
fullscreenMode bool
|
||||
positionVisible bool = true
|
||||
// pages
|
||||
historyPage = "historyPage"
|
||||
agentPage = "agentPage"
|
||||
@@ -87,6 +88,7 @@ var (
|
||||
[yellow]Alt+1[white]: toggle shell mode (execute commands locally)
|
||||
[yellow]Alt+4[white]: edit msg role
|
||||
[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) ===
|
||||
[yellow]arrows up/down and j/k[white]: scroll up and down
|
||||
@@ -171,6 +173,26 @@ func toggleShellMode() {
|
||||
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) {
|
||||
// Parse the command (split by spaces, but handle quoted arguments)
|
||||
cmdParts := parseCommand(cmdText)
|
||||
@@ -456,8 +478,10 @@ func init() {
|
||||
//
|
||||
flex = tview.NewFlex().SetDirection(tview.FlexRow).
|
||||
AddItem(textView, 0, 40, false).
|
||||
AddItem(textArea, 0, 10, true). // Restore original height
|
||||
AddItem(position, 0, 2, false)
|
||||
AddItem(textArea, 0, 10, true) // Restore original height
|
||||
if positionVisible {
|
||||
flex.AddItem(statusLineWidget, 0, 2, false)
|
||||
}
|
||||
// textView.SetBorder(true).SetTitle("chat")
|
||||
textView.SetDoneFunc(func(key tcell.Key) {
|
||||
if key == tcell.KeyEnter {
|
||||
@@ -516,14 +540,16 @@ func init() {
|
||||
})
|
||||
focusSwitcher[textArea] = textView
|
||||
focusSwitcher[textView] = textArea
|
||||
position = tview.NewTextView().
|
||||
statusLineWidget = tview.NewTextView().
|
||||
SetDynamicColors(true).
|
||||
SetTextAlign(tview.AlignCenter)
|
||||
// Initially set up flex without search bar
|
||||
flex = tview.NewFlex().SetDirection(tview.FlexRow).
|
||||
AddItem(textView, 0, 40, false).
|
||||
AddItem(textArea, 0, 10, true). // Restore original height
|
||||
AddItem(position, 0, 2, false)
|
||||
AddItem(textArea, 0, 10, true) // Restore original height
|
||||
if positionVisible {
|
||||
flex.AddItem(statusLineWidget, 0, 2, false)
|
||||
}
|
||||
editArea = tview.NewTextArea().
|
||||
SetPlaceholder("Replace msg...")
|
||||
editArea.SetBorder(true).SetTitle("input")
|
||||
@@ -749,6 +775,14 @@ func init() {
|
||||
textView.SetText(chatToText(cfg.ShowSys))
|
||||
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 {
|
||||
// chatList, err := loadHistoryChats()
|
||||
chatList, err := store.GetChatByChar(cfg.AssistantRole)
|
||||
@@ -841,16 +875,7 @@ func init() {
|
||||
}
|
||||
} else {
|
||||
// focused is the fullscreened widget here
|
||||
flex.Clear().
|
||||
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)
|
||||
}
|
||||
updateFlexLayout()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user