Index: /Include/api_console.sbp
===================================================================
--- /Include/api_console.sbp	(revision 121)
+++ /Include/api_console.sbp	(revision 122)
@@ -3,14 +3,4 @@
 #ifndef _INC_CONSOLE
 #define _INC_CONSOLE
-
-'console text color
-Const FOREGROUND_BLUE =      &H0001
-Const FOREGROUND_GREEN =     &H0002
-Const FOREGROUND_RED =       &H0004
-Const FOREGROUND_INTENSITY = &H0008
-Const BACKGROUND_BLUE =      &H0010
-Const BACKGROUND_GREEN =     &H0020
-Const BACKGROUND_RED =       &H0040
-Const BACKGROUND_INTENSITY = &H0080
 
 Type COORD
@@ -18,17 +8,193 @@
 	Y As Integer
 End Type
-
-
+TypeDef PCOORD = *COORD
+
+Type SMALL_RECT
+	Left As Integer
+	Top As Integer
+	Right As Integer
+	Bottom As Integer
+End Type
+TypeDef PSMALL_RECT = *SMALL_RECT
+
+Type KEY_EVENT_RECORD
+	bKeyDown As BOOL
+	wRepeatCount As Word
+	wVirtualKeyCode As Word
+	wVirtualScanCode As Word
+	uChar As WCHAR
+	dwControlKeyState As DWord
+End Type
+TypeDef PKEY_EVENT_RECORD = *KEY_EVENT_RECORD
+
+Const RIGHT_ALT_PRESSED = &H0001
+Const LEFT_ALT_PRESSED = &H0002
+Const RIGHT_CTRL_PRESSED = &H0004
+Const LEFT_CTRL_PRESSED = &H0008
+Const SHIFT_PRESSED = &H0010
+Const NUMLOCK_ON = &H0020
+Const SCROLLLOCK_ON = &H0040
+Const CAPSLOCK_ON = &H0080
+Const ENHANCED_KEY = &H0100
+Const NLS_DBCSCHAR = &H00010000
+Const NLS_ALPHANUMERIC = &H00000000
+Const NLS_KATAKANA = &H00020000
+Const NLS_HIRAGANA = &H00040000
+Const NLS_ROMAN = &H00400000
+Const NLS_IME_CONVERSION = &H00800000
+Const NLS_IME_DISABLE = &H20000000
+
+Type MOUSE_EVENT_RECORD
+	dwMousePosition As COORD
+	dwButtonState As DWord
+	dwControlKeyState As DWord
+	dwEventFlags As DWord
+End Type
+TypeDef PMOUSE_EVENT_RECORD = *MOUSE_EVENT_RECORD
+
+Const FROM_LEFT_1ST_BUTTON_PRESSED = &H0001
+Const RIGHTMOST_BUTTON_PRESSED = &H0002
+Const FROM_LEFT_2ND_BUTTON_PRESSED = &H0004
+Const FROM_LEFT_3RD_BUTTON_PRESSED = &H0008
+Const FROM_LEFT_4TH_BUTTON_PRESSED = &H0010
+
+Const MOUSE_MOVED = &H0001
+Const DOUBLE_CLICK = &H0002
+Const MOUSE_WHEELED = &H0004
+
+Type WINDOW_BUFFER_SIZE_RECORD
+	dwSize As COORD
+End Type
+TypeDef PWINDOW_BUFFER_SIZE_RECORD = *WINDOW_BUFFER_SIZE_RECORD
+
+Type MENU_EVENT_RECORD
+	dwCommandId As DWord
+End Type
+TypeDef PMENU_EVENT_RECORD = *MENU_EVENT_RECORD
+
+Type FOCUS_EVENT_RECORD
+	bSetFocus As BOOL
+End Type
+TypeDef PFOCUS_EVENT_RECORD = *FOCUS_EVENT_RECORD
+
+Type INPUT_RECORD
+	EventType As Word
+'	Union Event
+		KeyEvent As KEY_EVENT_RECORD
+'		MouseEvent As MOUSE_EVENT_RECORD
+'		WindowBufferSizeEvent As WINDOW_BUFFER_SIZE_RECORD
+'		MenuEvent As MENU_EVENT_RECORD
+'		FocusEvent As FOCUS_EVENT_RECORD
+'	End Union
+End Type
+TypeDef PINPUT_RECORD = *INPUT_RECORD
+
+Const KEY_EVENT                = &H0001
+Const MOUSE_EVENT              = &H0002
+Const WINDOW_BUFFER_SIZE_EVENT = &H0004
+Const MENU_EVENT               = &H0008
+Const FOCUS_EVENT              = &H0010
+
+Type CHAR_INFO
+'	Union Char
+'		UnicodeChar As Word
+		AsciiChar[1] As SByte
+'	End Union
+	Attributes As Word
+End Type
+TypeDef PCHAR_INFO = *CHAR_INFO
+
+Const FOREGROUND_BLUE            = &H0001
+Const FOREGROUND_GREEN           = &H0002
+Const FOREGROUND_RED             = &H0004
+Const FOREGROUND_INTENSITY       = &H0008
+Const BACKGROUND_BLUE            = &H0010
+Const BACKGROUND_GREEN           = &H0020
+Const BACKGROUND_RED             = &H0040
+Const BACKGROUND_INTENSITY       = &H0080
+Const COMMON_LVB_LEADING_BYTE    = &H0100
+Const COMMON_LVB_TRAILING_BYTE   = &H0200
+Const COMMON_LVB_GRID_HORIZONTAL = &H0400
+Const COMMON_LVB_GRID_LVERTICAL  = &H0800
+Const COMMON_LVB_GRID_RVERTICAL  = &H1000
+Const COMMON_LVB_REVERSE_VIDEO   = &H4000
+Const COMMON_LVB_UNDERSCORE      = &H8000
+Const COMMON_LVB_SBCSDBCS        = &H0300
+
+Type CONSOLE_SCREEN_BUFFER_INFO
+	dwSize As COORD
+	dwCursorPosition As COORD
+	wAttributes As Word
+	srWindow As SMALL_RECT
+	dwMaximumWindowSize As COORD
+End Type
+TypeDef PCONSOLE_SCREEN_BUFFER_INFO = *CONSOLE_SCREEN_BUFFER_INFO
+
+Type CONSOLE_CURSOR_INFO
+	dwSize As DWord
+	bVisible As BOOL
+End Type
+TypeDef PCONSOLE_CURSOR_INFO = *CONSOLE_CURSOR_INFO
+
+TypeDef PHANDLER_ROUTINE = *Function(CtrlType As DWord) As BOOL
+
+Const CTRL_C_EVENT        = 0
+Const CTRL_BREAK_EVENT    = 1
+Const CTRL_CLOSE_EVENT    = 2
+Const CTRL_LOGOFF_EVENT   = 5
+Const CTRL_SHUTDOWN_EVENT = 6
+
+Const ENABLE_PROCESSED_INPUT    = &H0001
+Const ENABLE_LINE_INPUT         = &H0002
+Const ENABLE_ECHO_INPUT         = &H0004
+Const ENABLE_WINDOW_INPUT       = &H0008
+Const ENABLE_MOUSE_INPUT        = &H0010
+Const ENABLE_PROCESSED_OUTPUT   = &H0001
+Const ENABLE_WRAP_AT_EOL_OUTPUT = &H0002
+
+Declare Function PeekConsoleInput Lib "kernel32" Alias "PeekConsoleInputA" (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
+Declare Function ReadConsoleInput Lib "kernel32" Alias "ReadConsoleInputA" (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsRead As DWord) As BOOL
+Declare Function WriteConsoleInput Lib "kernel32" Alias "WriteConsoleInputA" (hConsoleInput As HANDLE, ByRef lpBuffer As INPUT_RECORD, nLength As DWord, ByRef lpNumberOfEventsWritten As DWord) As BOOL
+Declare Function ReadConsoleOutput Lib "kernel32" Alias "ReadConsoleOutputA" (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpReadRegion As SMALL_RECT) As BOOL
+Declare Function WriteConsoleOutput Lib "kernel32" Alias "WriteConsoleOutputA" (hConsoleOutput As HANDLE, lpBuffer As *CHAR_INFO, ByRef dwBufferSize As COORD, ByRef dwBufferCoord As COORD, ByRef lpWriteRegion As SMALL_RECT) As BOOL
+Declare Function ReadConsoleOutputCharacter Lib "kernel32" Alias "ReadConsoleOutputCharacterA" (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfCharsRead As DWord) As BOOL
+Declare Function ReadConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwReadCoord As COORD, ByRef lpNumberOfAttrsRead As DWord) As BOOL
+Declare Function WriteConsoleOutputCharacter Lib "kernel32" Alias "WriteConsoleOutputCharacterA" (hConsoleOutput As HANDLE, lpCharacter As LPSTR, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
+Declare Function WriteConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, lpAttribute As *Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
+Declare Function FillConsoleOutputCharacter Lib "kernel32" Alias "FillConsoleOutputCharacterA" (hConsoleOutput As HANDLE, cCharacter As Char, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfCharsWritten As DWord) As BOOL
+Declare Function FillConsoleOutputAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttribute As Word, nLength As DWord, ByRef dwWriteCoord As COORD, ByRef lpNumberOfAttrsWritten As DWord) As BOOL
+Declare Function GetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, ByRef lpMode As DWord) As BOOL
+Declare Function GetNumberOfConsoleInputEvents Lib "kernel32" (hConsoleInput As HANDLE, ByRef lpNumberOfEvents As DWord) As BOOL
+Declare Function GetConsoleScreenBufferInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleScreenBufferInfo As CONSOLE_SCREEN_BUFFER_INFO) As BOOL
+Declare Function GetLargestConsoleWindowSize Lib "kernel32" (hConsoleOutput As HANDLE) As DWord
+Declare Function GetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
+Declare Function GetNumberOfConsoleMouseButtons Lib "kernel32" (ByRef lpNumberOfMouseButtons As DWord) As BOOL
+Declare Function SetConsoleMode Lib "kernel32" (hConsoleHandle As HANDLE, dwMode As DWord) As BOOL
+Declare Function SetConsoleActiveScreenBuffer Lib "kernel32" (hConsoleOutput As HANDLE) As BOOL
+Declare Function FlushConsoleInputBuffer Lib "kernel32" (hConsoleInput As HANDLE) As BOOL
+Declare Function SetConsoleScreenBufferSize Lib "kernel32" (hConsoleOutput As HANDLE, dwSize As DWord) As BOOL
+Declare Function SetConsoleCursorPosition Lib "kernel32" (hConsoleOutput As HANDLE, dwCursorPosition As DWord) As BOOL
+Declare Function SetConsoleCursorInfo Lib "kernel32" (hConsoleOutput As HANDLE, ByRef lpConsoleCursorInfo As CONSOLE_CURSOR_INFO) As BOOL
+Declare Function ScrollConsoleScreenBuffer Lib "kernel32" Alias "ScrollConsoleScreenBufferA" (hConsoleOutput As HANDLE, ByRef lpScrollRectangle As SMALL_RECT, lpClipRectangle As *SMALL_RECT, ByRef dwDestinationOrigin As COORD, lpFill As *CHAR_INFO) As BOOL
+Declare Function SetConsoleWindowInfo Lib "kernel32" (hConsoleOutput As HANDLE, bAbsolute As BOOL, ByRef lpConsoleWindow As SMALL_RECT) As BOOL
+Declare Function SetConsoleTextAttribute Lib "kernel32" (hConsoleOutput As HANDLE, wAttributes As Word) As BOOL
+Declare Function SetConsoleCtrlHandler Lib "kernel32" (HandlerRoutine As PHANDLER_ROUTINE, Add As BOOL) As BOOL
+Declare Function GenerateConsoleCtrlEvent Lib "kernel32" (dwCtrlEvent As DWord, dwProcessGroupId As DWord) As BOOL
 Declare Function AllocConsole Lib "kernel32" () As BOOL
 Declare Function FreeConsole Lib "kernel32" () As BOOL
-
-Declare Function SetConsoleCursorPosition Lib "kernel32" (hConsoleOutput As HANDLE, dwCursorPosition As DWord) As BOOL
-
-Declare Function ReadConsole Lib "kernel32" Alias "ReadConsoleA" (hConsoleInput As HANDLE, pBuffer As VoidPtr, nNumberOfCharsToRead As DWord, ByRef NumberOfCharsRead As DWord, pReserved As VoidPtr) As BOOL
-Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (hConsoleOutput As HANDLE, pBuffer As VoidPtr, nNumberOfCharsToWrite As DWord, ByRef NumberOfCharsWritten As DWord, pReserved As VoidPtr) As BOOL
-
-Declare Function CreateConsoleScreenBuffer Lib "kernel32" (dwDesiredAccess As DWord, dwShareMode As DWord, pSecurityAttributes As *SECURITY_ATTRIBUTES, dwFlags As DWord, pScreenBufferData As VoidPtr) As HANDLE
-
-Declare Function SetConsoleActiveScreenBuffer Lib "kernel32" (hConsoleOutput As HANDLE) As BOOL
+Declare Function GetConsoleTitle Lib "kernel32" Alias "GetConsoleTitleA" (lpConsoleTitle As LPSTR, nSize As DWord) As DWord
+Declare Function SetConsoleTitle Lib "kernel32" Alias "SetConsoleTitleA" (lpConsoleTitle As LPSTR) As BOOL
+Declare Function ReadConsole Lib "kernel32" Alias "ReadConsoleA" (hConsoleInput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToRead As DWord, ByRef lpNumberOfCharsRead As DWord, lpReserved As VoidPtr) As BOOL
+Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (hConsoleOutput As HANDLE, lpBuffer As VoidPtr, nNumberOfCharsToWrite As DWord, ByRef lpNumberOfCharsWritten As DWord, lpReserved As VoidPtr) As BOOL
+
+Const CONSOLE_TEXTMODE_BUFFER = 1
+
+Declare Function CreateConsoleScreenBuffer Lib "kernel32" (dwDesiredAccess As DWord, dwShareMode As DWord, lpSecurityAttributes As *SECURITY_ATTRIBUTES, dwFlags As DWord, lpScreenBufferData As VoidPtr) As HANDLE
+Declare Function GetConsoleCP Lib "kernel32" () As DWord
+Declare Function SetConsoleCP Lib "kernel32" (wCodePageID As DWord) As BOOL
+Declare Function GetConsoleOutputCP Lib "kernel32" () As DWord
+Declare Function SetConsoleOutputCP Lib "kernel32" (wCodePageID As DWord) As BOOL
+
+
 
 #endif '_INC_CONSOLE
