Documentation
¶
Index ¶
- Constants
- func Code(lexerName, styleName string, lineLimit, tabSize int) string
- func Confirm(question string) (confirmed bool)
- func CookedMode()
- func Integer(question string) (answer int, err error)
- func Password() (passHash string, err error)
- func RawKeys() (keys iter.Seq[Key])
- func RawMode() (err error)
- func SetOnEntered(listener func())
- func SetOnSelected(listener func())
- func String(question string) (answer string, err error)
- func UnsetOnEntered()
- func UnsetOnSelected()
- type Choice
- type Key
Constants ¶
const NO_RESULT = -1
Variables ¶
This section is empty.
Functions ¶
func Code ¶
Creates a small code editor with syntax highlighting and line numbers. Does not work with screen scrolling, thus is best for small snippits of code.
func CookedMode ¶
func CookedMode()
Enter cooked terminal mode, meaning key presses are only received after pressing enter. Does nothing if it's already in cooked mode.
func Password ¶
Prompts the user to enter a password. The password is not display password in terminal. The password is hashed before being returned.
func RawKeys ¶
Enters raw terminal mode and then gets key press as an iterator. Whenever pulling from the iterator the program will pause until the next key press. The returned iterator must be stopped to exit raw mode. Will immediately terminate the program with code 0 if the user enters ctrl+c.
func RawMode ¶
func RawMode() (err error)
Enter raw terminal mode, meaning each key press are received one by one. Does nothing if it's already in raw mode.
func SetOnEntered ¶
func SetOnEntered(listener func())
func SetOnSelected ¶
func SetOnSelected(listener func())
func UnsetOnEntered ¶
func UnsetOnEntered()
func UnsetOnSelected ¶
func UnsetOnSelected()
Types ¶
type Choice ¶
type Choice struct {
// contains filtered or unexported fields
}
func (*Choice) Ask ¶
Ask the user, replacing any older selection. May fail to select anything, leaving the result as NO_RESULT.
func (*Choice) ResultIndex ¶
Gets the index of the selected option, asking the user if needed. Returns NO_RESULT if failed to select anything.
func (*Choice) ResultString ¶
Get the string of the selected option, asking the user if needed. Returns an empty string if failed to select anything.
type Key ¶
type Key uint64
const ( KEY_SPACE Key = iota + 32 KEY_EXCLAMATION KEY_QUOTATION_MARK KEY_HASH KEY_DOLLAR KEY_PERCENT KEY_AMPERSAND KEY_APOSTROPHE KEY_LEFT_PARENTHESIS KEY_RIGHT_PARENTHESIS KEY_ASTERISK KEY_PLUS_SIGN KEY_COMMA KEY_HYPHEN KEY_PERIOD KEY_SLASH KEY_ZERO KEY_ONE KEY_TWO KEY_THREE KEY_FOUR KEY_FIVE KEY_SIX KEY_SEVEN KEY_EIGHT KEY_NINE KEY_COLON KEY_SEMICOLON KEY_LESS_THAN KEY_EQUAL KEY_GREATER_THAN KEY_QUESTION_MARK KEY_AT_SIGN KEY_SHIFT_A KEY_SHIFT_B KEY_SHIFT_C KEY_SHIFT_D KEY_SHIFT_E KEY_SHIFT_F KEY_SHIFT_G KEY_SHIFT_H KEY_SHIFT_I KEY_SHIFT_J KEY_SHIFT_K KEY_SHIFT_L KEY_SHIFT_M KEY_SHIFT_N KEY_SHIFT_O KEY_SHIFT_P KEY_SHIFT_Q KEY_SHIFT_R KEY_SHIFT_S KEY_SHIFT_T KEY_SHIFT_U KEY_SHIFT_V KEY_SHIFT_W KEY_SHIFT_X KEY_SHIFT_Y KEY_SHIFT_Z KEY_LEFT_SQUARE_BRACKET KEY_BACK_SLASH KEY_RIGHT_SQUARE_BRACKET KEY_EXPONENT KEY_UNDERSCORE KEY_GRAVE KEY_A KEY_B KEY_C KEY_D KEY_E KEY_F KEY_G KEY_H KEY_I KEY_J KEY_K KEY_L KEY_M KEY_N KEY_O KEY_P KEY_Q KEY_R KEY_S KEY_T KEY_U KEY_V KEY_W KEY_X KEY_Y KEY_Z KEY_LEFT_CURLY_BRACE KEY_PIPE KEY_RIGHT_CURLY_BRASE KEY_TILDE KEY_BACKSPACE )