1 Commits
Author SHA1 Message Date
clawbot d1cb9f8044 Show the connection state in the neoirc-cli status bar (closes #229)
check / check (push) Canceled after 0s
The status bar has colour tags turned on, so tview read "[connected]"
and "[disconnected]" as colour names and dropped them. It dropped the
bracketed part of a nick such as "erin[away]" the same way.

renderStatusBar now passes the whole status line through tview.Escape,
so every bracket shows as it is. TestStartUp checks that the status
bar shows [disconnected] at start-up. TestStatusBar checks [connected]
with plain nicks and with nicks that hold brackets.

Model: opus-5-5
2026-11-02 01:14:37 +00:00
2 changed files with 9 additions and 24 deletions
+2 -18
View File
@@ -465,21 +465,6 @@ func TestStatusBar(t *testing.T) {
unread: "dave[afk]",
want: " [connected] erin[away] [1:bob[m]] bob[m] [Act: 2:dave[afk](1)]",
},
{
name: "nicks with brackets and symbols",
nick: "bob[|[]",
target: "x[^[]",
unread: testOtherNick,
want: " [connected] bob[|[] [1:x[^[]] x[^[] [Act: 2:bob(1)]",
},
{
// /query takes any text as the target.
name: "query target with brackets",
nick: testNick,
target: "[:::y|z]",
unread: testOtherNick,
want: " [connected] erin [1:[:::y|z]] [:::y|z] [Act: 2:bob(1)]",
},
}
for _, test := range tests {
@@ -585,9 +570,8 @@ func bufferState(ui *UI, name string) (int, int) {
return lines, unread
}
// statusBarText returns the text the status bar shows.
// GetText(true) leaves out whatever tview reads as a tag, as
// drawing does.
// statusBarText returns the text the status bar shows, without
// its colour tags.
func statusBarText(ui *UI) string {
var text string
+7 -6
View File
@@ -226,10 +226,8 @@ func (ui *UI) initMessages() {
}
func (ui *UI) initStatusBar() {
// Colour tags stay off. With them on, tview reads text in
// square brackets, such as "[connected]" or part of a nick,
// as a tag and drops it.
ui.statusBar = tview.NewTextView()
ui.statusBar = tview.NewTextView().
SetDynamicColors(true)
ui.statusBar.SetBackgroundColor(tcell.ColorNavy)
ui.statusBar.SetTextColor(tcell.ColorWhite)
}
@@ -334,10 +332,13 @@ func (ui *UI) renderStatusBar(
ui.statusBar.Clear()
_, _ = fmt.Fprintf(ui.statusBar,
// The status bar has colour tags turned on, so tview would read
// "[connected]", or a name in square brackets, as a colour tag
// and drop it. Escape makes it show every bracket as it is.
_, _ = fmt.Fprint(ui.statusBar, tview.Escape(fmt.Sprintf(
" [%s] %s %s %s%s",
connStatus, nick, bufInfo, target, unread,
)
)))
}
func (ui *UI) getOrCreateBuffer(name string) *Buffer {