mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
The screens after the login (menus, message areas, reading and writing, mail, file areas, who's online, the user list, system info, the profile and SSH keys, validation, paging the sysop) were written twice, once for text terminals and once for 3270s. They are now written once in internal/app, as descriptions in internal/view's terms (menus, tables, messages, forms, panels, drafts), and each front end draws them its own way: prompts and keys a page at a time (RIP buttons for menus) on a text terminal, fields and PF keys on a 3270. What only a front end can do stays with it, behind app.Frontend: the logins, display files, chat, doors, transfers (protocols, or IND$FILE), the terminal's line on the profile and the goodbye. The 3270 gains what it lacked: the main menu by letter like the text BBS's, a new scan, messages to other nodes from who's online, validation, SSH keys, editing and removing files, paging with a message left when the sysop is away. The text prompts are as before. Tests: internal/app driven by a scripted front end; the column layout and text key labels; a 3270 (s3270) through areas, posting, reading and the profile, with a text caller reading its post. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
83 lines
2.0 KiB
Go
83 lines
2.0 KiB
Go
package textui
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/Neo-Desktop/bbs-sec/internal/bbs"
|
|
)
|
|
|
|
// notify is the terminal's Notify: what other nodes sent, shown at any
|
|
// prompt (in chat, as the room's lines; elsewhere, marked out).
|
|
func (s *session) notify() []string {
|
|
t := s.t
|
|
var out []string
|
|
for _, e := range s.n.Pending() {
|
|
line := bbs.Trunc(e.String(), 400)
|
|
switch {
|
|
case s.chatting && e.Kind == bbs.Said:
|
|
out = append(out, t.C(Cyan, e.From+":")+" "+e.Text)
|
|
case s.chatting && e.Kind != bbs.Private && e.Kind != bbs.Paged:
|
|
out = append(out, t.C(Dim, line))
|
|
default:
|
|
out = append(out, t.C(Yellow, "** "+line+" **"))
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// Chat is the chat rooms, from room (the main one if ""), the note first.
|
|
func (s *session) Chat(room, note string) error {
|
|
t := s.t
|
|
if note != "" {
|
|
t.Println(t.C(Green, note))
|
|
}
|
|
if room == "" {
|
|
room = bbs.MainRoom
|
|
}
|
|
t.Println("")
|
|
t.Println(t.C(Cyan, "Chat") + t.C(Dim, " (/help for commands, /quit to leave)"))
|
|
hist, err := s.n.JoinRoom(room)
|
|
if err != nil {
|
|
t.Println(t.C(Red, err.Error()+"."))
|
|
return nil
|
|
}
|
|
s.chatting = true
|
|
defer func() {
|
|
s.chatting = false
|
|
s.n.LeaveRoom()
|
|
}()
|
|
for _, e := range hist {
|
|
t.Println(t.C(Dim, e.String()))
|
|
}
|
|
t.Println(t.C(Dim, "You are in "+s.n.Room()+"."))
|
|
for {
|
|
s.n.Doing("Chatting in " + s.n.Room())
|
|
t.Print(t.C(Green, "> "))
|
|
l, err := t.ReadLine(LineOpts{Max: min(bbs.MaxChatLine, max(t.Cols-3, 20))})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
text := strings.TrimSpace(l.Text)
|
|
if t.ANSI && text != "" && !strings.HasPrefix(text, "/") {
|
|
// what was typed comes back as the room's line: not twice
|
|
t.w.WriteString("\x1b[A\r\x1b[K")
|
|
}
|
|
out, leave, err := s.n.ChatCommand(text)
|
|
for _, o := range out {
|
|
t.Println(t.C(Dim, o))
|
|
}
|
|
if err != nil {
|
|
t.Println(t.C(Red, err.Error()+"."))
|
|
}
|
|
if leave {
|
|
if s.n.Room() == fmt.Sprintf("sysop-%d", s.n.Num) {
|
|
s.n.CancelPage()
|
|
}
|
|
t.Println(t.C(Dim, "You left the chat."))
|
|
return nil
|
|
}
|
|
t.notices()
|
|
}
|
|
}
|