wincon.h 11.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright (C) the Wine project
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 18
 */

Alexandre Julliard's avatar
Alexandre Julliard committed
19 20
#ifndef __WINE_WINCON_H
#define __WINE_WINCON_H
Alexandre Julliard's avatar
Alexandre Julliard committed
21

22 23 24 25 26 27 28 29
#ifdef __cplusplus
extern "C" {
#endif

#define CTRL_C_EVENT        0
#define CTRL_BREAK_EVENT    1
#define CTRL_CLOSE_EVENT    2
#define CTRL_LOGOFF_EVENT   5
Alexandre Julliard's avatar
Alexandre Julliard committed
30 31
#define CTRL_SHUTDOWN_EVENT 6

Alexandre Julliard's avatar
Alexandre Julliard committed
32
/* Console Mode flags */
33 34 35 36 37
#define ENABLE_PROCESSED_INPUT 0x01
#define ENABLE_LINE_INPUT      0x02
#define ENABLE_ECHO_INPUT      0x04
#define ENABLE_WINDOW_INPUT    0x08
#define ENABLE_MOUSE_INPUT     0x10
Alexandre Julliard's avatar
Alexandre Julliard committed
38

39
#define ENABLE_PROCESSED_OUTPUT   0x01
Alexandre Julliard's avatar
Alexandre Julliard committed
40 41 42
#define ENABLE_WRAP_AT_EOL_OUTPUT 0x02


43
typedef BOOL (WINAPI *PHANDLER_ROUTINE)(DWORD dwCtrlType);
Alexandre Julliard's avatar
Alexandre Julliard committed
44

Alexandre Julliard's avatar
Alexandre Julliard committed
45
/* Attributes flags: */
Alexandre Julliard's avatar
Alexandre Julliard committed
46 47 48 49 50 51 52 53 54 55

#define FOREGROUND_BLUE      0x0001 /* text color contains blue. */
#define FOREGROUND_GREEN     0x0002 /* text color contains green. */
#define FOREGROUND_RED       0x0004 /* text color contains red. */
#define FOREGROUND_INTENSITY 0x0008 /* text color is intensified. */
#define BACKGROUND_BLUE      0x0010 /* background color contains blue. */
#define BACKGROUND_GREEN     0x0020 /* background color contains green. */
#define BACKGROUND_RED       0x0040 /* background color contains red. */
#define BACKGROUND_INTENSITY 0x0080 /* background color is intensified. */

56 57
typedef struct _CONSOLE_CURSOR_INFO {
    DWORD	dwSize;   /* Between 1 & 100 for percentage of cell filled */
58
    BOOL	bVisible; /* Visibility of cursor */
59 60
} CONSOLE_CURSOR_INFO, *LPCONSOLE_CURSOR_INFO;

Alexandre Julliard's avatar
Alexandre Julliard committed
61 62
typedef struct tagCOORD
{
63 64 65
    SHORT X;
    SHORT Y;
} COORD, *LPCOORD;
Alexandre Julliard's avatar
Alexandre Julliard committed
66 67 68

typedef struct tagSMALL_RECT
{
69 70 71 72
    SHORT Left;
    SHORT Top;
    SHORT Right;
    SHORT Bottom;
Alexandre Julliard's avatar
Alexandre Julliard committed
73 74 75 76 77 78 79 80 81 82 83
} SMALL_RECT,*LPSMALL_RECT;

typedef struct tagCONSOLE_SCREEN_BUFFER_INFO
{
    COORD       dwSize;
    COORD       dwCursorPosition;
    WORD        wAttributes;
    SMALL_RECT  srWindow;
    COORD       dwMaximumWindowSize;
} CONSOLE_SCREEN_BUFFER_INFO,*LPCONSOLE_SCREEN_BUFFER_INFO;

Alexandre Julliard's avatar
Alexandre Julliard committed
84 85 86 87 88 89 90 91 92 93 94 95
typedef struct tagCHAR_INFO
{
    union
	{
	WCHAR UnicodeChar;
	CHAR AsciiChar;
	} Char;
    WORD	Attributes;
} CHAR_INFO,*LPCHAR_INFO;

typedef struct tagKEY_EVENT_RECORD
{
96
    BOOL	bKeyDown;		/* 04 */
97 98 99 100
    WORD	wRepeatCount;		/* 08 */
    WORD	wVirtualKeyCode;	/* 0A */
    WORD	wVirtualScanCode;	/* 0C */
    union				/* 0E */
Alexandre Julliard's avatar
Alexandre Julliard committed
101
	{
102
	WCHAR UnicodeChar;		/* 0E */
103
	CHAR AsciiChar;			/* 0E */
Alexandre Julliard's avatar
Alexandre Julliard committed
104
	} uChar;
105
    DWORD	dwControlKeyState;	/* 10 */
Alexandre Julliard's avatar
Alexandre Julliard committed
106 107
} KEY_EVENT_RECORD,*LPKEY_EVENT_RECORD;

108 109 110 111 112 113 114 115 116 117 118
/* dwControlKeyState bitmask */
#define	RIGHT_ALT_PRESSED	0x0001
#define	LEFT_ALT_PRESSED	0x0002
#define	RIGHT_CTRL_PRESSED	0x0004
#define	LEFT_CTRL_PRESSED	0x0008
#define	SHIFT_PRESSED		0x0010
#define	NUMLOCK_ON		0x0020
#define	SCROLLLOCK_ON		0x0040
#define	CAPSLOCK_ON		0x0080
#define	ENHANCED_KEY		0x0100

Alexandre Julliard's avatar
Alexandre Julliard committed
119 120 121 122 123 124 125 126
typedef struct tagMOUSE_EVENT_RECORD
{
    COORD	dwMousePosition;
    DWORD	dwButtonState;
    DWORD	dwControlKeyState;
    DWORD	dwEventFlags;
} MOUSE_EVENT_RECORD,*LPMOUSE_EVENT_RECORD;

127 128 129 130 131 132 133 134 135 136
#define FROM_LEFT_1ST_BUTTON_PRESSED    0x0001
#define RIGHTMOST_BUTTON_PRESSED        0x0002
#define FROM_LEFT_2ND_BUTTON_PRESSED    0x0004
#define FROM_LEFT_3RD_BUTTON_PRESSED    0x0008
#define FROM_LEFT_4TH_BUTTON_PRESSED    0x0010

#define MOUSE_MOVED                     0x0001
#define DOUBLE_CLICK                    0x0002
#define MOUSE_WHEELED                   0x0004

Alexandre Julliard's avatar
Alexandre Julliard committed
137 138 139 140 141 142 143
typedef struct tagWINDOW_BUFFER_SIZE_RECORD
{
    COORD	dwSize;
} WINDOW_BUFFER_SIZE_RECORD,*LPWINDOW_BUFFER_SIZE_RECORD;

typedef struct tagMENU_EVENT_RECORD
{
144
    UINT	dwCommandId; /* perhaps UINT16 ??? */
Alexandre Julliard's avatar
Alexandre Julliard committed
145 146 147 148
} MENU_EVENT_RECORD,*LPMENU_EVENT_RECORD;

typedef struct tagFOCUS_EVENT_RECORD
{
149
    BOOL      bSetFocus; /* perhaps BOOL16 ??? */
Alexandre Julliard's avatar
Alexandre Julliard committed
150 151 152 153
} FOCUS_EVENT_RECORD,*LPFOCUS_EVENT_RECORD;

typedef struct tagINPUT_RECORD
{
154
    WORD		EventType;		/* 00 */
Alexandre Julliard's avatar
Alexandre Julliard committed
155 156 157 158 159 160 161 162
    union
	{
	KEY_EVENT_RECORD KeyEvent;
	MOUSE_EVENT_RECORD MouseEvent;
	WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
	MENU_EVENT_RECORD MenuEvent;
	FOCUS_EVENT_RECORD FocusEvent;
	} Event;
163
} INPUT_RECORD,*PINPUT_RECORD;
Alexandre Julliard's avatar
Alexandre Julliard committed
164

165 166 167 168 169 170 171
/* INPUT_RECORD.wEventType */
#define KEY_EVENT			0x01
#define MOUSE_EVENT			0x02
#define WINDOW_BUFFER_SIZE_EVENT	0x04
#define MENU_EVENT			0x08
#define FOCUS_EVENT 			0x10

172 173
#define CONSOLE_TEXTMODE_BUFFER  1

174 175 176 177 178 179 180
#ifdef __i386__
/* Note: this should return a COORD, but calling convention for returning
 * structures is different between Windows and gcc on i386. */
DWORD WINAPI GetLargestConsoleWindowSize(HANDLE);

inline static COORD __wine_GetLargestConsoleWindowSize_wrapper(HANDLE h)
{
181 182 183 184 185 186
    union {
      COORD c;
      DWORD dw;
    } u;
    u.dw = GetLargestConsoleWindowSize(h);
    return u.c;
187 188 189 190 191 192 193
}
#define GetLargestConsoleWindowSize(h) __wine_GetLargestConsoleWindowSize_wrapper(h)

#else  /* __i386__ */
COORD WINAPI GetLargestConsoleWindowSize(HANDLE);
#endif  /* __i386__ */

194
BOOL WINAPI   AllocConsole(VOID);
195
HANDLE WINAPI CreateConsoleScreenBuffer( DWORD dwDesiredAccess, DWORD dwShareMode,
196 197 198 199
                                         LPSECURITY_ATTRIBUTES sa, DWORD dwFlags,
                                         LPVOID lpScreenBufferData);
BOOL WINAPI   FillConsoleOutputAttribute( HANDLE hConsoleOutput, WORD wAttribute, DWORD nLength,
                                          COORD dwCoord, LPDWORD lpNumAttrsWritten);
200 201
BOOL WINAPI   FillConsoleOutputCharacterA(HANDLE,CHAR,DWORD,COORD,LPDWORD);
BOOL WINAPI   FillConsoleOutputCharacterW(HANDLE,WCHAR,DWORD,COORD,LPDWORD);
202 203 204 205 206 207 208 209 210 211 212 213 214
#define       FillConsoleOutputCharacter WINELIB_NAME_AW(FillConsoleOutputCharacter)
BOOL WINAPI   FlushConsoleInputBuffer( HANDLE handle);
BOOL WINAPI   FreeConsole(VOID);
BOOL WINAPI   GenerateConsoleCtrlEvent( DWORD dwCtrlEvent, DWORD dwProcessGroupID);
UINT WINAPI   GetConsoleCP(VOID);
BOOL WINAPI   GetConsoleCursorInfo( HANDLE hcon, LPCONSOLE_CURSOR_INFO cinfo);
BOOL WINAPI   GetConsoleMode( HANDLE hcon,LPDWORD mode);
UINT WINAPI   GetConsoleOutputCP(VOID);
BOOL WINAPI   GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
                                         LPCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
DWORD WINAPI  GetConsoleTitleA(LPSTR title,DWORD size);
DWORD WINAPI  GetConsoleTitleW(LPWSTR title, DWORD size);
#define       GetConsoleTitle WINELIB_NAME_AW(GetConsoleTitle)
215
HWND WINAPI   GetConsoleWindow(void);
216 217
BOOL WINAPI   GetNumberOfConsoleInputEvents( HANDLE hcon,LPDWORD nrofevents);
BOOL WINAPI   GetNumberOfConsoleMouseButtons(LPDWORD nrofbuttons);
218 219
BOOL WINAPI   PeekConsoleInputA( HANDLE handle, PINPUT_RECORD buffer, DWORD count, LPDWORD read );
BOOL WINAPI   PeekConsoleInputW( HANDLE handle, PINPUT_RECORD buffer, DWORD count, LPDWORD read );
220 221 222 223 224 225
#define       PeekConsoleInput WINELIB_NAME_AW(PeekConsoleInput)
BOOL WINAPI   ReadConsoleA(HANDLE hConsoleInput, LPVOID lpBuffer, DWORD nNumberOfCharsToRead,
                           LPDWORD lpNumberOfCharsRead, LPVOID lpReserved);
BOOL WINAPI   ReadConsoleW(HANDLE hConsoleInput, LPVOID lpBuffer, DWORD nNumberOfCharsToRead,
                           LPDWORD lpNumberOfCharsRead, LPVOID lpReserved);
#define       ReadConsole WINELIB_NAME_AW(ReadConsole)
226
BOOL WINAPI   ReadConsoleInputA(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength,
227
                                LPDWORD lpNumberOfEventsRead);
228
BOOL WINAPI   ReadConsoleInputW(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength,
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
                                LPDWORD lpNumberOfEventsRead);
#define       ReadConsoleInput WINELIB_NAME_AW(ReadConsoleInput)
BOOL WINAPI   ReadConsoleOutputA( HANDLE hConsoleOutput, LPCHAR_INFO lpBuffer, COORD dwBufferSize,
                                  COORD dwBufferCoord, LPSMALL_RECT lpReadRegion );
BOOL WINAPI   ReadConsoleOutputW( HANDLE hConsoleOutput, LPCHAR_INFO lpBuffer, COORD dwBufferSize,
                                  COORD dwBufferCoord, LPSMALL_RECT lpReadRegion );
#define       ReadConsoleOutput WINELIB_NAME_AW(ReadConsoleOutput)
BOOL WINAPI   ReadConsoleOutputAttribute( HANDLE hConsoleOutput, LPWORD lpAttribute, DWORD nLength,
                                          COORD dwReadCoord, LPDWORD lpNumberOfAttrsRead);
BOOL WINAPI   ReadConsoleOutputCharacterA(HANDLE,LPSTR,DWORD,COORD,LPDWORD);
BOOL WINAPI   ReadConsoleOutputCharacterW(HANDLE,LPWSTR,DWORD,COORD,LPDWORD);
#define       ReadConsoleOutputCharacter WINELIB_NAME_AW(ReadConsoleOutputCharacter)
BOOL WINAPI   ScrollConsoleScreenBufferA( HANDLE hConsoleOutput, LPSMALL_RECT lpScrollRect,
                                          LPSMALL_RECT lpClipRect, COORD dwDestOrigin,
                                          LPCHAR_INFO lpFill);
BOOL WINAPI   ScrollConsoleScreenBufferW( HANDLE hConsoleOutput, LPSMALL_RECT lpScrollRect,
                                          LPSMALL_RECT lpClipRect, COORD dwDestOrigin,
                                          LPCHAR_INFO lpFill);
#define       ScrollConsoleScreenBuffer WINELIB_NAME_AW(ScrollConsoleScreenBuffer)
BOOL WINAPI   SetConsoleActiveScreenBuffer( HANDLE hConsoleOutput);
BOOL WINAPI   SetConsoleCP(UINT cp);
BOOL WINAPI   SetConsoleCtrlHandler( PHANDLER_ROUTINE func, BOOL add);
BOOL WINAPI   SetConsoleCursorInfo( HANDLE hcon, LPCONSOLE_CURSOR_INFO cinfo);
BOOL WINAPI   SetConsoleCursorPosition(HANDLE,COORD);
BOOL WINAPI   SetConsoleMode( HANDLE hcon, DWORD mode);
BOOL WINAPI   SetConsoleOutputCP(UINT cp);
BOOL WINAPI   SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize);
BOOL WINAPI   SetConsoleTextAttribute( HANDLE hConsoleOutput,WORD wAttr);
BOOL WINAPI   SetConsoleTitleA(LPCSTR title);
BOOL WINAPI   SetConsoleTitleW(LPCWSTR title);
#define       SetConsoleTitle WINELIB_NAME_AW(SetConsoleTitle)
BOOL WINAPI   SetConsoleWindowInfo( HANDLE hcon, BOOL bAbsolute, LPSMALL_RECT window);
BOOL WINAPI   WriteConsoleA(HANDLE,CONST VOID *,DWORD,LPDWORD,LPVOID);
BOOL WINAPI   WriteConsoleW(HANDLE, CONST VOID *lpBuffer, DWORD,LPDWORD,LPVOID);
#define       WriteConsole WINELIB_NAME_AW(WriteConsole)
264 265
BOOL WINAPI   WriteConsoleInputA(HANDLE,const INPUT_RECORD *,DWORD,LPDWORD);
BOOL WINAPI   WriteConsoleInputW(HANDLE,const INPUT_RECORD *,DWORD,LPDWORD);
266
#define       WriteConsoleInput WINELIB_NAME_AW(WriteConsoleInput)
267 268
BOOL WINAPI   WriteConsoleOutputA(HANDLE,const CHAR_INFO*,COORD,COORD,LPSMALL_RECT);
BOOL WINAPI   WriteConsoleOutputW(HANDLE,const CHAR_INFO*,COORD,COORD,LPSMALL_RECT);
269 270 271 272 273 274 275 276 277
#define       WriteConsoleOutput WINELIB_NAME_AW(WriteConsoleOutput)
BOOL WINAPI   WriteConsoleOutputAttribute(HANDLE,CONST WORD *,DWORD,COORD,LPDWORD);
BOOL WINAPI   WriteConsoleOutputCharacterA(HANDLE,LPCSTR,DWORD,COORD,LPDWORD);
BOOL WINAPI   WriteConsoleOutputCharacterW(HANDLE,LPCWSTR,DWORD,COORD,LPDWORD);
#define       WriteConsoleOutputCharacter WINELIB_NAME_AW(WriteConsoleOutputCharacter)

#ifdef __cplusplus
}
#endif
278

Alexandre Julliard's avatar
Alexandre Julliard committed
279
#endif  /* __WINE_WINCON_H */