Documentation
¶
Index ¶
- Constants
- func AltScreen()
- func ExitAltScreen()
- func LogToFile(path string, prefix string) (*os.File, error)
- func UseSysLog(programName string) error
- type Cmd
- func Batch(cmds ...Cmd) Cmd
- func Every(duration time.Duration, fn func(time.Time) Msg) Cmd
- func ScrollDown(newLines []string, topBoundary, bottomBoundary int) Cmd
- func ScrollUp(newLines []string, topBoundary, bottomBoundary int) Cmd
- func SyncScrollArea(lines []string, topBoundary int, bottomBoundary int) Cmd
- func Tick(d time.Duration, fn func(time.Time) Msg) Cmd
- type Init
- type Key
- type KeyMsg
- type KeyType
- type Model
- type Msg
- type Program
- type Update
- type View
- type WindowSizeMsg
Constants ¶
const ( KeyNull = keyNUL KeyBreak = keyETX KeyEnter = keyCR KeyBackspace = keyBS KeyTab = keyHT KeySpace = keySP KeyEsc = keyESC KeyEscape = keyESC KeyDelete = keyDEL KeyCtrlAt = keyNUL // ctrl+@ KeyCtrlA = keySOH KeyCtrlB = keySTX KeyCtrlC = keyETX KeyCtrlD = keyEOT KeyCtrlE = keyENQ KeyCtrlF = keyACK KeyCtrlG = keyBEL KeyCtrlH = keyBS KeyCtrlI = keyHT KeyCtrlJ = keyLF KeyCtrlK = keyVT KeyCtrlL = keyFF KeyCtrlM = keyCR KeyCtrlN = keySO KeyCtrlO = keySI KeyCtrlP = keyDLE KeyCtrlQ = keyDC1 KeyCtrlR = keyDC2 KeyCtrlS = keyDC3 KeyCtrlT = keyDC4 KeyCtrlU = keyNAK KeyCtrlV = keyETB KeyCtrlW = keyETB KeyCtrlX = keyCAN KeyCtrlY = keyEM KeyCtrlZ = keySUB KeyCtrlOpenBracket = keyESC // ctrl+[ KeyCtrlBackslash = keyFS // ctrl+\ KeyCtrlCloseBracket = keyGS // ctrl+] KeyCtrlCaret = keyRS // ctrl+^ KeyCtrlUnderscore = keyUS // ctrl+_ KeyCtrlQuestionMark = keyDEL // ctrl+? )
Aliases
const ( KeyRune = -(iota + 1) KeyUp KeyDown KeyRight KeyLeft KeyShiftTab KeyHome KeyEnd KeyPgUp KeyPgDown )
Other keys we track
Variables ¶
This section is empty.
Functions ¶
func LogToFile ¶
LogToFile sets up default logging to log to a file This is helpful as we can't print to the terminal since our TUI is occupying it. If the file doesn't exist it will be created.
Don't forget to close the file when you're done with it.
f, err := LogToFile("debug.log", "debug")
if err != nil {
fmt.Println("fatal:", err)
os.Exit(1)
}
defer f.Close()
Types ¶
type Cmd ¶
type Cmd func() Msg
Cmd is an IO operation. If it's nil it's considered a no-op. Keep in mind that there's almost never a need to use a command to send a message to another part of your program.
func Batch ¶
Batch peforms a bunch of commands concurrently with no ordering guarantees about the results.
func Every ¶
Every is a command that ticks in sync with the system clock. So, if you wanted to tick with the system clock every second, minute or hour you could use this. It's also handy for having different things tick in sync.
Because we're ticking with the system clock the tick will likely not run for the entire specified duration. For example, if we're ticking for one minute and the clock is at 12:34:20 then the next tick will happen at 12:35:00, 40 seconds later.
func ScrollDown ¶ added in v0.9.0
ScrollDown adds lines to the bottom of the scrollable region, pushing lines above up. Lines that are pushed out of the scrollable region disappear from view.
For high-performance, scroll-based rendering only.
func ScrollUp ¶ added in v0.9.0
ScrollUp adds lines to the top of the scrollable region, pushing lines below down. Lines that are pushed out the scrollable region disappear from view.
For high-performance, scroll-based rendering only.
func SyncScrollArea ¶ added in v0.9.0
SyncScrollArea performs a paint of the entire scroll area. This is required to initialize the scrollable region and should also be called on resize (WindowSizeMsg).
For high-performance, scroll-based rendering only.
type Init ¶
Init is the first function that will be called. It returns your initial model and runs an optional command.
type KeyMsg ¶
type KeyMsg Key
KeyMsg contains information about a keypress.
type Msg ¶
type Msg interface{}
Msg represents an action and is usually the result of an IO operation. It's triggers the Update function, and henceforth, the UI.
func ClearScrollArea ¶ added in v0.9.0
func ClearScrollArea() Msg
ClearScrollArea deallocates the scrollable region and returns the control of those lines to the main rendering routine.
For high-performance, scroll-based rendering only.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program is a terminal user interface.
func NewProgram ¶
NewProgram creates a new Program.
type Update ¶
Update is called when a message is received. It may update the model and/or send a command.
type WindowSizeMsg ¶ added in v0.9.0
WindowSizeMsg is used to report on the terminal size. It's sent once initially and then on every terminal resize.