Documentation
¶
Overview ¶
Package console owns the virtual terminal while the splash shows: it keeps the kernel's text off the splash, reads keys already mapped by the console's keymap, and shows the splash as text when there is no graphical output.
Index ¶
- Constants
- Variables
- func Screen(lines []string, rows int) []byte
- func UnbindFramebufferConsoles(dir string) ([]string, error)
- type Capture
- type Paths
- type Scrollback
- type TextView
- type VT
- func (v *VT) CapsLock() (bool, error)
- func (v *VT) Graphics() error
- func (v *VT) Leave() error
- func (v *VT) Name() string
- func (v *VT) Read(b []byte) (int, error)
- func (v *VT) Reclaim() error
- func (v *VT) Restore() error
- func (v *VT) Rows() (int, error)
- func (v *VT) Text() error
- func (v *VT) Write(b []byte) (int, error)
Constants ¶
const ( MaxLines = 1000 MaxLineWidth = 512 )
The bounds of a Scrollback.
const ClearScreen = "\x1b[H\x1b[2J"
ClearScreen clears a terminal and puts the cursor top left.
const (
VTConsoles = "/sys/class/vtconsole"
)
Variables ¶
var ErrNoVT = errors.New("console: the kernel has no virtual terminals")
ErrNoVT is what OpenActive wraps on a kernel without virtual terminals.
var SystemPaths = Paths{Sysfs: "/sys/class/tty", Dev: "/dev"}
SystemPaths are the kernel's: /sys/class/tty and /dev.
Functions ¶
Types ¶
type Capture ¶
type Capture struct {
// contains filtered or unexported fields
}
Capture is the console's output redirected into a pseudo-terminal with TIOCCONS, as plymouth's details view takes it: what is written to /dev/console, systemd's status lines among it, reaches Read instead of the console until Restore or Leave gives the console back.
func CaptureConsole ¶
CaptureConsole redirects the console under p.Dev into a new pseudo-terminal. It needs CAP_SYS_ADMIN, and fails while another process holds the console redirected.
func (*Capture) Leave ¶
Leave gives the console back without writing to it, for a splash whose last frame stays on screen, and closes the pseudo-terminal.
type Scrollback ¶
type Scrollback struct {
// contains filtered or unexported fields
}
Scrollback is the console's output as the lines a terminal would show: a carriage return goes back to the start of the line, a backspace back one character and an erase-line sequence clears from the cursor on; other escape sequences and control characters are dropped. It keeps the last MaxLines lines, each cut at MaxLineWidth characters.
func (*Scrollback) Lines ¶
func (s *Scrollback) Lines() []string
Lines are the lines kept, oldest first, the one still being written last when it has anything on it.
func (*Scrollback) Screen ¶
func (s *Scrollback) Screen(rows int) []byte
Screen is what a terminal of rows lines shows of the scrollback: the screen cleared, then the last lines, leaving the bottom row free.
type TextView ¶
TextView shows the splash as text on a terminal, for a machine without graphical output: each message on a line of its own, the update progress, and the prompt on the last line, a question's answer echoed and a password's not.
type VT ¶
type VT struct {
// contains filtered or unexported fields
}
VT is the active virtual terminal, taken over: graphics mode keeps the kernel's text off the splash, and its keyboard reads characters one at a time without echo.
func OpenActive ¶
OpenActive opens the active VT and takes it over. On a kernel without VTs it fails with an error wrapping ErrNoVT.
func (*VT) Graphics ¶
Graphics switches the VT to graphics mode, so the kernel draws no text over the splash.
func (*VT) Leave ¶
Leave gives the keyboard and terminal settings back but keeps graphics mode, so the kernel's console does not draw over a frame the splash leaves on screen, and closes the VT. Only the first Restore or Leave acts.
func (*VT) Reclaim ¶
Reclaim makes the terminal raw and the keyboard unicode again, for when another process reset the VT under the splash: systemd resets the console's terminal when it starts in the real root, which with the console on a VT leaves the splash reading whole lines.
func (*VT) Restore ¶
Restore gives the VT back as it was: its display mode, keyboard mode and terminal settings, then closes it, which also ends a blocked Read. Only the first Restore or Leave acts.