Documentation ¶
Index ¶
- Constants
- func GetConsoleMode(handle uintptr) (uint32, error)
- func GetHandleInfo(in interface{}) (uintptr, bool)
- func IsConsole(fd uintptr) bool
- func SetConsoleMode(handle uintptr, mode uint32) error
- func SetCursorVisible(handle uintptr, isVisible BOOL) (bool, error)
- func SetWindowSize(handle uintptr, width, height, max SHORT) (bool, error)
- func WinConsoleStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer)
- type BOOL
- type CHAR_INFO
- type CONSOLE_CURSOR_INFO
- type CONSOLE_SCREEN_BUFFER_INFO
- type COORD
- type DWORD
- type INPUT_RECORD
- type KEY_EVENT_RECORD
- type SHORT
- type SMALL_RECT
- type WCHAR
- type WORD
- type WindowsTerminal
- func (term *WindowsTerminal) HandleInputSequence(fd uintptr, command []byte) (n int, err error)
- func (term *WindowsTerminal) HandleOutputCommand(handle uintptr, command []byte) (n int, err error)
- func (term *WindowsTerminal) ReadChars(fd uintptr, r io.Reader, p []byte) (n int, err error)
- func (term *WindowsTerminal) WriteChars(fd uintptr, w io.Writer, p []byte) (n int, err error)
Constants ¶
const ( // Consts for Get/SetConsoleMode function // -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx ENABLE_PROCESSED_INPUT = 0x0001 ENABLE_LINE_INPUT = 0x0002 ENABLE_ECHO_INPUT = 0x0004 ENABLE_WINDOW_INPUT = 0x0008 ENABLE_MOUSE_INPUT = 0x0010 ENABLE_INSERT_MODE = 0x0020 ENABLE_QUICK_EDIT_MODE = 0x0040 ENABLE_EXTENDED_FLAGS = 0x0080 // If parameter is a screen buffer handle, additional values ENABLE_PROCESSED_OUTPUT = 0x0001 ENABLE_WRAP_AT_EOL_OUTPUT = 0x0002 //http://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes FOREGROUND_BLUE = 1 FOREGROUND_GREEN = 2 FOREGROUND_RED = 4 FOREGROUND_INTENSITY = 8 FOREGROUND_MASK_SET = 0x000F FOREGROUND_MASK_UNSET = 0xFFF0 BACKGROUND_BLUE = 16 BACKGROUND_GREEN = 32 BACKGROUND_RED = 64 BACKGROUND_INTENSITY = 128 BACKGROUND_MASK_SET = 0x00F0 BACKGROUND_MASK_UNSET = 0xFF0F COMMON_LVB_REVERSE_VIDEO = 0x4000 COMMON_LVB_UNDERSCORE = 0x8000 // http://man7.org/linux/man-pages/man4/console_codes.4.html // ECMA-48 Set Graphics Rendition ANSI_ATTR_RESET = 0 ANSI_ATTR_BOLD = 1 ANSI_ATTR_DIM = 2 ANSI_ATTR_UNDERLINE = 4 ANSI_ATTR_BLINK = 5 ANSI_ATTR_REVERSE = 7 ANSI_ATTR_INVISIBLE = 8 ANSI_ATTR_UNDERLINE_OFF = 24 ANSI_ATTR_BLINK_OFF = 25 ANSI_ATTR_REVERSE_OFF = 27 ANSI_ATTR_INVISIBLE_OFF = 8 ANSI_FOREGROUND_BLACK = 30 ANSI_FOREGROUND_RED = 31 ANSI_FOREGROUND_GREEN = 32 ANSI_FOREGROUND_YELLOW = 33 ANSI_FOREGROUND_BLUE = 34 ANSI_FOREGROUND_MAGENTA = 35 ANSI_FOREGROUND_CYAN = 36 ANSI_FOREGROUND_WHITE = 37 ANSI_FOREGROUND_DEFAULT = 39 ANSI_BACKGROUND_BLACK = 40 ANSI_BACKGROUND_RED = 41 ANSI_BACKGROUND_GREEN = 42 ANSI_BACKGROUND_YELLOW = 43 ANSI_BACKGROUND_BLUE = 44 ANSI_BACKGROUND_MAGENTA = 45 ANSI_BACKGROUND_CYAN = 46 ANSI_BACKGROUND_WHITE = 47 ANSI_BACKGROUND_DEFAULT = 49 ANSI_MAX_CMD_LENGTH = 256 MAX_INPUT_EVENTS = 128 MAX_INPUT_BUFFER = 1024 DEFAULT_WIDTH = 80 DEFAULT_HEIGHT = 24 )
const ( VK_PRIOR = 0x21 // PAGE UP key VK_NEXT = 0x22 // PAGE DOWN key VK_END = 0x23 // END key VK_HOME = 0x24 // HOME key VK_LEFT = 0x25 // LEFT ARROW key VK_UP = 0x26 // UP ARROW key VK_RIGHT = 0x27 // RIGHT ARROW key VK_DOWN = 0x28 // DOWN ARROW key VK_SELECT = 0x29 // SELECT key VK_PRINT = 0x2A // PRINT key VK_EXECUTE = 0x2B // EXECUTE key VK_SNAPSHOT = 0x2C // PRINT SCREEN key VK_INSERT = 0x2D // INS key VK_DELETE = 0x2E // DEL key VK_HELP = 0x2F // HELP key VK_F1 = 0x70 // F1 key VK_F2 = 0x71 // F2 key VK_F3 = 0x72 // F3 key VK_F4 = 0x73 // F4 key VK_F5 = 0x74 // F5 key VK_F6 = 0x75 // F6 key VK_F7 = 0x76 // F7 key VK_F8 = 0x77 // F8 key VK_F9 = 0x78 // F9 key VK_F10 = 0x79 // F10 key VK_F11 = 0x7A // F11 key VK_F12 = 0x7B // F12 key )
http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
const ( CAPSLOCK_ON = 0x0080 //The CAPS LOCK light is on. ENHANCED_KEY = 0x0100 //The key is enhanced. LEFT_ALT_PRESSED = 0x0002 //The left ALT key is pressed. LEFT_CTRL_PRESSED = 0x0008 //The left CTRL key is pressed. NUMLOCK_ON = 0x0020 //The NUM LOCK light is on. RIGHT_ALT_PRESSED = 0x0001 //The right ALT key is pressed. RIGHT_CTRL_PRESSED = 0x0004 //The right CTRL key is pressed. SCROLLLOCK_ON = 0x0040 //The SCROLL LOCK light is on. SHIFT_PRESSED = 0x0010 // The SHIFT key is pressed. )
const ( KEY_CONTROL_PARAM_2 = ";2" KEY_CONTROL_PARAM_3 = ";3" KEY_CONTROL_PARAM_4 = ";4" KEY_CONTROL_PARAM_5 = ";5" KEY_CONTROL_PARAM_6 = ";6" KEY_CONTROL_PARAM_7 = ";7" KEY_CONTROL_PARAM_8 = ";8" KEY_ESC_CSI = "\x1B[" KEY_ESC_N = "\x1BN" KEY_ESC_O = "\x1BO" )
const ( ANSI_ESCAPE_PRIMARY = 0x1B ANSI_ESCAPE_SECONDARY = 0x5B ANSI_COMMAND_FIRST = 0x40 ANSI_COMMAND_LAST = 0x7E ANSI_PARAMETER_SEP = ";" ANSI_CMD_G0 = '(' ANSI_CMD_G1 = ')' ANSI_CMD_G2 = '*' ANSI_CMD_G3 = '+' ANSI_CMD_DECPNM = '>' ANSI_CMD_DECPAM = '=' ANSI_CMD_OSC = ']' ANSI_CMD_STR_TERM = '\\' ANSI_BEL = 0x07 KEY_EVENT = 1 )
http://manpages.ubuntu.com/manpages/intrepid/man4/console_codes.4.html
Variables ¶
This section is empty.
Functions ¶
func GetConsoleMode ¶
GetConsoleMode gets the console mode for given file descriptor http://msdn.microsoft.com/en-us/library/windows/desktop/ms683167(v=vs.85).aspx
func GetHandleInfo ¶
GetHandleInfo returns file descriptor and bool indicating whether the file is a console.
func IsConsole ¶
IsConsole returns true if the given file descriptor is a terminal. -- The code assumes that GetConsoleMode will return an error for file descriptors that are not a console.
func SetConsoleMode ¶
SetConsoleMode sets the console mode for given file descriptor http://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx
func SetCursorVisible ¶
SetCursorVisible sets the cursor visbility http://msdn.microsoft.com/en-us/library/windows/desktop/ms686019(v=vs.85).aspx
func SetWindowSize ¶
SetWindowSize sets the size of the console window.
func WinConsoleStreams ¶
func WinConsoleStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer)
Types ¶
type BOOL ¶
type BOOL int32
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type CHAR_INFO ¶
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type CONSOLE_CURSOR_INFO ¶
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type CONSOLE_SCREEN_BUFFER_INFO ¶
type CONSOLE_SCREEN_BUFFER_INFO struct { Size COORD CursorPosition COORD Attributes WORD Window SMALL_RECT MaximumWindowSize COORD }
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
func GetConsoleScreenBufferInfo ¶
func GetConsoleScreenBufferInfo(handle uintptr) (*CONSOLE_SCREEN_BUFFER_INFO, error)
GetConsoleScreenBufferInfo retrieves information about the specified console screen buffer. http://msdn.microsoft.com/en-us/library/windows/desktop/ms683171(v=vs.85).aspx
type COORD ¶
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type DWORD ¶
type DWORD uint32
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type INPUT_RECORD ¶
type INPUT_RECORD struct { EventType WORD KeyEvent KEY_EVENT_RECORD }
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type KEY_EVENT_RECORD ¶
type KEY_EVENT_RECORD struct { KeyDown BOOL RepeatCount WORD VirtualKeyCode WORD VirtualScanCode WORD UnicodeChar WCHAR ControlKeyState DWORD }
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684166(v=vs.85).aspx
type SHORT ¶
type SHORT int16
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type SMALL_RECT ¶
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type WCHAR ¶
type WCHAR uint16
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type WORD ¶
type WORD uint16
types for calling various windows API see http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
type WindowsTerminal ¶
type WindowsTerminal struct {
// contains filtered or unexported fields
}
Implements the TerminalEmulator interface
func (*WindowsTerminal) HandleInputSequence ¶
func (term *WindowsTerminal) HandleInputSequence(fd uintptr, command []byte) (n int, err error)
HandleInputSequence interprets the input sequence command
func (*WindowsTerminal) HandleOutputCommand ¶
func (term *WindowsTerminal) HandleOutputCommand(handle uintptr, command []byte) (n int, err error)
HandleOutputCommand interpretes the Ansi commands and then makes appropriate Win32 calls
func (*WindowsTerminal) WriteChars ¶
WriteChars writes the bytes to given writer.