Documentation
¶
Overview ¶
These are some nice functions torn out of Gomacs which I think are better suited to be out of the project for reuse. It's imported as termutil.
Index ¶
- func ChoiceIndex(screen tcell.Screen, title string, choices []string, def int) int
- func ChoiceIndexCallback(screen tcell.Screen, title string, choices []string, def int, ...) int
- func ClearLine(screen tcell.Screen, sx, y int)
- func DisplayScreenMessage(screen tcell.Screen, messages ...string)
- func DynamicPromptWithCallback(screen tcell.Screen, prompt string, refresh func(tcell.Screen, int, int), ...) string
- func Edit(screen tcell.Screen, defval, prompt string, ...) string
- func EditDynamicWithCallback(screen tcell.Screen, defval, prompt string, ...) string
- func IsControl(ru rune) bool
- func ParseTcellEvent(ev *tcell.EventKey) string
- func PickColor(screen tcell.Screen, prompt string) tcell.Color
- func PressKey(screen tcell.Screen, p string, refresh func(tcell.Screen, int, int), ...) string
- func PrintRune(screen tcell.Screen, x, y int, ru rune)
- func PrintRuneStyle(screen tcell.Screen, x, y int, ru rune, style tcell.Style)
- func PrintString(screen tcell.Screen, x, y int, s string)
- func PrintStringStyle(screen tcell.Screen, x, y int, s string, style tcell.Style)
- func Prompt(screen tcell.Screen, prompt string, refresh func(tcell.Screen, int, int)) string
- func PromptWithCallback(screen tcell.Screen, prompt string, refresh func(tcell.Screen, int, int), ...) string
- func Runewidth(ru rune) int
- func RunewidthStr(s string) int
- func WordCharacter(c rune) bool
- func YesNo(screen tcell.Screen, p string, refresh func(tcell.Screen, int, int)) bool
- func YesNoCancel(screen tcell.Screen, p string, refresh func(tcell.Screen, int, int)) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChoiceIndex ¶
Allows the user to select one of many choices displayed on-screen. Takes a title, choices, and default selection. Returns an index into the choices array; or def (default)
func ChoiceIndexCallback ¶
func ChoiceIndexCallback(screen tcell.Screen, title string, choices []string, def int, f func(tcell.Screen, int, int, int)) int
As ChoiceIndex, but calls a function after drawing the interface, passing it the current selected choice, screen width, and screen height.
func ClearLine ¶
func ClearLine(screen tcell.Screen, sx, y int)
Pass the screenwidth and a line number; this function will clear the given line.
func DisplayScreenMessage ¶
func DisplayScreenMessage(screen tcell.Screen, messages ...string)
Prints all strings given to the screen, and allows the user to scroll through, rather like less(1).
func DynamicPromptWithCallback ¶
func DynamicPromptWithCallback(screen tcell.Screen, prompt string, refresh func(tcell.Screen, int, int), callback func(string, string) string) string
As prompt, but calls a function after every keystroke that can modify the query.
func Edit ¶
Edit takes a default value and a refresh function. It allows the user to edit the default value. It returns what the user entered.
func EditDynamicWithCallback ¶
func EditDynamicWithCallback(screen tcell.Screen, defval, prompt string, refresh func(tcell.Screen, int, int), callback func(string, string) string) string
EditDynamicWithCallback takes a default value, prompt, refresh function, and callback. It allows the user to edit the default value. It returns what the user entered.
func ParseTcellEvent ¶
func ParseTcellEvent(ev *tcell.EventKey) string
Parses a tcell.EventKey event and returns it as an emacs-ish keybinding string (e.g. "C-c", "LEFT", "TAB", etc.)
func PressKey ¶
func PressKey(screen tcell.Screen, p string, refresh func(tcell.Screen, int, int), keys ...string) string
Asks the user to press one of a set of keys. Returns the one which they pressed.
func PrintRuneStyle ¶
Print the rune with reverse colors for control characters
func PrintString ¶
Prints the string given on the screen. Uses the above functions to choose how it appears.
func PrintStringStyle ¶
Print string with a style
func Prompt ¶
Get a string from the user. They can use typical emacs-ish editing commands, or press C-c or C-g to cancel.
func PromptWithCallback ¶
func PromptWithCallback(screen tcell.Screen, prompt string, refresh func(tcell.Screen, int, int), callback func(string, string)) string
As prompt, but calls a function after every keystroke.
func WordCharacter ¶
Indicate whether the given rune is a word character
Types ¶
This section is empty.