Documentation
¶
Index ¶
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 AltScreen ¶
func AltScreen()
AltScreen exits the altscreen. This is just a wrapper around the termenv function
func ExitAltScreen ¶
func ExitAltScreen()
ExitAltScreen exits the altscreen. This is just a wrapper around the termenv function
func LogToFile ¶ added in v0.6.2
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.
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.
Note that 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 GetTerminalSize ¶ added in v0.5.1
func GetTerminalSize(newMsgFunc func(int, int, error) TerminalSizeMsg) Cmd
GetTerminalSize is used to get
func OnResize ¶ added in v0.6.0
OnResize is used to listen for window resizes. Use GetTerminalSize to get the windows dimensions. We don't fetch the window size with this command to avoid a potential performance hit making the necessary system calls, since this command could potentially run a lot. On that note, consider debouncing this function.
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
KeyPressMsg 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.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program is a terminal user interface
func NewProgram ¶
NewProgram creates a new Program
type TerminalSizeMsg ¶ added in v0.5.1
type TerminalSizeMsg interface { // Size returns the terminal width and height, in that order Size() (int, int) // Error returns the error, if any, received when fetching the terminal size Error() error }
TerminalSizeMsg defines an interface for a message that contains terminal sizing as sent by GetTerminalSize.