mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
- Menu takes only an item's key (returned as the item has it), asking again for any other without redrawing, as a 3270 does; Enter is still "" (none chosen: Back would log off from the top menu). view.UI's Menu doc says so. - VT52: ED 1 (erase up to the cursor) was sent as ESC J, erasing below; it is dropped now, as EL 1 is. EL 2 erases the whole line from its start; ED 3 clears like ED 2. - A sheet's key line leaves out 3270 PF-only keys instead of writing a NUL for them. - The full-screen editor cuts a body longer than its line limit. - keyLabel's unreachable branch removed; setTranslator's comment notes that Flush settles the old translator (it already did). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
package textui
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/Neo-Desktop/bbs-sec/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 line names a sheet's keys, leaving out those with
|
|
// a 3270 PF key alone (no NUL for them).
|
|
func TestSheetFoot(t *testing.T) {
|
|
term, c := ansiTerm()
|
|
d := &sheetDraw{t: term, sh: &view.Sheet{Keys: []view.Action{{Key: 'A', Label: "Add"}, {PF: 5, Label: "PFonly"}}}, cur: -1}
|
|
d.drawFoot()
|
|
term.Flush()
|
|
out := c.String()
|
|
if strings.Contains(out, "\x00") || strings.Contains(out, "PFonly") || !strings.Contains(out, "A Add Enter change") {
|
|
t.Errorf("foot %q", out)
|
|
}
|
|
}
|