Documentation ¶
Index ¶
Constants ¶
const ( // ActionInit has to be sent to initialize the application. // For xterm-like terminals, this is the `smkx` code. ActionInit = iota // ActionExit has to be sent to close the application. // For xterm-like terminals, this is the `rmkx` code. ActionExit )
const ( // KeyLetter is a single letter. Value is a keycode out of the Basic Latin keymap. KeyLetter = iota // KeySpecial indicates that this key should not be printed, but be interpreted instead. KeySpecial // KeyInvalid is an invalid key, e. g. if an error ocured during parsing. KeyInvalid )
const ( // ModCtrl is or'd to the modifier list if the ctrl key was pressed. // For technical reasons, C-(A-Z) is reported as C-(a-z). ModCtrl = (1 << iota) // ModAlt is or'd to the modifier list if the alt key was pressed. ModAlt // ModShift is or'd to the modifier list if the shift key was pressed. // It is only applicable for special keys. ModShift )
const ( // SpecialBackspace is the key that deletes the character to the left of the cursor. SpecialBackspace = iota // SpecialDelete is the key that deletes the character to the right of the cursor. SpecialDelete // SpecialEnter is the enter / new-line key. SpecialEnter SpecialArrowLeft SpecialArrowRight SpecialArrowUp SpecialArrowDown SpecialHome SpecialEnd SpecialPgUp SpecialPgDown SpecialIns SpecialF1 SpecialF2 SpecialF3 SpecialF4 SpecialF5 SpecialF6 SpecialF7 SpecialF8 SpecialF9 SpecialF10 SpecialF11 SpecialF12 SpecialTab SpecialEscape )
Variables ¶
var ( // ColorDefault resets the terminal to the default color. ColorDefault = Color{SpectrumDefault, 0, 0, 0} // ColorBlack is the black color. ColorBlack = Color{Spectrum8, 0, 0, 0} // ColorRed is the red color. ColorRed = Color{Spectrum8, 1, 0, 0} // ColorGreen is the green color. ColorGreen = Color{Spectrum8, 2, 0, 0} // ColorYellow is the yellow color, mixed from red and green. ColorYellow = Color{Spectrum8, 3, 0, 0} // ColorBlue is the blue color. ColorBlue = Color{Spectrum8, 4, 0, 0} // ColorMagenta is the magenta color, mixed from red and blue. ColorMagenta = Color{Spectrum8, 5, 0, 0} // ColorCyan is the cyan color, mixed from green and blue. ColorCyan = Color{Spectrum8, 6, 0, 0} // ColorWhite is the white color, mixed from red, green and blue. ColorWhite = Color{Spectrum8, 7, 0, 0} // ColorDarkGray is the black color. ColorDarkGray = Color{Spectrum16, 8, 0, 0} // ColorLightRed is the red color. ColorLightRed = Color{Spectrum16, 9, 0, 0} // ColorLightGreen is the green color. ColorLightGreen = Color{Spectrum16, 10, 0, 0} // ColorLightYellow is the yellow color, mixed from red and green. ColorLightYellow = Color{Spectrum16, 11, 0, 0} // ColorLightBlue is the blue color. ColorLightBlue = Color{Spectrum16, 12, 0, 0} // ColorLightMagenta is the magenta color, mixed from red and blue. ColorLightMagenta = Color{Spectrum16, 13, 0, 0} // ColorLightCyan is the cyan color, mixed from green and blue. ColorLightCyan = Color{Spectrum16, 14, 0, 0} // ColorLightGray is even brighter than white, mixed from red, green and blue. ColorLightGray = Color{Spectrum16, 15, 0, 0} )
var ( Color256Black = Color{Spectrum8, 0, 0, 0} Color256Maroon = Color{Spectrum8, 1, 0, 0} Color256Green = Color{Spectrum8, 2, 0, 0} Color256Olive = Color{Spectrum8, 3, 0, 0} Color256Purple = Color{Spectrum8, 5, 0, 0} Color256Teal = Color{Spectrum8, 6, 0, 0} Color256Silver = Color{Spectrum8, 7, 0, 0} Color256Grey = Color{Spectrum8, 8, 0, 0} Color256Red = Color{Spectrum8, 9, 0, 0} Color256Lime = Color{Spectrum8, 10, 0, 0} Color256Yellow = Color{Spectrum8, 11, 0, 0} Color256Blue = Color{Spectrum8, 12, 0, 0} Color256Fuchsia = Color{Spectrum8, 13, 0, 0} Color256Aqua = Color{Spectrum8, 14, 0, 0} Color256White = Color{Spectrum8, 15, 0, 0} Color256Grey0 = Color{Spectrum8, 16, 0, 0} Color256DarkBlue = Color{Spectrum8, 18, 0, 0} Color256Blue3Dark = Color{Spectrum8, 19, 0, 0} Color256Blue3Light = Color{Spectrum8, 20, 0, 0} Color256Blue1 = Color{Spectrum8, 21, 0, 0} Color256DarkGreen = Color{Spectrum8, 22, 0, 0} Color256DeepSkyBlue4Dark = Color{Spectrum8, 23, 0, 0} Color256DeepSkyBlue4Medium = Color{Spectrum8, 24, 0, 0} Color256DeepSkyBlue4Light = Color{Spectrum8, 25, 0, 0} Color256DodgerBlue3 = Color{Spectrum8, 26, 0, 0} Color256DodgerBlue2 = Color{Spectrum8, 27, 0, 0} Color256Green4 = Color{Spectrum8, 28, 0, 0} Color256SpringGreen4 = Color{Spectrum8, 29, 0, 0} Color256Turquoise4 = Color{Spectrum8, 30, 0, 0} Color256DeepSkyBlue3Dark = Color{Spectrum8, 31, 0, 0} Color256DeepSkyBlue3Light = Color{Spectrum8, 32, 0, 0} Color256DodgerBlue1 = Color{Spectrum8, 33, 0, 0} Color256Green3Dark = Color{Spectrum8, 34, 0, 0} Color256SpringGreen3Dark = Color{Spectrum8, 35, 0, 0} Color256DarkCyan = Color{Spectrum8, 36, 0, 0} Color256LightSeaGreen = Color{Spectrum8, 37, 0, 0} Color256DeepSkyBlue2 = Color{Spectrum8, 38, 0, 0} Color256DeepSkyBlue1 = Color{Spectrum8, 39, 0, 0} Color256Green3Light = Color{Spectrum8, 40, 0, 0} Color256SpringGreen3Light = Color{Spectrum8, 41, 0, 0} Color256SpringGreen2Dark = Color{Spectrum8, 42, 0, 0} Color256Cyan3 = Color{Spectrum8, 43, 0, 0} Color256DarkTurquoise = Color{Spectrum8, 44, 0, 0} Color256Turquoise2 = Color{Spectrum8, 45, 0, 0} Color256Green1 = Color{Spectrum8, 46, 0, 0} Color256SpringGreen2Light = Color{Spectrum8, 47, 0, 0} Color256SpringGreen1 = Color{Spectrum8, 48, 0, 0} Color256MediumSpringGreen = Color{Spectrum8, 49, 0, 0} Color256Cyan2 = Color{Spectrum8, 50, 0, 0} Color256Cyan1 = Color{Spectrum8, 51, 0, 0} Color256DarkRedDark = Color{Spectrum8, 52, 0, 0} Color256DeepPink4Dark = Color{Spectrum8, 53, 0, 0} Color256Purple4Dark = Color{Spectrum8, 54, 0, 0} Color256Purple4Light = Color{Spectrum8, 55, 0, 0} Color256Purple3 = Color{Spectrum8, 56, 0, 0} Color256BlueViolet = Color{Spectrum8, 57, 0, 0} Color256Orange4Dark = Color{Spectrum8, 58, 0, 0} Color256Grey37 = Color{Spectrum8, 59, 0, 0} Color256MediumPurple4 = Color{Spectrum8, 60, 0, 0} Color256SlateBlue3Dark = Color{Spectrum8, 61, 0, 0} Color256SlateBlue3Light = Color{Spectrum8, 62, 0, 0} Color256RoyalBlue1 = Color{Spectrum8, 63, 0, 0} Color256Chartreuse4 = Color{Spectrum8, 64, 0, 0} Color256DarkSeaGreen4Dark = Color{Spectrum8, 65, 0, 0} Color256PaleTurquoise4 = Color{Spectrum8, 66, 0, 0} Color256SteelBlue = Color{Spectrum8, 67, 0, 0} Color256SteelBlue3 = Color{Spectrum8, 68, 0, 0} Color256CornflowerBlue = Color{Spectrum8, 69, 0, 0} Color256Chartreuse3Dark = Color{Spectrum8, 70, 0, 0} Color256DarkSeaGreen4Light = Color{Spectrum8, 71, 0, 0} Color256CadetBlueDark = Color{Spectrum8, 72, 0, 0} Color256CadetBlueLight = Color{Spectrum8, 73, 0, 0} Color256SkyBlue3 = Color{Spectrum8, 74, 0, 0} Color256SteelBlue1Dark = Color{Spectrum8, 75, 0, 0} Color256Chartreuse3Light = Color{Spectrum8, 76, 0, 0} Color256PaleGreen3Dark = Color{Spectrum8, 77, 0, 0} Color256SeaGreen3 = Color{Spectrum8, 78, 0, 0} Color256Aquamarine3 = Color{Spectrum8, 79, 0, 0} Color256MediumTurquoise = Color{Spectrum8, 80, 0, 0} Color256SteelBlue1Light = Color{Spectrum8, 81, 0, 0} Color256Chartreuse2Dark = Color{Spectrum8, 82, 0, 0} Color256SeaGreen2 = Color{Spectrum8, 83, 0, 0} Color256SeaGreen1Dark = Color{Spectrum8, 84, 0, 0} Color256SeaGreen1Light = Color{Spectrum8, 85, 0, 0} Color256Aquamarine1Dark = Color{Spectrum8, 86, 0, 0} Color256DarkSlateGray2 = Color{Spectrum8, 87, 0, 0} Color256DarkRedLight = Color{Spectrum8, 88, 0, 0} Color256DeepPink4Medium = Color{Spectrum8, 89, 0, 0} Color256DarkMagentaDark = Color{Spectrum8, 90, 0, 0} Color256DarkMagentaLight = Color{Spectrum8, 91, 0, 0} Color256DarkVioletDark = Color{Spectrum8, 92, 0, 0} Color256Purple2 = Color{Spectrum8, 93, 0, 0} Color256Orange4Light = Color{Spectrum8, 94, 0, 0} Color256LightPink4 = Color{Spectrum8, 95, 0, 0} Color256Plum4 = Color{Spectrum8, 96, 0, 0} Color256MediumPurple3Dark = Color{Spectrum8, 97, 0, 0} Color256MediumPurple3Light = Color{Spectrum8, 98, 0, 0} Color256SlateBlue1 = Color{Spectrum8, 99, 0, 0} Color256Yellow4Dark = Color{Spectrum8, 100, 0, 0} Color256Wheat4 = Color{Spectrum8, 101, 0, 0} Color256Grey53 = Color{Spectrum8, 102, 0, 0} Color256LightSlateGrey = Color{Spectrum8, 103, 0, 0} Color256MediumPurpleDark = Color{Spectrum8, 104, 0, 0} Color256LightSlateBlue = Color{Spectrum8, 105, 0, 0} Color256Yellow4Light = Color{Spectrum8, 106, 0, 0} Color256DarkOliveGreen3Dark = Color{Spectrum8, 107, 0, 0} Color256DarkSeaGreen = Color{Spectrum8, 108, 0, 0} Color256LightSkyBlue3Dark = Color{Spectrum8, 109, 0, 0} Color256LightSkyBlue3Light = Color{Spectrum8, 110, 0, 0} Color256SkyBlue2 = Color{Spectrum8, 111, 0, 0} Color256Chartreuse2Light = Color{Spectrum8, 112, 0, 0} Color256DarkOliveGreen3Light = Color{Spectrum8, 113, 0, 0} Color256PaleGreen3Light = Color{Spectrum8, 114, 0, 0} Color256DarkSeaGreen3Dark = Color{Spectrum8, 115, 0, 0} Color256DarkSlateGray3 = Color{Spectrum8, 116, 0, 0} Color256SkyBlue1 = Color{Spectrum8, 117, 0, 0} Color256Chartreuse1 = Color{Spectrum8, 118, 0, 0} Color256LightGreenDark = Color{Spectrum8, 119, 0, 0} Color256LightGreenLight = Color{Spectrum8, 120, 0, 0} Color256PaleGreen1Dark = Color{Spectrum8, 121, 0, 0} Color256Aquamarine1Light = Color{Spectrum8, 122, 0, 0} Color256DarkSlateGray1 = Color{Spectrum8, 123, 0, 0} Color256Red3Dark = Color{Spectrum8, 124, 0, 0} Color256DeepPink4Light = Color{Spectrum8, 125, 0, 0} Color256MediumVioletRed = Color{Spectrum8, 126, 0, 0} Color256Magenta3 = Color{Spectrum8, 127, 0, 0} Color256DarkVioletLight = Color{Spectrum8, 128, 0, 0} Color256PurpleLight = Color{Spectrum8, 129, 0, 0} Color256DarkOrange3Dark = Color{Spectrum8, 130, 0, 0} Color256IndianRedDark = Color{Spectrum8, 131, 0, 0} Color256HotPink3Dark = Color{Spectrum8, 132, 0, 0} Color256MediumOrchid3 = Color{Spectrum8, 133, 0, 0} Color256MediumOrchid = Color{Spectrum8, 134, 0, 0} Color256MediumPurple2Dark = Color{Spectrum8, 135, 0, 0} Color256DarkGoldenrod = Color{Spectrum8, 136, 0, 0} Color256LightSalmon3Dark = Color{Spectrum8, 137, 0, 0} Color256RosyBrown = Color{Spectrum8, 138, 0, 0} Color256Grey63 = Color{Spectrum8, 139, 0, 0} Color256MediumPurple2Light = Color{Spectrum8, 140, 0, 0} Color256MediumPurple1 = Color{Spectrum8, 141, 0, 0} Color256Gold3Dark = Color{Spectrum8, 142, 0, 0} Color256DarkKhaki = Color{Spectrum8, 143, 0, 0} Color256Grey69 = Color{Spectrum8, 145, 0, 0} Color256LightSteelBlue3 = Color{Spectrum8, 146, 0, 0} Color256LightSteelBlue = Color{Spectrum8, 147, 0, 0} Color256Yellow3Dark = Color{Spectrum8, 148, 0, 0} Color256DarkOliveGreen3 = Color{Spectrum8, 149, 0, 0} Color256DarkSeaGreen3Light = Color{Spectrum8, 150, 0, 0} Color256DarkSeaGreen2Dark = Color{Spectrum8, 151, 0, 0} Color256LightCyan3 = Color{Spectrum8, 152, 0, 0} Color256LightSkyBlue1 = Color{Spectrum8, 153, 0, 0} Color256GreenYellow = Color{Spectrum8, 154, 0, 0} Color256DarkOliveGreen2 = Color{Spectrum8, 155, 0, 0} Color256PaleGreen1Light = Color{Spectrum8, 156, 0, 0} Color256DarkSeaGreen2Light = Color{Spectrum8, 157, 0, 0} Color256DarkSeaGreen1Dark = Color{Spectrum8, 158, 0, 0} Color256PaleTurquoise1 = Color{Spectrum8, 159, 0, 0} Color256Red3Light = Color{Spectrum8, 160, 0, 0} Color256DeepPink3Dark = Color{Spectrum8, 161, 0, 0} Color256DeepPink3Light = Color{Spectrum8, 162, 0, 0} Color256Magenta3Dark = Color{Spectrum8, 163, 0, 0} Color256Magenta3Light = Color{Spectrum8, 164, 0, 0} Color256Magenta2Dark = Color{Spectrum8, 165, 0, 0} Color256DarkOrange3Light = Color{Spectrum8, 166, 0, 0} Color256IndianRedLight = Color{Spectrum8, 167, 0, 0} Color256HotPink3Light = Color{Spectrum8, 168, 0, 0} Color256HotPink2 = Color{Spectrum8, 169, 0, 0} Color256Orchid = Color{Spectrum8, 170, 0, 0} Color256MediumOrchid1Dark = Color{Spectrum8, 171, 0, 0} Color256Orange3 = Color{Spectrum8, 172, 0, 0} Color256LightSalmon3Light = Color{Spectrum8, 173, 0, 0} Color256LightPink3 = Color{Spectrum8, 174, 0, 0} Color256Pink3 = Color{Spectrum8, 175, 0, 0} Color256Plum3 = Color{Spectrum8, 176, 0, 0} Color256Violet = Color{Spectrum8, 177, 0, 0} Color256Gold3Light = Color{Spectrum8, 178, 0, 0} Color256LightGoldenrod3 = Color{Spectrum8, 179, 0, 0} Color256Tan = Color{Spectrum8, 180, 0, 0} Color256MistyRose3 = Color{Spectrum8, 181, 0, 0} Color256Thistle3 = Color{Spectrum8, 182, 0, 0} Color256Plum2 = Color{Spectrum8, 183, 0, 0} Color256Yellow3Light = Color{Spectrum8, 184, 0, 0} Color256Khaki3 = Color{Spectrum8, 185, 0, 0} Color256LightGoldenrod2 = Color{Spectrum8, 186, 0, 0} Color256LightYellow3 = Color{Spectrum8, 187, 0, 0} Color256Grey84 = Color{Spectrum8, 188, 0, 0} Color256LightSteelBlue1 = Color{Spectrum8, 189, 0, 0} Color256Yellow2 = Color{Spectrum8, 190, 0, 0} Color256DarkOliveGreen1Dark = Color{Spectrum8, 191, 0, 0} Color256DarkOliveGreen1Light = Color{Spectrum8, 192, 0, 0} Color256DarkSeaGreen1Light = Color{Spectrum8, 193, 0, 0} Color256Honeydew2 = Color{Spectrum8, 194, 0, 0} Color256LightCyan1 = Color{Spectrum8, 195, 0, 0} Color256Red1 = Color{Spectrum8, 196, 0, 0} Color256DeepPink2 = Color{Spectrum8, 197, 0, 0} Color256DeepPink1Dark = Color{Spectrum8, 198, 0, 0} Color256DeepPink1Light = Color{Spectrum8, 199, 0, 0} Color256Magenta2Light = Color{Spectrum8, 200, 0, 0} Color256Magenta1 = Color{Spectrum8, 201, 0, 0} Color256OrangeRed1 = Color{Spectrum8, 202, 0, 0} Color256IndianRed1Dark = Color{Spectrum8, 203, 0, 0} Color256IndianRed1Light = Color{Spectrum8, 204, 0, 0} Color256HotPinkDark = Color{Spectrum8, 205, 0, 0} Color256HotPinkLight = Color{Spectrum8, 206, 0, 0} Color256MediumOrchid1Light = Color{Spectrum8, 207, 0, 0} Color256DarkOrange = Color{Spectrum8, 208, 0, 0} Color256Salmon1 = Color{Spectrum8, 209, 0, 0} Color256LightCoral = Color{Spectrum8, 210, 0, 0} Color256PaleVioletRed1 = Color{Spectrum8, 211, 0, 0} Color256Orchid2 = Color{Spectrum8, 212, 0, 0} Color256Orchid1 = Color{Spectrum8, 213, 0, 0} Color256Orange1 = Color{Spectrum8, 214, 0, 0} Color256SandyBrown = Color{Spectrum8, 215, 0, 0} Color256LightSalmon1 = Color{Spectrum8, 216, 0, 0} Color256LightPink1 = Color{Spectrum8, 217, 0, 0} Color256Pink1 = Color{Spectrum8, 218, 0, 0} Color256Plum1 = Color{Spectrum8, 219, 0, 0} Color256Gold1 = Color{Spectrum8, 220, 0, 0} Color256LightGoldenrod2Dark = Color{Spectrum8, 221, 0, 0} Color256LightGoldenrod2Light = Color{Spectrum8, 222, 0, 0} Color256MistyRose1 = Color{Spectrum8, 224, 0, 0} Color256Thistle1 = Color{Spectrum8, 225, 0, 0} Color256Yellow1 = Color{Spectrum8, 226, 0, 0} Color256LightGoldenrod1 = Color{Spectrum8, 227, 0, 0} Color256Khaki1 = Color{Spectrum8, 228, 0, 0} Color256Wheat1 = Color{Spectrum8, 229, 0, 0} Color256Cornsilk1 = Color{Spectrum8, 230, 0, 0} Color256Grey100 = Color{Spectrum8, 231, 0, 0} Color256Grey3 = Color{Spectrum8, 232, 0, 0} Color256Grey7 = Color{Spectrum8, 233, 0, 0} Color256Grey11 = Color{Spectrum8, 234, 0, 0} Color256Grey15 = Color{Spectrum8, 235, 0, 0} Color256Grey19 = Color{Spectrum8, 236, 0, 0} Color256Grey23 = Color{Spectrum8, 237, 0, 0} Color256Grey27 = Color{Spectrum8, 238, 0, 0} Color256Grey30 = Color{Spectrum8, 239, 0, 0} Color256Grey35 = Color{Spectrum8, 240, 0, 0} Color256Grey39 = Color{Spectrum8, 241, 0, 0} Color256Grey42 = Color{Spectrum8, 242, 0, 0} Color256Grey46 = Color{Spectrum8, 243, 0, 0} Color256Grey50 = Color{Spectrum8, 244, 0, 0} Color256Grey54 = Color{Spectrum8, 245, 0, 0} Color256Grey58 = Color{Spectrum8, 246, 0, 0} Color256Grey62 = Color{Spectrum8, 247, 0, 0} Color256Grey66 = Color{Spectrum8, 248, 0, 0} Color256Grey70 = Color{Spectrum8, 249, 0, 0} Color256Grey74 = Color{Spectrum8, 250, 0, 0} Color256Grey78 = Color{Spectrum8, 251, 0, 0} Color256Grey82 = Color{Spectrum8, 252, 0, 0} Color256Grey85 = Color{Spectrum8, 253, 0, 0} Color256Grey89 = Color{Spectrum8, 254, 0, 0} Color256Grey93 = Color{Spectrum8, 255, 0, 0} )
var InvalidKey = Key{KeyInvalid, 0, utf8.RuneError}
InvalidKey is returned if an error ocured during reading.
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
Color is a color of a specified spectrum.
func (*Color) Downsample ¶
Downsample returns the closest color in the specified target spectrum. If target has more colors than the original color's spectrum, the old color is returned.
type InvalidClearTypeError ¶
type InvalidClearTypeError struct {
// contains filtered or unexported fields
}
func (*InvalidClearTypeError) Error ¶
func (e *InvalidClearTypeError) Error() string
type InvalidMovementError ¶
type InvalidMovementError struct {
// contains filtered or unexported fields
}
func (*InvalidMovementError) Error ¶
func (e *InvalidMovementError) Error() string
type InvalidResponseError ¶
type InvalidResponseError struct {
// contains filtered or unexported fields
}
func (*InvalidResponseError) Error ¶
func (e *InvalidResponseError) Error() string
type Key ¶
Key is an abstract key combination on the keyboard.
type RGB ¶
type RGB struct {
// contains filtered or unexported fields
}
RGB is an rgb color with 8 bpc.
func (*RGB) Difference ¶
Difference returns the difference between two colors on a scale from 0 to 255. E.g. if the colors are completely inverted, Difference returns 255, if they're very close colors (just a pitch more red), Difference returns a number close to 0.
type Spectrum ¶
type Spectrum uint8
Spectrum specifies the colorspace a color is given in.
const ( // SpectrumDefault only has one color: the terminal's default color. SpectrumDefault Spectrum = 0 // Spectrum8 indicates that the spectrum has 8 colors. // It usually includes red, blue, green and binary combinations of these. // It needs 3 bits of storage. Spectrum8 Spectrum = 1 // Spectrum16 indicates that the spectrum has 16 colors. // It usually adds a bright modifier to the 8 color spectrum. // It needs 4 bits of storage. Spectrum16 Spectrum = 2 // Spectrum256 indicates that the spectrum has 256 colors. // It is usually a terminal-specific gradient. // It takes 8 bits of storage. Spectrum256 Spectrum = 3 // SpectrumRGB indicates that the spectrum has all RGB colors. // Each component can be specified freely between 0 and 255. // It takes 24 bits of storage. SpectrumRGB Spectrum = 4 )
type Style ¶
type Style struct { Foreground Color Background Color Extras TextAttribute }
Style collects all attributes that can be given to a character in the terminal. It includes foreground, background color and more text attributes.
type Terminal ¶
type Terminal interface { // Read reads a single keypress // and returns an array of keys in the order that they were typed // or in case of an error an empty list and the error. // If the terminal hasn't been set to raw mode, the user must first press enter for keys // to be sent to the application. Read() ([]Key, error) // WriteString writes the specified string at the current position into the terminal // It returns the number of bytes (there may be multiple bytes in a character) written // or an error. WriteString(string) (int, error) // Write writes the specified data at the current position into the terminal. // It returns the number of bytes written or an error. Write([]byte) (int, error) // SetRaw enables or disables raw mode for this terminal. SetRaw(bool) error // IsOpen returns whether the developer can currently read from / write to // this terminal. IsOpen() bool Close() // GetSize returns the terminal's current size. GetSize() TermSize // SetStyle sets the terminal style. Not all terminals support all styles (e. g. 24bit colors). SetStyle(Style) error // GetPosition returns the current cursor position. On some terminals, this takes some time. GetPosition() (*Position, error) // Move moves the cursor and point of writing to a new position specified by the Movement. // Implementations will not cross line borders if the provided horizontal movement exceeds line width. Move(*Movement) error // ClearScreen clears the screen depending on the ClearType. ClearScreen(ClearType) error // ClearLine clears this line depending on the ClearType. ClearLine(ClearType) error // contains filtered or unexported methods }
Terminal is an abstract terminal where the user can press arbitrary keys and the developer can write arbitrary strings as well as some actions.
type TextAttribute ¶
type TextAttribute uint8
TextAttribute sets more styling options on text.
const ( // TextDefault unsets all text attributes. TextDefault TextAttribute = 0 // TextBold makes the text appear bold. // On some terminals it will create bright text instead. TextBold TextAttribute = 0x1 // TextDim makes the text appear dim. TextDim TextAttribute = 0x2 // TextUnderlined underlines the text. TextUnderlined TextAttribute = 0x4 // TextBlink blinks the text. Does not work on some terminals. TextBlink TextAttribute = 0x8 // TextReverse reverses foreground and background color. TextReverse TextAttribute = 0x10 // TextHidden hides the text. TextHidden TextAttribute = 0x20 // TextCursive prints the text in cursive. Does only work on few terminals. TextCursive TextAttribute = 0x40 )