1 Commits
Author SHA1 Message Date
clawbot e9badcd41c Show the connection state in the neoirc-cli status bar (closes #229)
check / check (push) Canceled after 0s
The status bar had colour tags turned on, so tview read "[connected]"
and "[disconnected]" as tags and dropped them. It dropped all or part
of a nick, a target or a window name holding square brackets the same
way.

The status bar now has colour tags turned off. It wrote none of its
own, so every bracket shows as it is. TestStartUp checks that the
status bar shows [disconnected] at start-up. TestStatusBar checks
[connected], and checks nicks and a /query target that hold brackets.

Model: opus-5-5
2026-11-02 01:34:41 +00:00
2 changed files with 24 additions and 9 deletions
+18 -2
View File
@@ -465,6 +465,21 @@ 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 {
@@ -570,8 +585,9 @@ func bufferState(ui *UI, name string) (int, int) {
return lines, unread
}
// statusBarText returns the text the status bar shows, without
// its colour tags.
// statusBarText returns the text the status bar shows.
// GetText(true) leaves out whatever tview reads as a tag, as
// drawing does.
func statusBarText(ui *UI) string {
var text string
+6 -7
View File
@@ -226,8 +226,10 @@ func (ui *UI) initMessages() {
}
func (ui *UI) initStatusBar() {
ui.statusBar = tview.NewTextView().
SetDynamicColors(true)
// 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.SetBackgroundColor(tcell.ColorNavy)
ui.statusBar.SetTextColor(tcell.ColorWhite)
}
@@ -332,13 +334,10 @@ func (ui *UI) renderStatusBar(
ui.statusBar.Clear()
// 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(
_, _ = fmt.Fprintf(ui.statusBar,
" [%s] %s %s %s%s",
connStatus, nick, bufInfo, target, unread,
)))
)
}
func (ui *UI) getOrCreateBuffer(name string) *Buffer {