summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-12-14 14:43:00 +0300
committerGrail Finder <wohilas@gmail.com>2025-12-14 14:43:00 +0300
commitedbacb813bd148db33d8747ada293ef2acabe7e9 (patch)
treebb9efad10ae4421725c1555bf5700455e21ee90c
parent82ffc364d34f4906ef4c4c1bd4bd202d393a46bc (diff)
Enha: toggle visibility of status line
-rw-r--r--helpfuncs.go2
-rw-r--r--tui.go57
2 files changed, 42 insertions, 17 deletions
diff --git a/helpfuncs.go b/helpfuncs.go
index df49ae5..edcb7fe 100644
--- a/helpfuncs.go
+++ b/helpfuncs.go
@@ -63,7 +63,7 @@ func colorText() {
}
func updateStatusLine() {
- position.SetText(makeStatusLine())
+ statusLineWidget.SetText(makeStatusLine())
helpView.SetText(fmt.Sprintf(helpText, makeStatusLine()))
}
diff --git a/tui.go b/tui.go
index 383d680..941371b 100644
--- a/tui.go
+++ b/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
}