source: Daodan/MinGW/include/wincon.h@ 1089

Last change on this file since 1089 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 8.1 KB
RevLine 
[1046]1#ifndef _WINCON_H
2#define _WINCON_H
3#if __GNUC__ >= 3
4#pragma GCC system_header
5#endif
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#define FOREGROUND_BLUE 1
12#define FOREGROUND_GREEN 2
13#define FOREGROUND_RED 4
14#define FOREGROUND_INTENSITY 8
15#define BACKGROUND_BLUE 16
16#define BACKGROUND_GREEN 32
17#define BACKGROUND_RED 64
18#define BACKGROUND_INTENSITY 128
19#if (_WIN32_WINNT >= 0x0501)
20#define CONSOLE_FULLSCREEN_MODE 1
21#define CONSOLE_WINDOWED_MODE 2
22#endif
23#define CTRL_C_EVENT 0
24#define CTRL_BREAK_EVENT 1
25#define CTRL_CLOSE_EVENT 2
26#define CTRL_LOGOFF_EVENT 5
27#define CTRL_SHUTDOWN_EVENT 6
28#define ENABLE_LINE_INPUT 2
29#define ENABLE_ECHO_INPUT 4
30#define ENABLE_PROCESSED_INPUT 1
31#define ENABLE_WINDOW_INPUT 8
32#define ENABLE_MOUSE_INPUT 16
33#define ENABLE_INSERT_MODE 32
34#define ENABLE_QUICK_EDIT_MODE 64
35#define ENABLE_EXTENDED_FLAGS 128
36#define ENABLE_AUTO_POSITION 256
37#define ENABLE_PROCESSED_OUTPUT 1
38#define ENABLE_WRAP_AT_EOL_OUTPUT 2
39#define KEY_EVENT 1
40#define MOUSE_EVENT 2
41#define WINDOW_BUFFER_SIZE_EVENT 4
42#define MENU_EVENT 8
43#define FOCUS_EVENT 16
44#define CAPSLOCK_ON 128
45#define ENHANCED_KEY 256
46#define RIGHT_ALT_PRESSED 1
47#define LEFT_ALT_PRESSED 2
48#define RIGHT_CTRL_PRESSED 4
49#define LEFT_CTRL_PRESSED 8
50#define SHIFT_PRESSED 16
51#define NUMLOCK_ON 32
52#define SCROLLLOCK_ON 64
53#define FROM_LEFT_1ST_BUTTON_PRESSED 1
54#define RIGHTMOST_BUTTON_PRESSED 2
55#define FROM_LEFT_2ND_BUTTON_PRESSED 4
56#define FROM_LEFT_3RD_BUTTON_PRESSED 8
57#define FROM_LEFT_4TH_BUTTON_PRESSED 16
58#define MOUSE_MOVED 1
59#define DOUBLE_CLICK 2
60#define MOUSE_WHEELED 4
61
62typedef struct _CHAR_INFO {
63 union {
64 WCHAR UnicodeChar;
65 CHAR AsciiChar;
66 } Char;
67 WORD Attributes;
68} CHAR_INFO, *PCHAR_INFO;
69typedef struct _SMALL_RECT {
70 SHORT Left;
71 SHORT Top;
72 SHORT Right;
73 SHORT Bottom;
74} SMALL_RECT, *PSMALL_RECT;
75typedef struct _CONSOLE_CURSOR_INFO {
76 DWORD dwSize;
77 BOOL bVisible;
78} CONSOLE_CURSOR_INFO,*PCONSOLE_CURSOR_INFO;
79typedef struct _COORD {
80 SHORT X;
81 SHORT Y;
82} COORD, *PCOORD;
83typedef struct _CONSOLE_FONT_INFO {
84 DWORD nFont;
85 COORD dwFontSize;
86} CONSOLE_FONT_INFO, *PCONSOLE_FONT_INFO;
87typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
88 COORD dwSize;
89 COORD dwCursorPosition;
90 WORD wAttributes;
91 SMALL_RECT srWindow;
92 COORD dwMaximumWindowSize;
93} CONSOLE_SCREEN_BUFFER_INFO,*PCONSOLE_SCREEN_BUFFER_INFO;
94typedef BOOL(CALLBACK *PHANDLER_ROUTINE)(DWORD);
95typedef struct _KEY_EVENT_RECORD {
96 BOOL bKeyDown;
97 WORD wRepeatCount;
98 WORD wVirtualKeyCode;
99 WORD wVirtualScanCode;
100 union {
101 WCHAR UnicodeChar;
102 CHAR AsciiChar;
103 } uChar;
104 DWORD dwControlKeyState;
105}
106#ifdef __GNUC__
107/* gcc's alignment is not what win32 expects */
108 __attribute__((packed))
109#endif
110KEY_EVENT_RECORD;
111
112typedef struct _MOUSE_EVENT_RECORD {
113 COORD dwMousePosition;
114 DWORD dwButtonState;
115 DWORD dwControlKeyState;
116 DWORD dwEventFlags;
117} MOUSE_EVENT_RECORD;
118typedef struct _WINDOW_BUFFER_SIZE_RECORD { COORD dwSize; } WINDOW_BUFFER_SIZE_RECORD;
119typedef struct _MENU_EVENT_RECORD { UINT dwCommandId; } MENU_EVENT_RECORD,*PMENU_EVENT_RECORD;
120typedef struct _FOCUS_EVENT_RECORD { BOOL bSetFocus; } FOCUS_EVENT_RECORD;
121typedef struct _INPUT_RECORD {
122 WORD EventType;
123 union {
124 KEY_EVENT_RECORD KeyEvent;
125 MOUSE_EVENT_RECORD MouseEvent;
126 WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
127 MENU_EVENT_RECORD MenuEvent;
128 FOCUS_EVENT_RECORD FocusEvent;
129 } Event;
130} INPUT_RECORD,*PINPUT_RECORD;
131
132BOOL WINAPI AllocConsole(void);
133#if (_WIN32_WINNT >= 0x0501)
134#define ATTACH_PARENT_PROCESS ((DWORD)-1)
135BOOL WINAPI AttachConsole(DWORD);
136#endif
137HANDLE WINAPI CreateConsoleScreenBuffer(DWORD,DWORD,CONST SECURITY_ATTRIBUTES*,DWORD,LPVOID);
138BOOL WINAPI FillConsoleOutputAttribute(HANDLE,WORD,DWORD,COORD,PDWORD);
139BOOL WINAPI FillConsoleOutputCharacterA(HANDLE,CHAR,DWORD,COORD,PDWORD);
140BOOL WINAPI FillConsoleOutputCharacterW(HANDLE,WCHAR,DWORD,COORD,PDWORD);
141BOOL WINAPI FlushConsoleInputBuffer(HANDLE);
142BOOL WINAPI FreeConsole(void);
143BOOL WINAPI GenerateConsoleCtrlEvent(DWORD,DWORD);
144UINT WINAPI GetConsoleCP(void);
145BOOL WINAPI GetConsoleCursorInfo(HANDLE,PCONSOLE_CURSOR_INFO);
146BOOL WINAPI GetConsoleMode(HANDLE,PDWORD);
147UINT WINAPI GetConsoleOutputCP(void);
148BOOL WINAPI GetConsoleScreenBufferInfo(HANDLE,PCONSOLE_SCREEN_BUFFER_INFO);
149DWORD WINAPI GetConsoleTitleA(LPSTR,DWORD);
150DWORD WINAPI GetConsoleTitleW(LPWSTR,DWORD);
151#if (_WIN32_WINNT >= 0x0500)
152BOOL WINAPI GetConsoleDisplayMode(LPDWORD);
153HWND WINAPI GetConsoleWindow(void);
154#endif
155#if (_WIN32_WINNT >= 0x0501)
156DWORD WINAPI GetConsoleProcessList(LPDWORD, DWORD);
157#endif
158COORD WINAPI GetLargestConsoleWindowSize(HANDLE);
159BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE,PDWORD);
160BOOL WINAPI GetNumberOfConsoleMouseButtons(PDWORD);
161BOOL WINAPI PeekConsoleInputA(HANDLE,PINPUT_RECORD,DWORD,PDWORD);
162BOOL WINAPI PeekConsoleInputW(HANDLE,PINPUT_RECORD,DWORD,PDWORD);
163BOOL WINAPI ReadConsoleA(HANDLE,PVOID,DWORD,PDWORD,PVOID);
164BOOL WINAPI ReadConsoleW(HANDLE,PVOID,DWORD,PDWORD,PVOID);
165BOOL WINAPI ReadConsoleInputA(HANDLE,PINPUT_RECORD,DWORD,PDWORD);
166BOOL WINAPI ReadConsoleInputW(HANDLE,PINPUT_RECORD,DWORD,PDWORD);
167BOOL WINAPI ReadConsoleOutputAttribute(HANDLE,LPWORD,DWORD,COORD,LPDWORD);
168BOOL WINAPI ReadConsoleOutputCharacterA(HANDLE,LPSTR,DWORD,COORD,PDWORD);
169BOOL WINAPI ReadConsoleOutputCharacterW(HANDLE,LPWSTR,DWORD,COORD,PDWORD);
170BOOL WINAPI ReadConsoleOutputA(HANDLE,PCHAR_INFO,COORD,COORD,PSMALL_RECT);
171BOOL WINAPI ReadConsoleOutputW(HANDLE,PCHAR_INFO,COORD,COORD,PSMALL_RECT);
172BOOL WINAPI ScrollConsoleScreenBufferA(HANDLE,const SMALL_RECT*,const SMALL_RECT*,COORD,const CHAR_INFO*);
173BOOL WINAPI ScrollConsoleScreenBufferW(HANDLE,const SMALL_RECT*,const SMALL_RECT*,COORD,const CHAR_INFO*);
174BOOL WINAPI SetConsoleActiveScreenBuffer(HANDLE);
175BOOL WINAPI SetConsoleCP(UINT);
176BOOL WINAPI SetConsoleCtrlHandler(PHANDLER_ROUTINE,BOOL);
177BOOL WINAPI SetConsoleCursorInfo(HANDLE,const CONSOLE_CURSOR_INFO*);
178BOOL WINAPI SetConsoleCursorPosition(HANDLE,COORD);
179#if (_WIN32_WINNT >= 0x0501)
180BOOL WINAPI SetConsoleDisplayMode(HANDLE,DWORD,PCOORD);
181#endif
182BOOL WINAPI SetConsoleMode(HANDLE,DWORD);
183BOOL WINAPI SetConsoleOutputCP(UINT);
184BOOL WINAPI SetConsoleScreenBufferSize(HANDLE,COORD);
185BOOL WINAPI SetConsoleTextAttribute(HANDLE,WORD);
186BOOL WINAPI SetConsoleTitleA(LPCSTR);
187BOOL WINAPI SetConsoleTitleW(LPCWSTR);
188BOOL WINAPI SetConsoleWindowInfo(HANDLE,BOOL,const SMALL_RECT*);
189BOOL WINAPI WriteConsoleA(HANDLE,PCVOID,DWORD,PDWORD,PVOID);
190BOOL WINAPI WriteConsoleW(HANDLE,PCVOID,DWORD,PDWORD,PVOID);
191BOOL WINAPI WriteConsoleInputA(HANDLE,const INPUT_RECORD*,DWORD,PDWORD);
192BOOL WINAPI WriteConsoleInputW(HANDLE,const INPUT_RECORD*,DWORD,PDWORD);
193BOOL WINAPI WriteConsoleOutputA(HANDLE,const CHAR_INFO*,COORD,COORD,PSMALL_RECT);
194BOOL WINAPI WriteConsoleOutputW(HANDLE,const CHAR_INFO*,COORD,COORD,PSMALL_RECT);
195BOOL WINAPI WriteConsoleOutputAttribute(HANDLE,const WORD*,DWORD,COORD,PDWORD);
196BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE,LPCSTR,DWORD,COORD,PDWORD);
197BOOL WINAPI WriteConsoleOutputCharacterW(HANDLE,LPCWSTR,DWORD,COORD,PDWORD);
198
199#ifdef UNICODE
200#define FillConsoleOutputCharacter FillConsoleOutputCharacterW
201#define GetConsoleTitle GetConsoleTitleW
202#define PeekConsoleInput PeekConsoleInputW
203#define ReadConsole ReadConsoleW
204#define ReadConsoleInput ReadConsoleInputW
205#define ReadConsoleOutput ReadConsoleOutputW
206#define ReadConsoleOutputCharacter ReadConsoleOutputCharacterW
207#define ScrollConsoleScreenBuffer ScrollConsoleScreenBufferW
208#define SetConsoleTitle SetConsoleTitleW
209#define WriteConsole WriteConsoleW
210#define WriteConsoleInput WriteConsoleInputW
211#define WriteConsoleOutput WriteConsoleOutputW
212#define WriteConsoleOutputCharacter WriteConsoleOutputCharacterW
213#else
214#define FillConsoleOutputCharacter FillConsoleOutputCharacterA
215#define GetConsoleTitle GetConsoleTitleA
216#define PeekConsoleInput PeekConsoleInputA
217#define ReadConsole ReadConsoleA
218#define ReadConsoleInput ReadConsoleInputA
219#define ReadConsoleOutput ReadConsoleOutputA
220#define ReadConsoleOutputCharacter ReadConsoleOutputCharacterA
221#define ScrollConsoleScreenBuffer ScrollConsoleScreenBufferA
222#define SetConsoleTitle SetConsoleTitleA
223#define WriteConsole WriteConsoleA
224#define WriteConsoleInput WriteConsoleInputA
225#define WriteConsoleOutput WriteConsoleOutputA
226#define WriteConsoleOutputCharacter WriteConsoleOutputCharacterA
227#endif
228
229#ifdef __cplusplus
230}
231#endif
232#endif
Note: See TracBrowser for help on using the repository browser.