Documentation
¶
Overview ¶
Package ui is the fullscreen Bubble Tea interface: the splash and the first run's login form, then the status bar, transcript and input line. The transcript keeps its own history rather than the terminal's, so paging keys and spoiler re-rendering are handled here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDoorClosed = errors.New("login form closed")
ErrDoorClosed is what a prompt returns once the UI has gone: the user quit at the login form, or the program ended under it. The login flow aborts on it like on any prompter error.
var Keys = []Key{
{"enter", "send"},
{"tab", "complete @names, /commands, ng emotes, :emoji"},
{"pgup/pgdn", "scroll a page"},
{"up/down", "scroll a line (the mouse wheel, where it sends arrows)"},
{"end", "jump to the newest message"},
{"home", "jump to the oldest, on an empty line"},
{"ctrl+p/ctrl+n", "recall earlier messages you sent, and back"},
{"ctrl+s", "reveal or hide spoilers"},
{"ctrl+t", "show or hide timestamps"},
{"ctrl+r", "show or hide the roster pane"},
{"/who", "list who is in the channel"},
{"f1, /keys", "show this list"},
{"ctrl+c", "quit; also ctrl+d on an empty line, or /quit"},
}
Keys is the key card. F1, the local /keys and `ngchat -help` all draw it from here, so the three cannot drift apart; a key added to Model.update's switch belongs here too. The completion list's own keys are left out: its header names them while it is open.
Functions ¶
Types ¶
type Door ¶
type Door struct {
// contains filtered or unexported fields
}
Door is the other end of the login form. auth.Login runs on Start's goroutine, off the UI loop, and blocks in Line and Secret until the form answers; the lines it writes (the help under each prompt, a wrong password, where the credential was stored) arrive through Write. Door satisfies auth.Prompter and io.Writer for exactly that.
It is a pointer shared between main and the Model, which Bubble Tea copies on every Update, so all of its state is the channel and the close guard. Nothing is buffered: a prompt or a line waits until the loop pumps it (waitDoor), and Close releases every waiter.
func NewDoor ¶
func NewDoor() *Door
NewDoor returns an open Door. Pass it as Options.Door and as the prompter and writer the login Start runs.
func (*Door) Close ¶
func (d *Door) Close()
Close releases any prompt or write still waiting, with ErrDoorClosed. main calls it once the program has returned; calling it again is a no-op.
func (*Door) Line ¶
Line asks for a visible field and returns it trimmed, as the terminal prompter does.
type Key ¶
type Key struct {
Press, Does string
}
Key is one line of the key card: what to press, and what it does.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the Bubble Tea root model.
func (Model) Abandoned ¶
Abandoned reports whether the program ended before Start answered: the user quit at the login form, or while the run was starting.
func (Model) Denied ¶
Denied returns the server's entry-gate notice (supporter-only, under 18, e-mail not validated, banned) as terminal text when that is why the client stopped, else "". main prints it after the program exits: the notice is the whole answer and nothing in the TUI can act on it.
func (Model) SignedOut ¶
SignedOut reports whether the client stopped because the site refused the remember cookie. main reads it after the program exits.
func (Model) StartErr ¶
StartErr is why Options.Start could not start the run (a bad chat URL, a login the site refused for good), or nil. main prints it after the program exits.
func (Model) Unshown ¶
Unshown returns the login's lines that never reached the screen: the run ended before the join that would have put them in the transcript. main prints them, since one may be where the credential was stored.
type Options ¶
type Options struct {
// Channel is the name shown in the status bar and placeholder.
Channel string
// Quiet suppresses the terminal bell and the desktop notification
// on mentions and DMs.
Quiet bool
// Theme colors the screen; the zero value means theme.Default().
Theme theme.Theme
// LightTheme, when set, replaces Theme if the terminal reports a
// light background. Leave it zero when the user named a theme: an
// explicit choice is never second-guessed. A terminal that does not
// answer the query keeps Theme.
LightTheme theme.Theme
// Splash is the opening animation; nil plays none.
Splash splash.Effect
// UpdateNotice, when set, runs once off the UI loop at startup and
// returns a line announcing a newer release, or "" for none. It may
// block on the network; the UI never waits for it.
UpdateNotice func() string
// Start, when set and New was given no client, prepares the run and
// starts the client off the UI loop, so the splash plays from the
// first frame instead of after a login on stdin. An error ends the
// program; StartErr returns it for main to print.
Start func() (*client.Client, error)
// Door is the login form Start's login talks to, when it may ask
// for one. Lines written to it with no form up wait for the join
// and land in the transcript, like the release notice.
Door *Door
// ShowTimes starts the transcript with timestamps on; ctrl+t still
// toggles them. It is how NGCHAT_TIMES outlives a launch.
ShowTimes bool
}
Options configures the UI beyond the client it wraps.