winterm

package
v0.0.0-...-d88c8b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
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

	RIGHT_ALT_PRESSED  = 0x0001
	LEFT_ALT_PRESSED   = 0x0002
	RIGHT_CTRL_PRESSED = 0x0004
	LEFT_CTRL_PRESSED  = 0x0008
	SHIFT_PRESSED      = 0x0010
	NUMLOCK_ON         = 0x0020
	SCROLLLOCK_ON      = 0x0040
	CAPSLOCK_ON        = 0x0080
	ENHANCED_KEY       = 0x0100
)

Windows keyboard constants See https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx.

View Source
const (
	// Console modes
	// 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
	ENABLE_AUTO_POSITION          = 0x0100
	ENABLE_VIRTUAL_TERMINAL_INPUT = 0x0200

	ENABLE_PROCESSED_OUTPUT            = 0x0001
	ENABLE_WRAP_AT_EOL_OUTPUT          = 0x0002
	ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004
	DISABLE_NEWLINE_AUTO_RETURN        = 0x0008
	ENABLE_LVB_GRID_WORLDWIDE          = 0x0010

	// Character attributes
	// Note:
	// -- The attributes are combined to produce various colors (e.g., Blue + Green will create Cyan).
	//    Clearing all foreground or background colors results in black; setting all creates white.
	// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes.
	FOREGROUND_BLUE      uint16 = 0x0001
	FOREGROUND_GREEN     uint16 = 0x0002
	FOREGROUND_RED       uint16 = 0x0004
	FOREGROUND_INTENSITY uint16 = 0x0008
	FOREGROUND_MASK      uint16 = 0x000F

	BACKGROUND_BLUE      uint16 = 0x0010
	BACKGROUND_GREEN     uint16 = 0x0020
	BACKGROUND_RED       uint16 = 0x0040
	BACKGROUND_INTENSITY uint16 = 0x0080
	BACKGROUND_MASK      uint16 = 0x00F0

	COMMON_LVB_MASK          uint16 = 0xFF00
	COMMON_LVB_REVERSE_VIDEO uint16 = 0x4000
	COMMON_LVB_UNDERSCORE    uint16 = 0x8000

	// Input event types
	// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx.
	KEY_EVENT                = 0x0001
	MOUSE_EVENT              = 0x0002
	WINDOW_BUFFER_SIZE_EVENT = 0x0004
	MENU_EVENT               = 0x0008
	FOCUS_EVENT              = 0x0010

	// WaitForSingleObject return codes
	WAIT_ABANDONED = 0x00000080
	WAIT_FAILED    = 0xFFFFFFFF
	WAIT_SIGNALED  = 0x0000000
	WAIT_TIMEOUT   = 0x00000102

	// WaitForSingleObject wait duration
	WAIT_INFINITE       = 0xFFFFFFFF
	WAIT_ONE_SECOND     = 1000
	WAIT_HALF_SECOND    = 500
	WAIT_QUARTER_SECOND = 250
)

Windows Console constants

View Source
const (
	FOREGROUND_COLOR_MASK = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
	BACKGROUND_COLOR_MASK = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE
)

Variables

This section is empty.

Functions

func CreateWinEventHandler

func CreateWinEventHandler(fd uintptr, file *os.File, opts ...Option) ansiterm.AnsiEventHandler

func GetConsoleCursorInfo

func GetConsoleCursorInfo(handle uintptr, cursorInfo *CONSOLE_CURSOR_INFO) error

GetConsoleCursorInfo retrieves information about the size and visiblity of the console cursor. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683163(v=vs.85).aspx.

func GetConsoleMode

func GetConsoleMode(handle uintptr) (mode uint32, err error)

GetConsoleMode gets the console mode for given file descriptor See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683167(v=vs.85).aspx.

func GetStdFile

func GetStdFile(nFile int) (*os.File, uintptr)

func ReadConsoleInput

func ReadConsoleInput(handle uintptr, buffer []INPUT_RECORD, count *uint32) error

ReadConsoleInput reads (and removes) data from the console input buffer. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms684961(v=vs.85).aspx.

func ScrollConsoleScreenBuffer

func ScrollConsoleScreenBuffer(handle uintptr, scrollRect SMALL_RECT, clipRect SMALL_RECT, destOrigin COORD, char CHAR_INFO) error

func SetConsoleCursorInfo

func SetConsoleCursorInfo(handle uintptr, cursorInfo *CONSOLE_CURSOR_INFO) error

SetConsoleCursorInfo sets the size and visiblity of the console cursor. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms686019(v=vs.85).aspx.

func SetConsoleCursorPosition

func SetConsoleCursorPosition(handle uintptr, coord COORD) error

SetConsoleCursorPosition location of the console cursor. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms686025(v=vs.85).aspx.

func SetConsoleMode

func SetConsoleMode(handle uintptr, mode uint32) error

SetConsoleMode sets the console mode for given file descriptor See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx.

func SetConsoleScreenBufferSize

func SetConsoleScreenBufferSize(handle uintptr, coord COORD) error

SetConsoleScreenBufferSize sets the size of the console screen buffer. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms686044(v=vs.85).aspx.

func SetConsoleTextAttribute

func SetConsoleTextAttribute(handle uintptr, attribute uint16) error

SetConsoleTextAttribute sets the attributes of characters written to the console screen buffer by the WriteFile or WriteConsole function. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686047(v=vs.85).aspx.

func SetConsoleWindowInfo

func SetConsoleWindowInfo(handle uintptr, isAbsolute bool, rect SMALL_RECT) error

SetConsoleWindowInfo sets the size and position of the console screen buffer's window. Note that the size and location must be within and no larger than the backing console screen buffer. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms686125(v=vs.85).aspx.

func WaitForSingleObject

func WaitForSingleObject(handle uintptr, msWait uint32) (bool, error)

WaitForSingleObject waits for the passed handle to be signaled. It returns true if the handle was signaled; false otherwise. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx.

func WriteConsoleOutput

func WriteConsoleOutput(handle uintptr, buffer []CHAR_INFO, bufferSize COORD, bufferCoord COORD, writeRegion *SMALL_RECT) error

WriteConsoleOutput writes the CHAR_INFOs from the provided buffer to the active console buffer. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms687404(v=vs.85).aspx.

Types

type CHAR_INFO

type CHAR_INFO struct {
	UnicodeChar uint16
	Attributes  uint16
}

Windows API Console types -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD) -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment

type CONSOLE_CURSOR_INFO

type CONSOLE_CURSOR_INFO struct {
	Size    uint32
	Visible int32
}

Windows API Console types -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD) -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment

type CONSOLE_SCREEN_BUFFER_INFO

type CONSOLE_SCREEN_BUFFER_INFO struct {
	Size              COORD
	CursorPosition    COORD
	Attributes        uint16
	Window            SMALL_RECT
	MaximumWindowSize COORD
}

Windows API Console types -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD) -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment

func GetConsoleScreenBufferInfo

func GetConsoleScreenBufferInfo(handle uintptr) (*CONSOLE_SCREEN_BUFFER_INFO, error)

GetConsoleScreenBufferInfo retrieves information about the specified console screen buffer. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683171(v=vs.85).aspx.

func (CONSOLE_SCREEN_BUFFER_INFO) String

func (info CONSOLE_SCREEN_BUFFER_INFO) String() string

String helpers

type COORD

type COORD struct {
	X int16
	Y int16
}

Windows API Console types -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD) -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment

func (COORD) String

func (coord COORD) String() string

type INPUT_RECORD

type INPUT_RECORD struct {
	EventType uint16
	KeyEvent  KEY_EVENT_RECORD
}

INPUT_RECORD is a C/C++ union of which KEY_EVENT_RECORD is one case, it is also the largest See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx.

type KEY_EVENT_RECORD

type KEY_EVENT_RECORD struct {
	KeyDown         int32
	RepeatCount     uint16
	VirtualKeyCode  uint16
	VirtualScanCode uint16
	UnicodeChar     uint16
	ControlKeyState uint32
}

Windows API Console types -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD) -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment

type Option

type Option func(*windowsAnsiEventHandler)

func WithLogf

func WithLogf(f func(string, ...interface{})) Option

type SMALL_RECT

type SMALL_RECT struct {
	Left   int16
	Top    int16
	Right  int16
	Bottom int16
}

Windows API Console types -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD) -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment

func (SMALL_RECT) String

func (rect SMALL_RECT) String() string

type WINDOW_BUFFER_SIZE

type WINDOW_BUFFER_SIZE struct {
	Size COORD
}

Windows API Console types -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD) -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL