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(title string, choices []string, def int) int
- func ChoiceIndexCallback(title string, choices []string, def int, f func(int, int, int)) int
- func ClearLine(sx, y int)
- func DisplayScreenMessage(messages ...string)
- func DynamicPromptWithCallback(prompt string, refresh func(int, int), callback func(string, string) string) string
- func Edit(defval, prompt string, refresh func(int, int)) string
- func EditDynamicWithCallback(defval, prompt string, refresh func(int, int), ...) string
- func GetRawChar(refresh func(int, int)) string
- func IsControl(ru rune) bool
- func ParseTermboxEvent(ev termbox.Event) string
- func PressKey(p string, refresh func(int, int), keys ...string) string
- func PrintRune(x, y int, ru rune, col termbox.Attribute)
- func PrintRuneBgFg(x, y int, ru rune, fg, bg termbox.Attribute)
- func PrintStringFgBg(x, y int, s string, fg, bg termbox.Attribute)
- func Printstring(s string, x, y int)
- func PrintstringColored(color termbox.Attribute, s string, x, y int)
- func Prompt(prompt string, refresh func(int, int)) string
- func PromptWithCallback(prompt string, refresh func(int, int), callback func(string, string)) string
- func Runewidth(ru rune) int
- func RunewidthStr(s string) int
- func WordCharacter(c rune) bool
- func YesNo(p string, refresh func(int, int)) bool
- func YesNoCancel(p string, refresh func(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 ¶
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(sx, y int)
Pass the screenwidth and a line number; this function will clear the given line.
func DisplayScreenMessage ¶
func DisplayScreenMessage(messages ...string)
Prints all strings given to the screen, and allows the user to scroll through, rather like less(1).
func DynamicPromptWithCallback ¶
func DynamicPromptWithCallback(prompt string, refresh func(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(defval, prompt string, refresh func(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 ParseTermboxEvent ¶
func ParseTermboxEvent(ev termbox.Event) string
Parses a termbox.EventKey event and returns it as an emacs-ish keybinding string (e.g. "C-c", "LEFT", "TAB", etc.)
func PrintRuneBgFg ¶
Print the rune with reverse colors for control characters
func PrintStringFgBg ¶
Print string with an FG and a BG; API mimicking termbox itself
func Printstring ¶
Prints the string given on the screen. Uses the above functions to choose how it appears.
func PrintstringColored ¶
Same as Printstring, but passes a color to PrintRune.
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(prompt string, refresh func(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.