Files
bbs/internal/textui/view_test.go
T
Claude 4037dff09f Setup screens in the style of 1990s BBS setup programs
The configuration screens (bbs config, and the sysop's Configuration) on
an ANSI terminal are now a shaded blue desk with a menu bar of pull-down
menus, each menu a window cascading over the one it was opened from, the
line's help in a box below and the keys on a bar at the foot.  Values are
typed in boxes that pop up, choices picked from lists, and questions,
help and the save's report come up as dialogs.  Only the cells that
change are sent, and a terminal without UTF-8 gets code page 437.

The menus now reach every front end: Online services (AOL, CompuServe,
MSN 1995), Messengers and chat (AIM/ICQ, MSN Messenger, Yahoo!, IRC and
its links, MRC), E-mail, Networks and doors, and Time, beside Internet
services.  The pull-down menus jump to any of them from anywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRUCKaoTaTTA2EiiN7Z
2026-11-09 05:49:19 +00:00

49 lines
1.6 KiB
Go

package textui
import (
"strings"
"testing"
"github.com/D-Modem/bbs/internal/view"
)
// TestKeyLabel: a key in brackets where it begins a word of its label,
// else before it; actions with no key are left out of the prompt.
func TestKeyLabel(t *testing.T) {
for _, c := range []struct {
key rune
label, out string
}{{'R', "Read new", "[R]ead new"}, {'K', "SSH keys", "SSH [K]eys"}, {'K', "lock", "[K] lock"},
{'+', "add area", "[+] add area"}, {'8', "8-bit UTF-8 on/off", "[8]-bit UTF-8 on/off"},
{'V', "Validate (level 20)", "[V]alidate (level 20)"}} {
if got := keyLabel(view.Action{Key: c.key, Label: c.label}); got != c.out {
t.Errorf("%c %q: %q", c.key, c.label, got)
}
}
if got := keyPrompt([]view.Action{{Key: 'N', Label: "Next"}, {PF: 5, Label: "3270 only"}}); got != "[N]ext, [Q]uit: " {
t.Errorf("prompt %q", got)
}
}
// TestSheetFoot: the key bar names a sheet's keys, leaving out those with
// a 3270 PF key alone (no NUL for them).
func TestSheetFoot(t *testing.T) {
term, _ := ansiTerm()
s := &session{t: term}
s.startDesk()
w := &sheetWin{s: s, sh: &view.Sheet{Title: "T", Keys: []view.Action{{Key: 'A', Label: "Add"}, {PF: 5, Label: "PFonly"}}}, cur: -1}
bar := screenRow(w.frame(), term.Rows-1)
if strings.Contains(bar, "\x00") || strings.Contains(bar, "PFonly") || !strings.Contains(bar, "A Add F9 Quit") {
t.Errorf("key bar %q", bar)
}
}
// screenRow is a screen's row as text.
func screenRow(scr *screen, row int) string {
var b strings.Builder
for x := 0; x < scr.cols; x++ {
b.WriteRune(scr.at(row, x).r)
}
return b.String()
}