52938
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2018, the original author or authors.
|
|
3 |
*
|
|
4 |
* This software is distributable under the BSD license. See the terms of the
|
|
5 |
* BSD license in the documentation provided with this software.
|
|
6 |
*
|
58903
|
7 |
* https://opensource.org/licenses/BSD-3-Clause
|
52938
|
8 |
*/
|
|
9 |
package jdk.internal.org.jline.terminal.impl.jna.win;
|
|
10 |
|
|
11 |
//OpenJDK changes:
|
|
12 |
//-references to JNA types commented out
|
|
13 |
//-replacement types provided where needed (IntByReference, LastErrorException, Pointer)
|
|
14 |
//-methods not used by JLine commented out
|
|
15 |
//-provided an implementation of the interface (Kernel32Impl), backed by a native implementation (Kernel32.cpp)
|
|
16 |
|
|
17 |
//import com.sun.jna.LastErrorException;
|
|
18 |
//import com.sun.jna.Native;
|
|
19 |
//import com.sun.jna.Pointer;
|
|
20 |
//import com.sun.jna.Structure;
|
|
21 |
//import com.sun.jna.Union;
|
|
22 |
//import com.sun.jna.ptr.IntByReference;
|
|
23 |
//import com.sun.jna.win32.StdCallLibrary;
|
|
24 |
//import com.sun.jna.win32.W32APIOptions;
|
|
25 |
|
|
26 |
interface Kernel32 {//extends StdCallLibrary {
|
|
27 |
|
|
28 |
Kernel32 INSTANCE = new Kernel32Impl();
|
58903
|
29 |
// Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
|
52938
|
30 |
|
|
31 |
// Pointer INVALID_HANDLE_VALUE = Pointer.createConstant(-1L);
|
|
32 |
|
|
33 |
int STD_INPUT_HANDLE = -10;
|
|
34 |
int STD_OUTPUT_HANDLE = -11;
|
|
35 |
int STD_ERROR_HANDLE = -12;
|
|
36 |
|
|
37 |
int ENABLE_PROCESSED_INPUT = 0x0001;
|
|
38 |
int ENABLE_LINE_INPUT = 0x0002;
|
|
39 |
int ENABLE_ECHO_INPUT = 0x0004;
|
|
40 |
int ENABLE_WINDOW_INPUT = 0x0008;
|
|
41 |
int ENABLE_MOUSE_INPUT = 0x0010;
|
|
42 |
int ENABLE_INSERT_MODE = 0x0020;
|
|
43 |
int ENABLE_QUICK_EDIT_MODE = 0x0040;
|
|
44 |
int ENABLE_EXTENDED_FLAGS = 0x0080;
|
|
45 |
|
|
46 |
int RIGHT_ALT_PRESSED = 0x0001;
|
|
47 |
int LEFT_ALT_PRESSED = 0x0002;
|
|
48 |
int RIGHT_CTRL_PRESSED = 0x0004;
|
|
49 |
int LEFT_CTRL_PRESSED = 0x0008;
|
|
50 |
int SHIFT_PRESSED = 0x0010;
|
|
51 |
|
|
52 |
int FOREGROUND_BLUE = 0x0001;
|
|
53 |
int FOREGROUND_GREEN = 0x0002;
|
|
54 |
int FOREGROUND_RED = 0x0004;
|
|
55 |
int FOREGROUND_INTENSITY = 0x0008;
|
|
56 |
int BACKGROUND_BLUE = 0x0010;
|
|
57 |
int BACKGROUND_GREEN = 0x0020;
|
|
58 |
int BACKGROUND_RED = 0x0040;
|
|
59 |
int BACKGROUND_INTENSITY = 0x0080;
|
|
60 |
|
|
61 |
// Button state
|
|
62 |
int FROM_LEFT_1ST_BUTTON_PRESSED = 0x0001;
|
|
63 |
int RIGHTMOST_BUTTON_PRESSED = 0x0002;
|
|
64 |
int FROM_LEFT_2ND_BUTTON_PRESSED = 0x0004;
|
|
65 |
int FROM_LEFT_3RD_BUTTON_PRESSED = 0x0008;
|
|
66 |
int FROM_LEFT_4TH_BUTTON_PRESSED = 0x0010;
|
|
67 |
|
|
68 |
// Event flags
|
|
69 |
int MOUSE_MOVED = 0x0001;
|
|
70 |
int DOUBLE_CLICK = 0x0002;
|
|
71 |
int MOUSE_WHEELED = 0x0004;
|
|
72 |
int MOUSE_HWHEELED = 0x0008;
|
|
73 |
|
|
74 |
// DWORD WINAPI WaitForSingleObject(
|
|
75 |
// _In_ HANDLE hHandle,
|
|
76 |
// _In_ DWORD dwMilliseconds
|
|
77 |
// );
|
|
78 |
int WaitForSingleObject(Pointer in_hHandle, int in_dwMilliseconds);
|
|
79 |
|
|
80 |
// HANDLE WINAPI GetStdHandle(
|
|
81 |
// __in DWORD nStdHandle
|
|
82 |
// );
|
|
83 |
Pointer GetStdHandle(int nStdHandle);
|
|
84 |
|
|
85 |
// // BOOL WINAPI AllocConsole(void);
|
|
86 |
// void AllocConsole() throws LastErrorException;
|
|
87 |
//
|
|
88 |
// // BOOL WINAPI FreeConsole(void);
|
|
89 |
// void FreeConsole() throws LastErrorException;
|
|
90 |
//
|
|
91 |
// // HWND WINAPI GetConsoleWindow(void);
|
|
92 |
// Pointer GetConsoleWindow();
|
|
93 |
//
|
|
94 |
// // UINT WINAPI GetConsoleCP(void)
|
|
95 |
// int GetConsoleCP();
|
|
96 |
//
|
|
97 |
// UINT WINAPI GetConsoleOutputCP(void)
|
|
98 |
int GetConsoleOutputCP();
|
|
99 |
|
|
100 |
// BOOL WINAPI FillConsoleOutputCharacter(
|
|
101 |
// _In_ HANDLE hConsoleOutput,
|
|
102 |
// _In_ TCHAR cCharacter,
|
|
103 |
// _In_ DWORD nLength,
|
|
104 |
// _In_ COORD dwWriteCoord,
|
|
105 |
// _Out_ LPDWORD lpNumberOfCharsWritten);
|
|
106 |
void FillConsoleOutputCharacter(Pointer in_hConsoleOutput,
|
|
107 |
char in_cCharacter, int in_nLength, COORD in_dwWriteCoord,
|
|
108 |
IntByReference out_lpNumberOfCharsWritten)
|
|
109 |
throws LastErrorException;
|
|
110 |
|
|
111 |
// BOOL WINAPI FillConsoleOutputAttribute(
|
|
112 |
// _In_ HANDLE hConsoleOutput,
|
|
113 |
// _In_ WORD wAttribute,
|
|
114 |
// _In_ DWORD nLength,
|
|
115 |
// _In_ COORD dwWriteCoord,
|
|
116 |
// _Out_ LPDWORD lpNumberOfAttrsWritten);
|
|
117 |
void FillConsoleOutputAttribute(Pointer in_hConsoleOutput,
|
|
118 |
short in_wAttribute, int in_nLength, COORD in_dwWriteCoord,
|
|
119 |
IntByReference out_lpNumberOfAttrsWritten)
|
|
120 |
throws LastErrorException;
|
|
121 |
//
|
|
122 |
//// // BOOL WINAPI GetConsoleCursorInfo(
|
|
123 |
//// // _In_ HANDLE hConsoleOutput,
|
|
124 |
//// // _Out_ PCONSOLE_CURSOR_INFO lpConsoleCursorInfo);
|
|
125 |
//// void GetConsoleCursorInfo(Pointer in_hConsoleOutput,
|
|
126 |
//// CONSOLE_CURSOR_INFO.ByReference out_lpConsoleCursorInfo)
|
|
127 |
//// throws LastErrorException;
|
|
128 |
//
|
|
129 |
// BOOL WINAPI GetConsoleMode(
|
|
130 |
// _In_ HANDLE hConsoleHandle,
|
|
131 |
// _Out_ LPDWORD lpMode);
|
|
132 |
void GetConsoleMode(
|
|
133 |
Pointer in_hConsoleOutput,
|
|
134 |
IntByReference out_lpMode)
|
|
135 |
throws LastErrorException;
|
|
136 |
|
|
137 |
// BOOL WINAPI GetConsoleScreenBufferInfo(
|
|
138 |
// _In_ HANDLE hConsoleOutput,
|
|
139 |
// _Out_ PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
|
|
140 |
void GetConsoleScreenBufferInfo(
|
|
141 |
Pointer in_hConsoleOutput,
|
|
142 |
CONSOLE_SCREEN_BUFFER_INFO out_lpConsoleScreenBufferInfo)
|
|
143 |
throws LastErrorException;
|
|
144 |
//
|
|
145 |
// // BOOL WINAPI GetNumberOfConsoleInputEvents(
|
|
146 |
// // _In_ HANDLE hConsoleInput,
|
|
147 |
// // _Out_ LPDWORD lpcNumberOfEvents);
|
|
148 |
// void GetNumberOfConsoleInputEvents(Pointer in_hConsoleOutput,
|
|
149 |
// IntByReference out_lpcNumberOfEvents) throws LastErrorException;
|
|
150 |
//
|
|
151 |
// BOOL WINAPI ReadConsoleInput(
|
|
152 |
// _In_ HANDLE hConsoleInput,
|
|
153 |
// _Out_ PINPUT_RECORD lpBuffer,
|
|
154 |
// _In_ DWORD nLength,
|
|
155 |
// _Out_ LPDWORD lpNumberOfEventsRead);
|
|
156 |
void ReadConsoleInput(Pointer in_hConsoleOutput,
|
|
157 |
INPUT_RECORD[] out_lpBuffer, int in_nLength,
|
|
158 |
IntByReference out_lpNumberOfEventsRead) throws LastErrorException;
|
|
159 |
|
|
160 |
// // BOOL WINAPI SetConsoleCtrlHandler(
|
|
161 |
// // _In_opt_ PHANDLER_ROUTINE HandlerRoutine,
|
|
162 |
// // _In_ BOOL Add);
|
|
163 |
// void SetConsoleCtrlHandler(
|
|
164 |
// Pointer in_opt_HandlerRoutine,
|
|
165 |
// boolean in_Add)
|
|
166 |
// throws LastErrorException;
|
|
167 |
//
|
|
168 |
// // BOOL WINAPI ReadConsoleOutput(
|
|
169 |
// // _In_ HANDLE hConsoleOutput,
|
|
170 |
// // _Out_ PCHAR_INFO lpBuffer,
|
|
171 |
// // _In_ COORD dwBufferSize,
|
|
172 |
// // _In_ COORD dwBufferCoord,
|
|
173 |
// // _Inout_ PSMALL_RECT lpReadRegion);
|
|
174 |
//// void ReadConsoleOutput(Pointer in_hConsoleOutput, CHAR_INFO[] out_lpBuffer,
|
|
175 |
//// COORD in_dwBufferSize, COORD in_dwBufferCoord,
|
|
176 |
//// SMALL_RECT inout_lpReadRegion) throws LastErrorException;
|
|
177 |
//// void ReadConsoleOutputA(Pointer in_hConsoleOutput, CHAR_INFO[] out_lpBuffer,
|
|
178 |
//// COORD in_dwBufferSize, COORD in_dwBufferCoord,
|
|
179 |
//// SMALL_RECT inout_lpReadRegion) throws LastErrorException;
|
|
180 |
//
|
|
181 |
// // BOOL WINAPI ReadConsoleOutputCharacter(
|
|
182 |
// // _In_ HANDLE hConsoleOutput,
|
|
183 |
// // _Out_ LPTSTR lpCharacter,
|
|
184 |
// // _In_ DWORD nLength,
|
|
185 |
// // _In_ COORD dwReadCoord,
|
|
186 |
// // _Out_ LPDWORD lpNumberOfCharsRead);
|
|
187 |
// void ReadConsoleOutputCharacter(Pointer in_hConsoleOutput,
|
|
188 |
// char[] ouy_lpCharacter, int in_nLength, COORD in_dwReadCoord,
|
|
189 |
// IntByReference out_lpNumberOfCharsRead)
|
|
190 |
// throws LastErrorException;
|
|
191 |
// void ReadConsoleOutputCharacterA(Pointer in_hConsoleOutput,
|
|
192 |
// byte[] ouy_lpCharacter, int in_nLength, COORD in_dwReadCoord,
|
|
193 |
// IntByReference out_lpNumberOfCharsRead)
|
|
194 |
// throws LastErrorException;
|
|
195 |
//
|
|
196 |
// // BOOL WINAPI SetConsoleCursorInfo(
|
|
197 |
// // _In_ HANDLE hConsoleOutput,
|
|
198 |
// // _In_ const CONSOLE_CURSOR_INFO *lpConsoleCursorInfo);
|
|
199 |
// void SetConsoleCursorInfo(Pointer in_hConsoleOutput,
|
|
200 |
// CONSOLE_CURSOR_INFO in_lpConsoleCursorInfo)
|
|
201 |
// throws LastErrorException;
|
|
202 |
//
|
|
203 |
// // BOOL WINAPI SetConsoleCP(
|
|
204 |
// // _In_ UINT wCodePageID);
|
|
205 |
// void SetConsoleCP(int in_wCodePageID) throws LastErrorException;
|
|
206 |
//
|
|
207 |
// // BOOL WINAPI SetConsoleOutputCP(
|
|
208 |
// // _In_ UINT wCodePageID);
|
|
209 |
// void SetConsoleOutputCP(int in_wCodePageID) throws LastErrorException;
|
|
210 |
//
|
|
211 |
// BOOL WINAPI SetConsoleCursorPosition(
|
|
212 |
// _In_ HANDLE hConsoleOutput,
|
|
213 |
// _In_ COORD dwCursorPosition);
|
|
214 |
void SetConsoleCursorPosition(Pointer in_hConsoleOutput,
|
|
215 |
COORD in_dwCursorPosition) throws LastErrorException;
|
|
216 |
|
|
217 |
// BOOL WINAPI SetConsoleMode(
|
|
218 |
// _In_ HANDLE hConsoleHandle,
|
|
219 |
// _In_ DWORD dwMode);
|
|
220 |
void SetConsoleMode(
|
|
221 |
Pointer in_hConsoleOutput,
|
|
222 |
int in_dwMode) throws LastErrorException;
|
|
223 |
|
|
224 |
// // BOOL WINAPI SetConsoleScreenBufferSize(
|
|
225 |
// // __in HANDLE hConsoleOutput,
|
|
226 |
// // __in COORD dwSize
|
|
227 |
// // );
|
|
228 |
// void SetConsoleScreenBufferSize(Pointer in_hConsoleOutput,
|
|
229 |
// COORD in_dwSize) throws LastErrorException;
|
|
230 |
//
|
|
231 |
// BOOL WINAPI SetConsoleTextAttribute(
|
|
232 |
// _In_ HANDLE hConsoleOutput,
|
|
233 |
// _In_ WORD wAttributes
|
|
234 |
// );
|
|
235 |
void SetConsoleTextAttribute(Pointer in_hConsoleOutput,
|
|
236 |
short in_wAttributes)
|
|
237 |
throws LastErrorException;
|
|
238 |
|
|
239 |
// BOOL WINAPI SetConsoleTitle(
|
|
240 |
// _In_ LPCTSTR lpConsoleTitle
|
|
241 |
// );
|
|
242 |
void SetConsoleTitle(String in_lpConsoleTitle)
|
|
243 |
throws LastErrorException;
|
|
244 |
|
|
245 |
// // BOOL WINAPI SetConsoleWindowInfo(
|
|
246 |
// // _In_ HANDLE hConsoleOutput,
|
|
247 |
// // _In_ BOOL bAbsolute,
|
|
248 |
// // _In_ const SMALL_RECT *lpConsoleWindow);
|
|
249 |
// void SetConsoleWindowInfo(Pointer in_hConsoleOutput,
|
|
250 |
// boolean in_bAbsolute, SMALL_RECT in_lpConsoleWindow)
|
|
251 |
// throws LastErrorException;
|
|
252 |
|
|
253 |
// BOOL WINAPI WriteConsole(
|
|
254 |
// _In_ HANDLE hConsoleOutput,
|
|
255 |
// _In_ const VOID *lpBuffer,
|
|
256 |
// _In_ DWORD nNumberOfCharsToWrite,
|
|
257 |
// _Out_ LPDWORD lpNumberOfCharsWritten,
|
|
258 |
// _Reserved_ LPVOID lpReserved
|
|
259 |
// );
|
|
260 |
void WriteConsoleW(Pointer in_hConsoleOutput, char[] in_lpBuffer, int in_nNumberOfCharsToWrite,
|
|
261 |
IntByReference out_lpNumberOfCharsWritten, Pointer reserved_lpReserved) throws LastErrorException;
|
|
262 |
|
|
263 |
// // BOOL WINAPI WriteConsoleOutput(
|
|
264 |
// // _In_ HANDLE hConsoleOutput,
|
|
265 |
// // _In_ const CHAR_INFO *lpBuffer,
|
|
266 |
// // _In_ COORD dwBufferSize,
|
|
267 |
// // _In_ COORD dwBufferCoord,
|
|
268 |
// // _Inout_ PSMALL_RECT lpWriteRegion);
|
|
269 |
//// void WriteConsoleOutput(Pointer in_hConsoleOutput, CHAR_INFO[] in_lpBuffer,
|
|
270 |
//// COORD in_dwBufferSize, COORD in_dwBufferCoord,
|
|
271 |
//// SMALL_RECT inout_lpWriteRegion) throws LastErrorException;
|
|
272 |
//// void WriteConsoleOutputA(Pointer in_hConsoleOutput, CHAR_INFO[] in_lpBuffer,
|
|
273 |
//// COORD in_dwBufferSize, COORD in_dwBufferCoord,
|
|
274 |
//// SMALL_RECT inout_lpWriteRegion) throws LastErrorException;
|
|
275 |
//
|
|
276 |
// // BOOL WINAPI WriteConsoleOutputCharacter(
|
|
277 |
// // _In_ HANDLE hConsoleOutput,
|
|
278 |
// // _In_ LPCTSTR lpCharacter,
|
|
279 |
// // _In_ DWORD nLength,
|
|
280 |
// // _In_ COORD dwWriteCoord,
|
|
281 |
// // _Out_ LPDWORD lpNumberOfCharsWritten);
|
|
282 |
// void WriteConsoleOutputCharacter(Pointer in_hConsoleOutput,
|
|
283 |
// char[] in_lpCharacter, int in_nLength, COORD in_dwWriteCoord,
|
|
284 |
// IntByReference out_lpNumberOfCharsWritten)
|
|
285 |
// throws LastErrorException;
|
|
286 |
// void WriteConsoleOutputCharacterA(Pointer in_hConsoleOutput,
|
|
287 |
// byte[] in_lpCharacter, int in_nLength, COORD in_dwWriteCoord,
|
|
288 |
// IntByReference out_lpNumberOfCharsWritten)
|
|
289 |
// throws LastErrorException;
|
|
290 |
//
|
|
291 |
// BOOL WINAPI ScrollConsoleScreenBuffer(
|
|
292 |
// _In_ HANDLE hConsoleOutput,
|
|
293 |
// _In_ const SMALL_RECT *lpScrollRectangle,
|
|
294 |
// _In_opt_ const SMALL_RECT *lpClipRectangle,
|
|
295 |
// _In_ COORD dwDestinationOrigin,
|
|
296 |
// _In_ const CHAR_INFO *lpFill);
|
|
297 |
void ScrollConsoleScreenBuffer(Pointer in_hConsoleOutput,
|
|
298 |
SMALL_RECT in_lpScrollRectangle,
|
|
299 |
SMALL_RECT in_lpClipRectangle,
|
|
300 |
COORD in_dwDestinationOrigin,
|
|
301 |
CHAR_INFO in_lpFill)
|
|
302 |
throws LastErrorException;
|
|
303 |
|
|
304 |
// typedef struct _CHAR_INFO {
|
|
305 |
// union {
|
|
306 |
// WCHAR UnicodeChar;
|
|
307 |
// CHAR AsciiChar;
|
|
308 |
// } Char;
|
|
309 |
// WORD Attributes;
|
|
310 |
// } CHAR_INFO, *PCHAR_INFO;
|
|
311 |
class CHAR_INFO {//extends Structure {
|
|
312 |
public CHAR_INFO() {
|
|
313 |
}
|
|
314 |
|
|
315 |
public CHAR_INFO(char c, short attr) {
|
|
316 |
uChar = new UnionChar(c);
|
|
317 |
Attributes = attr;
|
|
318 |
}
|
|
319 |
|
|
320 |
// public CHAR_INFO(byte c, short attr) {
|
|
321 |
// uChar = new UnionChar(c);
|
|
322 |
// Attributes = attr;
|
|
323 |
// }
|
|
324 |
|
|
325 |
public UnionChar uChar;
|
|
326 |
public short Attributes;
|
|
327 |
|
|
328 |
// public static CHAR_INFO[] createArray(int size) {
|
|
329 |
// return (CHAR_INFO[]) new CHAR_INFO().toArray(size);
|
|
330 |
// }
|
|
331 |
//
|
|
332 |
// private static String[] fieldOrder = { "uChar", "Attributes" };
|
|
333 |
//
|
|
334 |
// @Override
|
|
335 |
// protected java.util.List<String> getFieldOrder() {
|
|
336 |
// return java.util.Arrays.asList(fieldOrder);
|
|
337 |
// }
|
|
338 |
}
|
|
339 |
|
|
340 |
// typedef struct _CONSOLE_CURSOR_INFO {
|
|
341 |
// DWORD dwSize;
|
|
342 |
// BOOL bVisible;
|
|
343 |
// } CONSOLE_CURSOR_INFO, *PCONSOLE_CURSOR_INFO;
|
|
344 |
class CONSOLE_CURSOR_INFO {//extends Structure {
|
|
345 |
public int dwSize;
|
|
346 |
public boolean bVisible;
|
|
347 |
|
|
348 |
// public static class ByReference extends CONSOLE_CURSOR_INFO implements
|
|
349 |
// Structure.ByReference {
|
|
350 |
// }
|
|
351 |
//
|
|
352 |
// private static String[] fieldOrder = { "dwSize", "bVisible" };
|
|
353 |
//
|
|
354 |
// @Override
|
|
355 |
// protected java.util.List<String> getFieldOrder() {
|
|
356 |
// return java.util.Arrays.asList(fieldOrder);
|
|
357 |
// }
|
|
358 |
}
|
|
359 |
|
|
360 |
// typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
|
|
361 |
// COORD dwSize;
|
|
362 |
// COORD dwCursorPosition;
|
|
363 |
// WORD wAttributes;
|
|
364 |
// SMALL_RECT srWindow;
|
|
365 |
// COORD dwMaximumWindowSize;
|
|
366 |
// } CONSOLE_SCREEN_BUFFER_INFO;
|
|
367 |
class CONSOLE_SCREEN_BUFFER_INFO {//extends Structure {
|
|
368 |
public COORD dwSize;
|
|
369 |
public COORD dwCursorPosition;
|
|
370 |
public short wAttributes;
|
|
371 |
public SMALL_RECT srWindow;
|
|
372 |
public COORD dwMaximumWindowSize;
|
|
373 |
|
|
374 |
// private static String[] fieldOrder = { "dwSize", "dwCursorPosition", "wAttributes", "srWindow", "dwMaximumWindowSize" };
|
|
375 |
//
|
|
376 |
// @Override
|
|
377 |
// protected java.util.List<String> getFieldOrder() {
|
|
378 |
// return java.util.Arrays.asList(fieldOrder);
|
|
379 |
// }
|
|
380 |
|
|
381 |
public int windowWidth() {
|
|
382 |
return this.srWindow.width() + 1;
|
|
383 |
}
|
|
384 |
|
|
385 |
public int windowHeight() {
|
|
386 |
return this.srWindow.height() + 1;
|
|
387 |
}
|
|
388 |
}
|
|
389 |
|
|
390 |
// typedef struct _COORD {
|
|
391 |
// SHORT X;
|
|
392 |
// SHORT Y;
|
|
393 |
// } COORD, *PCOORD;
|
|
394 |
class COORD {//extends Structure implements Structure.ByValue {
|
|
395 |
public COORD() {
|
|
396 |
}
|
|
397 |
|
|
398 |
public COORD(short X, short Y) {
|
|
399 |
this.X = X;
|
|
400 |
this.Y = Y;
|
|
401 |
}
|
|
402 |
|
|
403 |
public short X;
|
|
404 |
public short Y;
|
|
405 |
|
|
406 |
// private static String[] fieldOrder = { "X", "Y" };
|
|
407 |
//
|
|
408 |
// @Override
|
|
409 |
// protected java.util.List<String> getFieldOrder() {
|
|
410 |
// return java.util.Arrays.asList(fieldOrder);
|
|
411 |
// }
|
|
412 |
}
|
|
413 |
|
|
414 |
// typedef struct _INPUT_RECORD {
|
|
415 |
// WORD EventType;
|
|
416 |
// union {
|
|
417 |
// KEY_EVENT_RECORD KeyEvent;
|
|
418 |
// MOUSE_EVENT_RECORD MouseEvent;
|
|
419 |
// WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
|
|
420 |
// MENU_EVENT_RECORD MenuEvent;
|
|
421 |
// FOCUS_EVENT_RECORD FocusEvent;
|
|
422 |
// } Event;
|
|
423 |
// } INPUT_RECORD;
|
|
424 |
class INPUT_RECORD {//extends Structure {
|
|
425 |
public static final short KEY_EVENT = 0x0001;
|
|
426 |
public static final short MOUSE_EVENT = 0x0002;
|
|
427 |
public static final short WINDOW_BUFFER_SIZE_EVENT = 0x0004;
|
|
428 |
public static final short MENU_EVENT = 0x0008;
|
|
429 |
public static final short FOCUS_EVENT = 0x0010;
|
|
430 |
|
|
431 |
public short EventType;
|
|
432 |
public EventUnion Event;
|
|
433 |
|
|
434 |
public static class EventUnion {//extends Union {
|
|
435 |
public KEY_EVENT_RECORD KeyEvent;
|
|
436 |
public MOUSE_EVENT_RECORD MouseEvent;
|
|
437 |
public WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
|
|
438 |
public MENU_EVENT_RECORD MenuEvent;
|
|
439 |
public FOCUS_EVENT_RECORD FocusEvent;
|
|
440 |
}
|
|
441 |
|
|
442 |
// @Override
|
|
443 |
// public void read() {
|
|
444 |
// readField("EventType");
|
|
445 |
// switch (EventType) {
|
|
446 |
// case KEY_EVENT:
|
|
447 |
// Event.setType(KEY_EVENT_RECORD.class);
|
|
448 |
// break;
|
|
449 |
// case MOUSE_EVENT:
|
|
450 |
// Event.setType(MOUSE_EVENT_RECORD.class);
|
|
451 |
// break;
|
|
452 |
// case WINDOW_BUFFER_SIZE_EVENT:
|
|
453 |
// Event.setType(WINDOW_BUFFER_SIZE_RECORD.class);
|
|
454 |
// break;
|
|
455 |
// case MENU_EVENT:
|
|
456 |
// Event.setType(MENU_EVENT_RECORD.class);
|
|
457 |
// break;
|
|
458 |
// case FOCUS_EVENT:
|
|
459 |
// Event.setType(MENU_EVENT_RECORD.class);
|
|
460 |
// break;
|
|
461 |
// }
|
|
462 |
// super.read();
|
|
463 |
// }
|
|
464 |
|
|
465 |
// private static String[] fieldOrder = {"EventType", "Event"};
|
|
466 |
//
|
|
467 |
// @Override
|
|
468 |
// protected java.util.List<String> getFieldOrder() {
|
|
469 |
// return java.util.Arrays.asList(fieldOrder);
|
|
470 |
// }
|
|
471 |
}
|
|
472 |
|
|
473 |
// typedef struct _KEY_EVENT_RECORD {
|
|
474 |
// BOOL bKeyDown;
|
|
475 |
// WORD wRepeatCount;
|
|
476 |
// WORD wVirtualKeyCode;
|
|
477 |
// WORD wVirtualScanCode;
|
|
478 |
// union {
|
|
479 |
// WCHAR UnicodeChar;
|
|
480 |
// CHAR AsciiChar;
|
|
481 |
// } uChar;
|
|
482 |
// DWORD dwControlKeyState;
|
|
483 |
// } KEY_EVENT_RECORD;
|
|
484 |
class KEY_EVENT_RECORD {//extends Structure {
|
|
485 |
public boolean bKeyDown;
|
|
486 |
public short wRepeatCount;
|
|
487 |
public short wVirtualKeyCode;
|
|
488 |
public short wVirtualScanCode;
|
|
489 |
public UnionChar uChar;
|
|
490 |
public int dwControlKeyState;
|
|
491 |
|
|
492 |
// private static String[] fieldOrder = {"bKeyDown", "wRepeatCount", "wVirtualKeyCode", "wVirtualScanCode", "uChar", "dwControlKeyState"};
|
|
493 |
//
|
|
494 |
// @Override
|
|
495 |
// protected java.util.List<String> getFieldOrder() {
|
|
496 |
// return java.util.Arrays.asList(fieldOrder);
|
|
497 |
// }
|
|
498 |
}
|
|
499 |
|
|
500 |
// typedef struct _MOUSE_EVENT_RECORD {
|
|
501 |
// COORD dwMousePosition;
|
|
502 |
// DWORD dwButtonState;
|
|
503 |
// DWORD dwControlKeyState;
|
|
504 |
// DWORD dwEventFlags;
|
|
505 |
// } MOUSE_EVENT_RECORD;
|
|
506 |
class MOUSE_EVENT_RECORD {//extends Structure {
|
|
507 |
public COORD dwMousePosition;
|
|
508 |
public int dwButtonState;
|
|
509 |
public int dwControlKeyState;
|
|
510 |
public int dwEventFlags;
|
|
511 |
|
|
512 |
// private static String[] fieldOrder = { "dwMousePosition", "dwButtonState", "dwControlKeyState", "dwEventFlags"};
|
|
513 |
//
|
|
514 |
// @Override
|
|
515 |
// protected java.util.List<String> getFieldOrder() {
|
|
516 |
// return java.util.Arrays.asList(fieldOrder);
|
|
517 |
// }
|
|
518 |
}
|
|
519 |
|
|
520 |
// typedef struct _WINDOW_BUFFER_SIZE_RECORD {
|
|
521 |
// COORD dwSize;
|
|
522 |
// } WINDOW_BUFFER_SIZE_RECORD;
|
|
523 |
class WINDOW_BUFFER_SIZE_RECORD {//extends Structure {
|
|
524 |
public COORD dwSize;
|
|
525 |
|
|
526 |
// private static String[] fieldOrder = {"dwSize"};
|
|
527 |
//
|
|
528 |
// @Override
|
|
529 |
// protected java.util.List<String> getFieldOrder() {
|
|
530 |
// return java.util.Arrays.asList(fieldOrder);
|
|
531 |
// }
|
|
532 |
}
|
|
533 |
|
|
534 |
// typedef struct _MENU_EVENT_RECORD {
|
|
535 |
// UINT dwCommandId;
|
|
536 |
// } MENU_EVENT_RECORD, *PMENU_EVENT_RECORD;
|
|
537 |
class MENU_EVENT_RECORD {//extends Structure {
|
|
538 |
|
|
539 |
public int dwCommandId;
|
|
540 |
|
|
541 |
// private static String[] fieldOrder = {"dwCommandId"};
|
|
542 |
//
|
|
543 |
// @Override
|
|
544 |
// protected java.util.List<String> getFieldOrder() {
|
|
545 |
// return java.util.Arrays.asList(fieldOrder);
|
|
546 |
// }
|
|
547 |
}
|
|
548 |
|
|
549 |
// typedef struct _FOCUS_EVENT_RECORD {
|
|
550 |
// BOOL bSetFocus;
|
|
551 |
//} FOCUS_EVENT_RECORD;
|
|
552 |
class FOCUS_EVENT_RECORD {//extends Structure {
|
|
553 |
public boolean bSetFocus;
|
|
554 |
|
|
555 |
// private static String[] fieldOrder = {"bSetFocus"};
|
|
556 |
//
|
|
557 |
// @Override
|
|
558 |
// protected java.util.List<String> getFieldOrder() {
|
|
559 |
// return java.util.Arrays.asList(fieldOrder);
|
|
560 |
// }
|
|
561 |
}
|
|
562 |
|
|
563 |
// typedef struct _SMALL_RECT {
|
|
564 |
// SHORT Left;
|
|
565 |
// SHORT Top;
|
|
566 |
// SHORT Right;
|
|
567 |
// SHORT Bottom;
|
|
568 |
// } SMALL_RECT;
|
|
569 |
class SMALL_RECT {//extends Structure {
|
|
570 |
public SMALL_RECT() {
|
|
571 |
}
|
|
572 |
|
|
573 |
public SMALL_RECT(SMALL_RECT org) {
|
|
574 |
this(org.Top, org.Left, org.Bottom, org.Right);
|
|
575 |
}
|
|
576 |
|
|
577 |
public SMALL_RECT(short Top, short Left, short Bottom, short Right) {
|
|
578 |
this.Top = Top;
|
|
579 |
this.Left = Left;
|
|
580 |
this.Bottom = Bottom;
|
|
581 |
this.Right = Right;
|
|
582 |
}
|
|
583 |
|
|
584 |
public short Left;
|
|
585 |
public short Top;
|
|
586 |
public short Right;
|
|
587 |
public short Bottom;
|
|
588 |
|
|
589 |
// private static String[] fieldOrder = { "Left", "Top", "Right", "Bottom" };
|
|
590 |
//
|
|
591 |
// @Override
|
|
592 |
// protected java.util.List<String> getFieldOrder() {
|
|
593 |
// return java.util.Arrays.asList(fieldOrder);
|
|
594 |
// }
|
|
595 |
|
|
596 |
public short width() {
|
|
597 |
return (short)(this.Right - this.Left);
|
|
598 |
}
|
|
599 |
|
|
600 |
public short height() {
|
|
601 |
return (short)(this.Bottom - this.Top);
|
|
602 |
}
|
|
603 |
|
|
604 |
}
|
|
605 |
|
|
606 |
class UnionChar {//extends Union {
|
|
607 |
public UnionChar() {
|
|
608 |
}
|
|
609 |
|
|
610 |
public UnionChar(char c) {
|
|
611 |
// setType(char.class);
|
|
612 |
UnicodeChar = c;
|
|
613 |
}
|
|
614 |
|
|
615 |
// public UnionChar(byte c) {
|
|
616 |
// setType(byte.class);
|
|
617 |
// AsciiChar = c;
|
|
618 |
// }
|
|
619 |
|
|
620 |
public void set(char c) {
|
|
621 |
// setType(char.class);
|
|
622 |
UnicodeChar = c;
|
|
623 |
}
|
|
624 |
|
|
625 |
// public void set(byte c) {
|
|
626 |
// setType(byte.class);
|
|
627 |
// AsciiChar = c;
|
|
628 |
// }
|
|
629 |
|
|
630 |
public char UnicodeChar;
|
|
631 |
// public byte AsciiChar;
|
|
632 |
}
|
|
633 |
}
|