1 | /* $Id: console.cpp,v 1.33 2004-02-19 13:03:06 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 Console API Translation for OS/2
|
---|
5 | *
|
---|
6 | * 1998/02/10 Patrick Haller (haller@zebra.fh-weingarten.de)
|
---|
7 | *
|
---|
8 | * @(#) console.cpp 1.0.0 1998/02/10 PH Start from scratch
|
---|
9 | *
|
---|
10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
11 | *
|
---|
12 | */
|
---|
13 |
|
---|
14 |
|
---|
15 | #ifdef DEBUG
|
---|
16 | #define DEBUG_LOCAL
|
---|
17 | #define DEBUG_LOCAL2
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | //#undef DEBUG_LOCAL
|
---|
21 | //#undef DEBUG_LOCAL2
|
---|
22 |
|
---|
23 |
|
---|
24 | /*****************************************************************************
|
---|
25 | * Remark *
|
---|
26 | *****************************************************************************
|
---|
27 |
|
---|
28 | - DWORD HandlerRoutine (DWORD dwCtrlType)
|
---|
29 | basically an exception handler routine. handles a few signals / excpts.
|
---|
30 | should be somewhere near the exception handling code ... :)
|
---|
31 |
|
---|
32 | Hmm, however as PM applications don't really get a ctrl-c signal,
|
---|
33 | I'll have to do this on my own ...
|
---|
34 |
|
---|
35 | - supply unicode<->ascii conversions for all the _A and _W function pairs.
|
---|
36 |
|
---|
37 | - problem: we can't prevent thread1 from blocking the message queue ?
|
---|
38 | what will happen if a WinTerminate() is issued there ?
|
---|
39 | will the message queue be closed and provide smooth tasking ?
|
---|
40 | how will open32 react on this ?
|
---|
41 |
|
---|
42 | - ECHO_LINE_INPUT / ReadFile blocks till CR
|
---|
43 |
|
---|
44 | - scrollbars
|
---|
45 | * do some flowchart to exactly determine WHEN to use WHICH setting
|
---|
46 | and perform WHAT action
|
---|
47 |
|
---|
48 | - clipboard support
|
---|
49 | */
|
---|
50 |
|
---|
51 |
|
---|
52 | /*******************************************************************************
|
---|
53 | * Header Files *
|
---|
54 | *******************************************************************************/
|
---|
55 |
|
---|
56 | // Vio/Kbd/Mou declarations conflict in GCC and in real OS2TK headers;
|
---|
57 | // force GCC declarations since we link against GCC libs
|
---|
58 | #if defined (__EMX__) && defined (USE_OS2_TOOLKIT_HEADERS)
|
---|
59 | #undef USE_OS2_TOOLKIT_HEADERS
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | #define INCL_WIN
|
---|
63 | #define INCL_DOSMEMMGR
|
---|
64 | #define INCL_DOSSEMAPHORES
|
---|
65 | #define INCL_DOSERRORS
|
---|
66 | #define INCL_DOSEXCEPTIONS
|
---|
67 | #define INCL_DOSPROCESS
|
---|
68 | #define INCL_DOSMODULEMGR
|
---|
69 | #define INCL_DOSDEVICES
|
---|
70 | #define INCL_VIO
|
---|
71 | #define INCL_KBD
|
---|
72 | #define INCL_AVIO
|
---|
73 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
74 |
|
---|
75 | #include <process.h>
|
---|
76 | #include <stdlib.h>
|
---|
77 | #include <string.h>
|
---|
78 |
|
---|
79 | #include <win32type.h>
|
---|
80 | #include <win32api.h>
|
---|
81 | #include <misc.h>
|
---|
82 | #include <odincrt.h>
|
---|
83 |
|
---|
84 | #include "conwin.h" // Windows Header for console only
|
---|
85 | #include "HandleManager.h"
|
---|
86 | #include "handlenames.h"
|
---|
87 | #include "HMDevice.h"
|
---|
88 |
|
---|
89 | #include "console.h"
|
---|
90 | #include "console2.h"
|
---|
91 | #include "conin.h"
|
---|
92 | #include "conout.h"
|
---|
93 | #include "conbuffer.h"
|
---|
94 | #include "conbuffervio.h"
|
---|
95 |
|
---|
96 | #include "conprop.h"
|
---|
97 | #include "unicode.h"
|
---|
98 | #include "heapstring.h"
|
---|
99 |
|
---|
100 | #define DBG_LOCALLOG DBG_console
|
---|
101 | #include "dbglocal.h"
|
---|
102 |
|
---|
103 | #include <os2sel.h>
|
---|
104 |
|
---|
105 |
|
---|
106 | /*******************************************************************************
|
---|
107 | * Process Global Structures *
|
---|
108 | *******************************************************************************/
|
---|
109 | static ICONSOLEGLOBALS ConsoleGlobals;
|
---|
110 | static ICONSOLEINPUT ConsoleInput;
|
---|
111 | BOOL flVioConsole = FALSE;
|
---|
112 |
|
---|
113 | /*******************************************************************************
|
---|
114 | * Internal Functions *
|
---|
115 | *******************************************************************************/
|
---|
116 | static void iConsoleInputQueueLock();
|
---|
117 | static void iConsoleInputQueueUnlock();
|
---|
118 |
|
---|
119 |
|
---|
120 | /*****************************************************************************
|
---|
121 | * Name : iConsoleInputQueueLock
|
---|
122 | * Purpose : lock the input queue to ensure correct event sequence
|
---|
123 | * Parameters:
|
---|
124 | * Variables :
|
---|
125 | * Result :
|
---|
126 | * Remark :
|
---|
127 | * Status :
|
---|
128 | *
|
---|
129 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
130 | *****************************************************************************/
|
---|
131 |
|
---|
132 | static void iConsoleInputQueueLock()
|
---|
133 | {
|
---|
134 | APIRET rc;
|
---|
135 |
|
---|
136 | rc = DosRequestMutexSem(ConsoleInput.hmtxInputQueue,
|
---|
137 | SEM_INDEFINITE_WAIT);
|
---|
138 | if (rc != NO_ERROR)
|
---|
139 | dprintf(("KERNEL32: Console:iConsoleInputQueueLock error %08xh\n",
|
---|
140 | rc));
|
---|
141 | }
|
---|
142 |
|
---|
143 |
|
---|
144 | /*****************************************************************************
|
---|
145 | * Name : iConsoleInputQueueUnlock
|
---|
146 | * Purpose : unlock the input queue
|
---|
147 | * Parameters:
|
---|
148 | * Variables :
|
---|
149 | * Result :
|
---|
150 | * Remark :
|
---|
151 | * Status :
|
---|
152 | *
|
---|
153 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
154 | *****************************************************************************/
|
---|
155 |
|
---|
156 | static void iConsoleInputQueueUnlock()
|
---|
157 | {
|
---|
158 | APIRET rc;
|
---|
159 |
|
---|
160 | rc = DosReleaseMutexSem(ConsoleInput.hmtxInputQueue);
|
---|
161 | if (rc != NO_ERROR)
|
---|
162 | dprintf(("KERNEL32: Console:iConsoleInputQueueUnlock error %08xh\n",
|
---|
163 | rc));
|
---|
164 | }
|
---|
165 |
|
---|
166 |
|
---|
167 | /*****************************************************************************
|
---|
168 | * Name :
|
---|
169 | * Purpose :
|
---|
170 | * Parameters:
|
---|
171 | * Variables :
|
---|
172 | * Result :
|
---|
173 | * Remark :
|
---|
174 | * Status :
|
---|
175 | *
|
---|
176 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
177 | *****************************************************************************/
|
---|
178 |
|
---|
179 | APIRET iConsoleInit(BOOL fVioConsole) /* creation of the console subsystem */
|
---|
180 | {
|
---|
181 | APIRET rc; /* API return code */
|
---|
182 | ULONG ulPostCount; /* semaphore post counter */
|
---|
183 |
|
---|
184 |
|
---|
185 | flVioConsole = fVioConsole;
|
---|
186 |
|
---|
187 | if (ConsoleGlobals.hevConsole != NULLHANDLE) /* we're already initialized ?*/
|
---|
188 | return (NO_ERROR); /* then abort immediately */
|
---|
189 |
|
---|
190 | rc = DosSetSignalExceptionFocus(SIG_SETFOCUS, &ulPostCount);
|
---|
191 | if(rc) {
|
---|
192 | dprintf(("DosSetSignalExceptionFocus failed with %d", rc));
|
---|
193 | }
|
---|
194 |
|
---|
195 | if(flVioConsole == TRUE)
|
---|
196 | {
|
---|
197 | /***************************************************************************
|
---|
198 | * Create pseudo-devices and initialize ConsoleGlobals *
|
---|
199 | ***************************************************************************/
|
---|
200 |
|
---|
201 | rc = iConsoleDevicesRegister(); /* ensure devices are there */
|
---|
202 | if (rc != NO_ERROR) /* check for errors */
|
---|
203 | {
|
---|
204 | return (rc); /* raise error condition */
|
---|
205 | }
|
---|
206 | rc = DosCreateMutexSem(NULL,
|
---|
207 | &ConsoleInput.hmtxInputQueue,
|
---|
208 | 0L,
|
---|
209 | FALSE);
|
---|
210 | if (rc != NO_ERROR) /* other error ? */
|
---|
211 | {
|
---|
212 | return (rc); /* raise error condition */
|
---|
213 | }
|
---|
214 |
|
---|
215 | return NO_ERROR;
|
---|
216 | }
|
---|
217 | else {
|
---|
218 | /* create console synchronization semaphore */
|
---|
219 | rc = DosCreateEventSem (NULL,
|
---|
220 | &ConsoleGlobals.hevConsole,
|
---|
221 | 0L, /* semaphore is private */
|
---|
222 | FALSE); /* reset state */
|
---|
223 | if (rc != NO_ERROR) /* other error ? */
|
---|
224 | return (rc); /* raise error condition */
|
---|
225 |
|
---|
226 |
|
---|
227 | /* create console input queue semaphore */
|
---|
228 | rc = DosCreateEventSem (NULL,
|
---|
229 | &ConsoleInput.hevInputQueue,
|
---|
230 | 0L, /* semaphore is private */
|
---|
231 | FALSE); /* reset state */
|
---|
232 | if (rc != NO_ERROR) /* other error ? */
|
---|
233 | {
|
---|
234 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
---|
235 | return (rc); /* raise error condition */
|
---|
236 | }
|
---|
237 |
|
---|
238 |
|
---|
239 | rc = DosCreateMutexSem(NULL,
|
---|
240 | &ConsoleInput.hmtxInputQueue,
|
---|
241 | 0L,
|
---|
242 | FALSE);
|
---|
243 | if (rc != NO_ERROR) /* other error ? */
|
---|
244 | {
|
---|
245 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
---|
246 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
---|
247 | return (rc); /* raise error condition */
|
---|
248 | }
|
---|
249 |
|
---|
250 | /***************************************************************************
|
---|
251 | * Create pseudo-devices and initialize ConsoleGlobals *
|
---|
252 | ***************************************************************************/
|
---|
253 |
|
---|
254 | rc = iConsoleDevicesRegister(); /* ensure devices are there */
|
---|
255 | if (rc != NO_ERROR) /* check for errors */
|
---|
256 | {
|
---|
257 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
---|
258 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
---|
259 | return (rc); /* raise error condition */
|
---|
260 | }
|
---|
261 |
|
---|
262 |
|
---|
263 | /***************************************************************************
|
---|
264 | * Presentation Manager Initialization phase *
|
---|
265 | ***************************************************************************/
|
---|
266 |
|
---|
267 | /* OK, we're about to initialize the console subsystem for this process. */
|
---|
268 | /* start message thread for console object window */
|
---|
269 | ConsoleGlobals.tidConsole = _beginthread(iConsoleMsgThread,
|
---|
270 | NULL,
|
---|
271 | 12288,
|
---|
272 | NULL);
|
---|
273 | /* has the thread been created properly ? */
|
---|
274 | if (ConsoleGlobals.tidConsole == -1)
|
---|
275 | {
|
---|
276 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
---|
277 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close event semaphore */
|
---|
278 | ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
|
---|
279 | return (rc); /* raise error condition */
|
---|
280 | }
|
---|
281 | else
|
---|
282 | DosSetPriority(PRTYS_THREAD, /* set priority */
|
---|
283 | ConsoleGlobals.Options.ulConsoleThreadPriorityClass,
|
---|
284 | ConsoleGlobals.Options.ulConsoleThreadPriorityDelta,
|
---|
285 | ConsoleGlobals.tidConsole);
|
---|
286 |
|
---|
287 |
|
---|
288 | /* wait for the child thread to do it's initialization */
|
---|
289 | /* timeout isn't really useful */
|
---|
290 | rc = DosWaitEventSem(ConsoleGlobals.hevConsole,
|
---|
291 | SEM_INDEFINITE_WAIT);
|
---|
292 | if (rc != NO_ERROR) /* check for errors */
|
---|
293 | {
|
---|
294 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
---|
295 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close event semaphore */
|
---|
296 | ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
|
---|
297 | return (rc); /* raise error condition */
|
---|
298 | }
|
---|
299 |
|
---|
300 | DosResetEventSem(ConsoleGlobals.hevConsole, /* reset event semaphore */
|
---|
301 | &ulPostCount);
|
---|
302 |
|
---|
303 | rc = ConsoleGlobals.rcConsole; /* pass thru console thread's return code */
|
---|
304 |
|
---|
305 | return (rc); /* OK */
|
---|
306 | }
|
---|
307 | }
|
---|
308 |
|
---|
309 |
|
---|
310 | /*****************************************************************************
|
---|
311 | * Name : ConsoleDevicesRegister
|
---|
312 | * Purpose : creates and registers console devices if the standard handles
|
---|
313 | * are not redirected to a file
|
---|
314 | * Parameters:
|
---|
315 | * Variables :
|
---|
316 | * Result :
|
---|
317 | * Remark :
|
---|
318 | * Status :
|
---|
319 | *
|
---|
320 | * Author : Patrick Haller [Tue, 1998/03/17 01:55]
|
---|
321 | *****************************************************************************/
|
---|
322 |
|
---|
323 | APIRET iConsoleDevicesRegister(void)
|
---|
324 | {
|
---|
325 | DWORD dwType; /* device handle type */
|
---|
326 | HANDLE hStandardIn; /* stdin handle to CONIN$ */
|
---|
327 | HANDLE hStandardOut; /* stdout handle to CONOUT$ */
|
---|
328 | HANDLE hStandardError; /* stderr handle to CONOUT$ */
|
---|
329 |
|
---|
330 | HMDeviceConsoleInClass *pHMDeviceConsoleIn;
|
---|
331 | HMDeviceConsoleOutClass *pHMDeviceConsoleOut;
|
---|
332 | HMDeviceConsoleBufferClass *pHMDeviceConsoleBuffer;
|
---|
333 |
|
---|
334 | DWORD rc;
|
---|
335 |
|
---|
336 | static BOOL fDevicesInitialized; /* have we been initialized already ? */
|
---|
337 |
|
---|
338 | if (fDevicesInitialized == TRUE) /* OK, we're already done */
|
---|
339 | return (NO_ERROR);
|
---|
340 | else
|
---|
341 | fDevicesInitialized = TRUE;
|
---|
342 |
|
---|
343 | dprintf(("KERNEL32:ConsoleDevicesRegister\n"));
|
---|
344 |
|
---|
345 |
|
---|
346 | /*************************************
|
---|
347 | * Initialize Console Window Options *
|
---|
348 | *************************************/
|
---|
349 |
|
---|
350 | // load defaults
|
---|
351 | ConsolePropertyDefault(&ConsoleGlobals.Options);
|
---|
352 |
|
---|
353 | ConsoleGlobals.ulTimerFrequency = 10; /* cursor + blitter timer frequency */
|
---|
354 |
|
---|
355 | ConsoleGlobals.coordWindowSize.X = ConsoleGlobals.Options.coordDefaultSize.X;
|
---|
356 | ConsoleGlobals.coordWindowSize.Y = ConsoleGlobals.Options.coordDefaultSize.Y;
|
---|
357 | ConsoleGlobals.coordWindowPos.X = 0;
|
---|
358 | ConsoleGlobals.coordWindowPos.Y = 0;
|
---|
359 | if(flVioConsole == TRUE) {
|
---|
360 | VIOMODEINFO videoinfo;
|
---|
361 |
|
---|
362 | videoinfo.cb = sizeof(VIOMODEINFO);
|
---|
363 | rc = VioGetMode(&videoinfo, 0);
|
---|
364 | if(rc == 0) {
|
---|
365 | dprintf(("video mode (%d,%d)", videoinfo.col, videoinfo.row));
|
---|
366 | ConsoleGlobals.coordWindowSize.X = videoinfo.col;
|
---|
367 | ConsoleGlobals.coordWindowSize.Y = videoinfo.row;
|
---|
368 | }
|
---|
369 | }
|
---|
370 |
|
---|
371 |
|
---|
372 | ConsoleGlobals.flFrameFlags = FCF_SIZEBORDER | /* frame creation flags */
|
---|
373 | FCF_TITLEBAR |
|
---|
374 | FCF_SHELLPOSITION|
|
---|
375 | FCF_SYSMENU |
|
---|
376 | FCF_TASKLIST |
|
---|
377 | FCF_AUTOICON |
|
---|
378 | FCF_HORZSCROLL |
|
---|
379 | FCF_VERTSCROLL |
|
---|
380 | FCF_MINMAX;
|
---|
381 |
|
---|
382 | /* generate copy of title */
|
---|
383 | ConsoleGlobals.pszWindowTitle = strdup(GetCommandLineA());
|
---|
384 |
|
---|
385 | /* obtain module handle to our resources */
|
---|
386 | rc = DosQueryModuleHandleStrict("KERNEL32",
|
---|
387 | &ConsoleGlobals.hmodResource);
|
---|
388 | if (rc != NO_ERROR)
|
---|
389 | dprintf(("KERNEL32/CONSOLE: Can't get handle to KERNEL32 (%u).\n",
|
---|
390 | rc));
|
---|
391 |
|
---|
392 | /* standard console input modes */
|
---|
393 | ConsoleInput.dwConsoleMode = ENABLE_LINE_INPUT |
|
---|
394 | ENABLE_PROCESSED_INPUT;
|
---|
395 | /* @@@PH ENABLE_ECHO_INPUT || ENABLE_MOUSE_INPUT; */
|
---|
396 |
|
---|
397 | ConsoleGlobals.hConsoleBufferDefault = INVALID_HANDLE_VALUE;
|
---|
398 | ConsoleGlobals.hConsoleBuffer = INVALID_HANDLE_VALUE;
|
---|
399 |
|
---|
400 |
|
---|
401 | if (flVioConsole == FALSE)
|
---|
402 | {
|
---|
403 | // defaults are effective, try to read and apply stored properties
|
---|
404 | if (ConsolePropertyLoad(&ConsoleGlobals.Options) == NO_ERROR)
|
---|
405 | ConsolePropertyApply(&ConsoleGlobals.Options);
|
---|
406 | }
|
---|
407 |
|
---|
408 |
|
---|
409 | /***************************************************************************
|
---|
410 | * Standard handles Initialization phase *
|
---|
411 | ***************************************************************************/
|
---|
412 |
|
---|
413 | /* create devices and register devices with handlemanager */
|
---|
414 | pHMDeviceConsoleIn = new HMDeviceConsoleInClass("CONIN$",
|
---|
415 | &ConsoleInput,
|
---|
416 | &ConsoleGlobals);
|
---|
417 |
|
---|
418 | rc = HMDeviceRegister ("CONIN$",
|
---|
419 | pHMDeviceConsoleIn);
|
---|
420 | if (rc != NO_ERROR) /* check for errors */
|
---|
421 | dprintf(("KERNEL32:ConsoleDevicesRegister: registering CONIN$ failed with %u.\n",
|
---|
422 | rc));
|
---|
423 |
|
---|
424 |
|
---|
425 | pHMDeviceConsoleOut = new HMDeviceConsoleOutClass("CONOUT$",
|
---|
426 | &ConsoleInput,
|
---|
427 | &ConsoleGlobals);
|
---|
428 | rc = HMDeviceRegister ("CONOUT$",
|
---|
429 | pHMDeviceConsoleOut);
|
---|
430 | if (rc != NO_ERROR) /* check for errors */
|
---|
431 | dprintf(("KERNEL32:ConsoleDevicesRegister: registering CONOUT$ failed with %u.\n",
|
---|
432 | rc));
|
---|
433 |
|
---|
434 | // add standard symbolic links
|
---|
435 | HandleNamesAddSymbolicLink("CON", "CONOUT$");
|
---|
436 | HandleNamesAddSymbolicLink("CON:", "CONOUT$");
|
---|
437 | HandleNamesAddSymbolicLink("\\\\.\\CON", "CONOUT$");
|
---|
438 |
|
---|
439 | if(flVioConsole == TRUE)
|
---|
440 | {
|
---|
441 | pHMDeviceConsoleBuffer = (HMDeviceConsoleBufferClass *)new HMDeviceConsoleVioBufferClass("CONBUFFER$",
|
---|
442 | &ConsoleInput,
|
---|
443 | &ConsoleGlobals);
|
---|
444 | }
|
---|
445 | else {
|
---|
446 | pHMDeviceConsoleBuffer = new HMDeviceConsoleBufferClass("CONBUFFER$",
|
---|
447 | &ConsoleInput,
|
---|
448 | &ConsoleGlobals);
|
---|
449 | }
|
---|
450 | rc = HMDeviceRegister ("CONBUFFER$",
|
---|
451 | pHMDeviceConsoleBuffer);
|
---|
452 | if (rc != NO_ERROR) /* check for errors */
|
---|
453 | dprintf(("KERNEL32:ConsoleDevicesRegister: registering CONBUFFER$ failed with %u.\n",
|
---|
454 | rc));
|
---|
455 |
|
---|
456 |
|
---|
457 | if(flVioConsole == FALSE)
|
---|
458 | {
|
---|
459 | /***********************************************************************
|
---|
460 | * initialize stdin handle *
|
---|
461 | ***********************************************************************/
|
---|
462 | hStandardIn = GetStdHandle(STD_INPUT_HANDLE);
|
---|
463 | dwType = GetFileType(hStandardIn);
|
---|
464 | if (dwType == FILE_TYPE_CHAR) /* is handle redirected ? */
|
---|
465 | hStandardIn = HMCreateFile("CONIN$",
|
---|
466 | GENERIC_READ | GENERIC_WRITE,
|
---|
467 | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
---|
468 | NULL,
|
---|
469 | 0,
|
---|
470 | CONSOLE_TEXTMODE_BUFFER,
|
---|
471 | 0);
|
---|
472 |
|
---|
473 | HMSetStdHandle(STD_INPUT_HANDLE,
|
---|
474 | hStandardIn);
|
---|
475 |
|
---|
476 | /***********************************************************************
|
---|
477 | * initialize stdout handle *
|
---|
478 | ***********************************************************************/
|
---|
479 | hStandardOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
---|
480 | dwType = GetFileType(hStandardOut);
|
---|
481 | if (dwType == FILE_TYPE_CHAR) /* is handle redirected ? */
|
---|
482 | hStandardOut = HMCreateFile("CONOUT$",
|
---|
483 | GENERIC_READ | GENERIC_WRITE,
|
---|
484 | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
---|
485 | NULL,
|
---|
486 | 0,
|
---|
487 | CONSOLE_TEXTMODE_BUFFER,
|
---|
488 | 0);
|
---|
489 |
|
---|
490 | HMSetStdHandle(STD_OUTPUT_HANDLE,
|
---|
491 | hStandardOut);
|
---|
492 |
|
---|
493 | /***********************************************************************
|
---|
494 | * initialize stderr handle *
|
---|
495 | ***********************************************************************/
|
---|
496 | hStandardError = GetStdHandle(STD_ERROR_HANDLE);
|
---|
497 | dwType = GetFileType(hStandardError);
|
---|
498 | if (dwType == FILE_TYPE_CHAR) /* is handle redirected ? */
|
---|
499 | hStandardError = HMCreateFile("CONOUT$",
|
---|
500 | GENERIC_READ | GENERIC_WRITE,
|
---|
501 | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
---|
502 | NULL,
|
---|
503 | 0,
|
---|
504 | CONSOLE_TEXTMODE_BUFFER,
|
---|
505 | 0);
|
---|
506 |
|
---|
507 | HMSetStdHandle(STD_ERROR_HANDLE,
|
---|
508 | hStandardError);
|
---|
509 | }
|
---|
510 |
|
---|
511 | return (NO_ERROR); /* OK */
|
---|
512 | }
|
---|
513 |
|
---|
514 |
|
---|
515 | /*****************************************************************************
|
---|
516 | * Name : static APIRET ConsoleTerminate
|
---|
517 | * Purpose : Shuts the OS/2 console subsystem down
|
---|
518 | * Parameters: VOID
|
---|
519 | * Variables :
|
---|
520 | * Result : OS/2 API return code
|
---|
521 | * Remark : That consolebuffer handle that became allocated as default
|
---|
522 | * screen buffer is lost here. This would be a serious memory
|
---|
523 | * leak if an application keeps opening and closing the console
|
---|
524 | * frequently.
|
---|
525 | * Status :
|
---|
526 | *
|
---|
527 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
528 | *****************************************************************************/
|
---|
529 |
|
---|
530 | ULONG iConsoleTerminate(VOID)
|
---|
531 | {
|
---|
532 | APIRET rc = NO_ERROR;
|
---|
533 |
|
---|
534 | if(flVioConsole == FALSE)
|
---|
535 | {
|
---|
536 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
---|
537 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
---|
538 |
|
---|
539 |
|
---|
540 | WinPostMsg (ConsoleGlobals.hwndFrame, /* force thread to terminate */
|
---|
541 | WM_CLOSE,
|
---|
542 | (MPARAM)NULL,
|
---|
543 | (MPARAM)NULL);
|
---|
544 |
|
---|
545 | rc = DosWaitThread(&ConsoleGlobals.tidConsole,/* wait until thd terminates */
|
---|
546 | DCWW_WAIT);
|
---|
547 |
|
---|
548 | }
|
---|
549 | DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */
|
---|
550 |
|
---|
551 | /* close the consolebuffer handle */
|
---|
552 | HMCloseHandle(ConsoleGlobals.hConsoleBufferDefault);
|
---|
553 | free(ConsoleGlobals.pszWindowTitle); /* free previously allocated memory */
|
---|
554 |
|
---|
555 | return (rc); /* OK */
|
---|
556 | }
|
---|
557 |
|
---|
558 |
|
---|
559 | /*****************************************************************************
|
---|
560 | * Name : static void ConsoleWaitClose
|
---|
561 | * Purpose : Wait for the user to close console window
|
---|
562 | * Parameters: VOID
|
---|
563 | * Variables :
|
---|
564 | * Result :
|
---|
565 | * Remark :
|
---|
566 | * Status :
|
---|
567 | *
|
---|
568 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
569 | *****************************************************************************/
|
---|
570 |
|
---|
571 | void iConsoleWaitClose(void)
|
---|
572 | {
|
---|
573 | CHAR szBuffer[128]; /* buffer for the title */
|
---|
574 | BOOL fResult; /* result from subsequent calls to Win32 APIs */
|
---|
575 |
|
---|
576 | /* check if there is a console window at all */
|
---|
577 | if (iConsoleIsActive() == FALSE)
|
---|
578 | return; /* nope */
|
---|
579 |
|
---|
580 | if(flVioConsole == TRUE) //no need to wait for VIO session
|
---|
581 | return;
|
---|
582 |
|
---|
583 | strcpy (szBuffer, /* indicate console process has terminated */
|
---|
584 | "Completed: ");
|
---|
585 |
|
---|
586 | fResult = GetConsoleTitleA(szBuffer + 11,/* 11 is length of Completed:_ */
|
---|
587 | sizeof(szBuffer) - 11);
|
---|
588 |
|
---|
589 |
|
---|
590 | /* Set new title: Win32 Console - Terminated */
|
---|
591 | fResult = SetConsoleTitleA(szBuffer);
|
---|
592 |
|
---|
593 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
---|
594 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
---|
595 | DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */
|
---|
596 |
|
---|
597 |
|
---|
598 | /* terminate console immediately ? */
|
---|
599 | if (ConsoleGlobals.Options.fTerminateAutomatically == FALSE) {
|
---|
600 | if(getenv("ODIN_AUTOEXITCONSOLE") == NULL) {
|
---|
601 | DosWaitThread(&ConsoleGlobals.tidConsole, /* wait until thd terminates */
|
---|
602 | DCWW_WAIT);
|
---|
603 | }
|
---|
604 | }
|
---|
605 | }
|
---|
606 |
|
---|
607 |
|
---|
608 | /*****************************************************************************
|
---|
609 | * Name : static BOOL ConsoleIsActive
|
---|
610 | * Purpose : Check if Console window is opened
|
---|
611 | * Parameters: VOID
|
---|
612 | * Variables :
|
---|
613 | * Result :
|
---|
614 | * Remark :
|
---|
615 | * Status :
|
---|
616 | *
|
---|
617 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
618 | *****************************************************************************/
|
---|
619 |
|
---|
620 | BOOL iConsoleIsActive(void)
|
---|
621 | {
|
---|
622 | if(flVioConsole == TRUE) //actually, this isn't needed in VIO mode
|
---|
623 | return TRUE;
|
---|
624 |
|
---|
625 | return (NULLHANDLE != ConsoleGlobals.hevConsole);
|
---|
626 | }
|
---|
627 |
|
---|
628 |
|
---|
629 | /*****************************************************************************
|
---|
630 | * Name : static VOID ConsoleMsgThread
|
---|
631 | * Purpose : Message handler thread for the console object window
|
---|
632 | * Parameters: PVOID pDummy
|
---|
633 | * Variables :
|
---|
634 | * Result : is placed in Globals.rcConsole
|
---|
635 | * Remark : the main thread has to wait for this thread
|
---|
636 | * Status :
|
---|
637 | *
|
---|
638 | * Author : Patrick Haller [Tue, 1998/02/10 02:49]
|
---|
639 | *****************************************************************************/
|
---|
640 |
|
---|
641 | VOID iConsoleMsgThread(PVOID pParameters)
|
---|
642 | {
|
---|
643 | APIRET rc; /* API return code */
|
---|
644 |
|
---|
645 |
|
---|
646 | ConsoleGlobals.rcConsole = NO_ERROR; /* initialization */
|
---|
647 |
|
---|
648 | ConsoleGlobals.hab = WinInitialize(0); /* enable thread for PM */
|
---|
649 | if (ConsoleGlobals.hab == NULLHANDLE) /* if anchor block allocation failed */
|
---|
650 | ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
|
---|
651 | else
|
---|
652 | {
|
---|
653 | /* create message queue */
|
---|
654 | ConsoleGlobals.hmq = WinCreateMsgQueue(ConsoleGlobals.hab,
|
---|
655 | 0);
|
---|
656 | if (ConsoleGlobals.hmq == NULLHANDLE) /* if msg queue allocation failed */
|
---|
657 | {
|
---|
658 | WinTerminate(ConsoleGlobals.hab); /* stop thread from accessing PM */
|
---|
659 | ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
|
---|
660 | }
|
---|
661 | else
|
---|
662 | {
|
---|
663 | if (WinRegisterClass(ConsoleGlobals.hab, /* register our class with PM */
|
---|
664 | SZ_CONSOLE_CLASS,
|
---|
665 | iConsoleWindowProc,
|
---|
666 | CS_SIZEREDRAW,
|
---|
667 | 0)
|
---|
668 | == FALSE)
|
---|
669 | {
|
---|
670 | WinDestroyMsgQueue(ConsoleGlobals.hmq); /* destroy message queue */
|
---|
671 | WinTerminate(ConsoleGlobals.hab); /* stop thread from accessing PM */
|
---|
672 | ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
|
---|
673 | }
|
---|
674 | else
|
---|
675 | {
|
---|
676 | ConsoleGlobals.hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
|
---|
677 | WS_VISIBLE,
|
---|
678 | &ConsoleGlobals.flFrameFlags,
|
---|
679 | SZ_CONSOLE_CLASS,
|
---|
680 | ConsoleGlobals.pszWindowTitle,
|
---|
681 | 0,
|
---|
682 | ConsoleGlobals.hmodResource,
|
---|
683 | ID_CONSOLE_MAIN,
|
---|
684 | &ConsoleGlobals.hwndClient);
|
---|
685 | if (ConsoleGlobals.hwndFrame == NULLHANDLE) /* check window creation */
|
---|
686 | {
|
---|
687 | WinDestroyMsgQueue(ConsoleGlobals.hmq); /* destroy message queue */
|
---|
688 | WinTerminate(ConsoleGlobals.hab); /* stop thread from accessing PM */
|
---|
689 | ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
|
---|
690 | } /* WinCreateStdWindow */
|
---|
691 | } /* WinRegisterClass */
|
---|
692 | } /* WinCreateMsgQueue */
|
---|
693 | } /* WinInitialize */
|
---|
694 |
|
---|
695 |
|
---|
696 | DosPostEventSem(ConsoleGlobals.hevConsole); /* signal the main thread */
|
---|
697 |
|
---|
698 |
|
---|
699 | if (ConsoleGlobals.rcConsole != NO_ERROR) /* if we ran into a problem */
|
---|
700 | {
|
---|
701 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
---|
702 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* subsystem not running .. */
|
---|
703 | ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
|
---|
704 | return; /* abort the message queue thread immediately */
|
---|
705 | }
|
---|
706 |
|
---|
707 |
|
---|
708 | while( WinGetMsg(ConsoleGlobals.hab, /* message loop */
|
---|
709 | &ConsoleGlobals.qmsg,
|
---|
710 | NULLHANDLE,
|
---|
711 | 0,
|
---|
712 | 0) )
|
---|
713 | WinDispatchMsg(ConsoleGlobals.hab, /* dispatch the message */
|
---|
714 | &ConsoleGlobals.qmsg);
|
---|
715 |
|
---|
716 | /* do the cleanup, destroy window, queue */
|
---|
717 | /* and stop thread from using PM */
|
---|
718 | WinDestroyWindow (ConsoleGlobals.hwndFrame);
|
---|
719 | WinDestroyMsgQueue(ConsoleGlobals.hmq);
|
---|
720 | WinTerminate (ConsoleGlobals.hab);
|
---|
721 |
|
---|
722 | /* destruction of semaphore indicates console is shutdown */
|
---|
723 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
---|
724 | DosCloseEventSem(ConsoleGlobals.hevConsole);
|
---|
725 | DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */
|
---|
726 |
|
---|
727 | ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
|
---|
728 | ConsoleInput.hevInputQueue = NULLHANDLE;
|
---|
729 | ConsoleInput.hmtxInputQueue = NULLHANDLE;
|
---|
730 |
|
---|
731 | /* @@@PH we've got to exit the process here ! */
|
---|
732 | ExitProcess(1);
|
---|
733 | }
|
---|
734 |
|
---|
735 |
|
---|
736 | /*****************************************************************************
|
---|
737 | * Name : static MRESULT EXPENTRY ConsoleWindowProc
|
---|
738 | * Purpose : Window Procedure for OUR console window
|
---|
739 | * Parameters: HWND hwnd - window handle
|
---|
740 | * ULONG msg - message identifier
|
---|
741 | * MPARAM mp1 - message parameter 1
|
---|
742 | * MPARAM mp2 - message parameter 2
|
---|
743 | * Variables :
|
---|
744 | * Result : MRESULT for PM
|
---|
745 | * Remark :
|
---|
746 | * Status :
|
---|
747 | *
|
---|
748 | * Author : Patrick Haller [Tue, 1998/02/10 03:24]
|
---|
749 | *****************************************************************************/
|
---|
750 |
|
---|
751 | MRESULT EXPENTRY iConsoleWindowProc(HWND hwnd,
|
---|
752 | ULONG msg,
|
---|
753 | MPARAM mp1,
|
---|
754 | MPARAM mp2)
|
---|
755 | {
|
---|
756 | static RECTL rcl; /* window rectangle */
|
---|
757 | static HPS hps;
|
---|
758 |
|
---|
759 | switch(msg)
|
---|
760 | {
|
---|
761 | /*************************************************************************
|
---|
762 | * WM_CREATE window creation *
|
---|
763 | *************************************************************************/
|
---|
764 |
|
---|
765 | case WM_CREATE:
|
---|
766 | WinPostMsg(hwnd, /* deferred initialization */
|
---|
767 | UM_CONSOLE_CREATE,
|
---|
768 | (MPARAM)NULL,
|
---|
769 | (MPARAM)NULL);
|
---|
770 | break;
|
---|
771 |
|
---|
772 |
|
---|
773 | case UM_CONSOLE_CREATE:
|
---|
774 | {
|
---|
775 | APIRET rc; /* API return code */
|
---|
776 | HWND hwndFrame; /* frame window handle */
|
---|
777 |
|
---|
778 | /* subclass the frame window */
|
---|
779 | hwndFrame = ConsoleGlobals.hwndFrame;
|
---|
780 | ConsoleGlobals.pfnwpFrameOriginal = WinSubclassWindow(hwndFrame,
|
---|
781 | iConsoleFrameWindowProc);
|
---|
782 |
|
---|
783 | ConsoleGlobals.hwndMenuConsole
|
---|
784 | = WinLoadMenu (hwnd, /* load context menue */
|
---|
785 | ConsoleGlobals.hmodResource,
|
---|
786 | ID_CONSOLE_MAIN);
|
---|
787 |
|
---|
788 | /* set an icon for the dialog */
|
---|
789 | ConsoleGlobals.hPtrConsole = WinLoadPointer(HWND_DESKTOP,
|
---|
790 | ConsoleGlobals.hmodResource,
|
---|
791 | ID_CONSOLE_MAIN );
|
---|
792 | WinSendMsg(ConsoleGlobals.hwndFrame,
|
---|
793 | WM_SETICON,
|
---|
794 | (MPARAM)ConsoleGlobals.hPtrConsole,
|
---|
795 | 0L );
|
---|
796 |
|
---|
797 | /* determine handles of the horizontal / vertical scroll bars */
|
---|
798 | ConsoleGlobals.hwndVertScroll = WinWindowFromID(ConsoleGlobals.hwndFrame,
|
---|
799 | FID_VERTSCROLL);
|
---|
800 |
|
---|
801 | ConsoleGlobals.hwndHorzScroll = WinWindowFromID(ConsoleGlobals.hwndFrame,
|
---|
802 | FID_HORZSCROLL);
|
---|
803 |
|
---|
804 | /* the initial state of the controls is DETACHED */
|
---|
805 | WinSetParent(ConsoleGlobals.hwndHorzScroll, /* detach control */
|
---|
806 | HWND_OBJECT,
|
---|
807 | FALSE);
|
---|
808 |
|
---|
809 | WinSetParent(ConsoleGlobals.hwndVertScroll, /* detach control */
|
---|
810 | HWND_OBJECT,
|
---|
811 | FALSE);
|
---|
812 |
|
---|
813 |
|
---|
814 | /* create AVIO presentation space */
|
---|
815 | rc = VioCreatePS(&ConsoleGlobals.hvpsConsole,
|
---|
816 | ConsoleGlobals.coordWindowSize.Y,
|
---|
817 | ConsoleGlobals.coordWindowSize.X,
|
---|
818 | 0, /* format, must be 0 */
|
---|
819 | FORMAT_CGA,
|
---|
820 | 0); /* template hvps, must be 0 */
|
---|
821 | if (rc != NO_ERROR) /* check errors */
|
---|
822 | dprintf(("KERNEL32/CONSOLE:VioCreatePS=%u\n",
|
---|
823 | rc));
|
---|
824 |
|
---|
825 | /* PH 1998/02/12 this seems to be an OS/2 PM bug:
|
---|
826 | when doing a WinOpenWindowDC here, PM hangs. Seems it never gets back into
|
---|
827 | the message loop. To investigate and report to IBM
|
---|
828 | */
|
---|
829 |
|
---|
830 | /* get a device context for the client window */
|
---|
831 | ConsoleGlobals.hdcConsole = WinOpenWindowDC(hwnd);
|
---|
832 | /* associate AVIO PS with the HDC */
|
---|
833 | rc = VioAssociate(ConsoleGlobals.hdcConsole,
|
---|
834 | ConsoleGlobals.hvpsConsole);
|
---|
835 | if (rc != NO_ERROR) /* check errors */
|
---|
836 | dprintf(("KERNEL32/CONSOLE:VioAssociate=%u\n",
|
---|
837 | rc));
|
---|
838 |
|
---|
839 | iConsoleFontQuery(); /* query current cell sizes */
|
---|
840 |
|
---|
841 | /* adjust window size and position */
|
---|
842 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
---|
843 | DRQ_INTERNAL_CONSOLEADJUSTWINDOW,
|
---|
844 | 0,
|
---|
845 | 0,
|
---|
846 | 0,
|
---|
847 | 0);
|
---|
848 |
|
---|
849 | /* @@@PH if console is maximized - now switched on per default ! */
|
---|
850 | WinSetWindowPos (ConsoleGlobals.hwndFrame,
|
---|
851 | HWND_DESKTOP,
|
---|
852 | 0,
|
---|
853 | 0,
|
---|
854 | ConsoleGlobals.Options.coordDefaultSize.X *
|
---|
855 | ConsoleGlobals.sCellCX +
|
---|
856 | 2 * WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER),
|
---|
857 | ConsoleGlobals.Options.coordDefaultSize.Y *
|
---|
858 | ConsoleGlobals.sCellCY +
|
---|
859 | WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR) +
|
---|
860 | 2 * WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER),
|
---|
861 | SWP_SIZE);
|
---|
862 |
|
---|
863 | /* do we have to set the window position also ? */
|
---|
864 | if (ConsoleGlobals.Options.fSetWindowPosition == TRUE)
|
---|
865 | WinSetWindowPos (ConsoleGlobals.hwndFrame,
|
---|
866 | HWND_DESKTOP,
|
---|
867 | ConsoleGlobals.Options.coordDefaultPosition.X,
|
---|
868 | ConsoleGlobals.Options.coordDefaultPosition.Y,
|
---|
869 | 0,
|
---|
870 | 0,
|
---|
871 | SWP_MOVE);
|
---|
872 |
|
---|
873 | /* start timer service for blitting and cursor blinking */
|
---|
874 | ConsoleGlobals.idTimer = WinStartTimer (ConsoleGlobals.hab,
|
---|
875 | hwnd,
|
---|
876 | CONSOLE_TIMER_ID, /* timer id */
|
---|
877 | ConsoleGlobals.ulTimerFrequency);
|
---|
878 |
|
---|
879 | WinPostMsg (hwnd, /* send myself a start message so we get the first */
|
---|
880 | WM_TIMER, /* frame immediately */
|
---|
881 | (MPARAM)NULL,
|
---|
882 | (MPARAM)NULL);
|
---|
883 | }
|
---|
884 | break;
|
---|
885 |
|
---|
886 |
|
---|
887 | /*************************************************************************
|
---|
888 | * WM_DESTROY window destruction *
|
---|
889 | *************************************************************************/
|
---|
890 |
|
---|
891 | case WM_DESTROY:
|
---|
892 | WinStopTimer (ConsoleGlobals.hab, /* anchor block */
|
---|
893 | hwnd,
|
---|
894 | ConsoleGlobals.idTimer); /* timer ID */
|
---|
895 |
|
---|
896 | VioAssociate(NULL,
|
---|
897 | ConsoleGlobals.hvpsConsole); /* disassociates the AVIO PS */
|
---|
898 | VioDestroyPS(ConsoleGlobals.hvpsConsole); /* destroys the AVIO PS */
|
---|
899 |
|
---|
900 | WinDestroyWindow(ConsoleGlobals.hwndMenuConsole);
|
---|
901 | WinDestroyPointer(ConsoleGlobals.hPtrConsole);
|
---|
902 | break;
|
---|
903 |
|
---|
904 |
|
---|
905 | /*************************************************************************
|
---|
906 | * WM_TIMER display cursor and update AVIO PS if required *
|
---|
907 | *************************************************************************/
|
---|
908 |
|
---|
909 | case WM_TIMER:
|
---|
910 | /* check if console has to be updated */
|
---|
911 | if (ConsoleGlobals.fUpdateRequired == TRUE)
|
---|
912 | {
|
---|
913 | ConsoleGlobals.fUpdateRequired = FALSE; /* as soon as possible ! */
|
---|
914 |
|
---|
915 | /* as device to map itself to the VIO buffer */
|
---|
916 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
---|
917 | DRQ_INTERNAL_CONSOLEBUFFERMAP,
|
---|
918 | 0,
|
---|
919 | 0,
|
---|
920 | 0,
|
---|
921 | 0);
|
---|
922 |
|
---|
923 | { /* DEBUG */
|
---|
924 | APIRET rc;
|
---|
925 | /* and now bring it to the screen */
|
---|
926 | rc = VioShowPS(ConsoleGlobals.coordWindowSize.Y,
|
---|
927 | ConsoleGlobals.coordWindowSize.X,
|
---|
928 | 0,
|
---|
929 | ConsoleGlobals.hvpsConsole);
|
---|
930 |
|
---|
931 | dprintf(("KERNEL32::Console::1 VioShowPS(%u,%u,%u)=%u\n",
|
---|
932 | ConsoleGlobals.coordWindowSize.Y,
|
---|
933 | ConsoleGlobals.coordWindowSize.X,
|
---|
934 | ConsoleGlobals.hvpsConsole,
|
---|
935 | rc));
|
---|
936 | }
|
---|
937 |
|
---|
938 | /* cursor is overwritten here ! */
|
---|
939 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
---|
940 | DRQ_INTERNAL_CONSOLECURSORSHOW,
|
---|
941 | CONSOLECURSOR_OVERWRITTEN,
|
---|
942 | 0,
|
---|
943 | 0,
|
---|
944 | 0);
|
---|
945 | }
|
---|
946 | else
|
---|
947 | {
|
---|
948 | ConsoleGlobals.ulTimerCursor++; /* increase counter */
|
---|
949 | if (ConsoleGlobals.ulTimerCursor > ConsoleGlobals.Options.ucCursorDivisor)
|
---|
950 | {
|
---|
951 | ConsoleGlobals.ulTimerCursor = 0; /* reset counter */
|
---|
952 | /* let our cursor blink */
|
---|
953 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
---|
954 | DRQ_INTERNAL_CONSOLECURSORSHOW,
|
---|
955 | CONSOLECURSOR_BLINK,
|
---|
956 | 0,
|
---|
957 | 0,
|
---|
958 | 0);
|
---|
959 | }
|
---|
960 | }
|
---|
961 | break;
|
---|
962 |
|
---|
963 |
|
---|
964 | /*************************************************************************
|
---|
965 | * WM_MINMAXFRAME handle window repaint in case of iconized window *
|
---|
966 | *************************************************************************/
|
---|
967 |
|
---|
968 | case WM_MINMAXFRAME :
|
---|
969 | {
|
---|
970 | BOOL fShow = ! (((PSWP) mp1)->fl & SWP_MINIMIZE);
|
---|
971 | HENUM henum;
|
---|
972 | HWND hwndChild;
|
---|
973 |
|
---|
974 | WinEnableWindowUpdate ( hwnd, FALSE );
|
---|
975 |
|
---|
976 | for (henum=WinBeginEnumWindows(hwnd);
|
---|
977 | (hwndChild = WinGetNextWindow (henum)) != 0; )
|
---|
978 | WinShowWindow ( hwndChild, fShow );
|
---|
979 |
|
---|
980 | WinEndEnumWindows ( henum );
|
---|
981 | WinEnableWindowUpdate ( hwnd, TRUE );
|
---|
982 | }
|
---|
983 | break;
|
---|
984 |
|
---|
985 |
|
---|
986 | /*************************************************************************
|
---|
987 | * WM_PAINT repaint the window *
|
---|
988 | *************************************************************************/
|
---|
989 | case WM_PAINT:
|
---|
990 | hps = WinBeginPaint(hwnd,
|
---|
991 | (HPS)NULL,
|
---|
992 | &rcl);
|
---|
993 | /* blit the whole AVIO presentation space */
|
---|
994 | { /* DEBUG */
|
---|
995 | APIRET rc;
|
---|
996 | /* and now bring it to the screen */
|
---|
997 | rc = VioShowPS(ConsoleGlobals.coordWindowSize.Y,
|
---|
998 | ConsoleGlobals.coordWindowSize.X,
|
---|
999 | 0,
|
---|
1000 | ConsoleGlobals.hvpsConsole);
|
---|
1001 |
|
---|
1002 | dprintf(("KERNEL32::Console::2 VioShowPS(%u,%u,%u)=%u\n",
|
---|
1003 | ConsoleGlobals.coordWindowSize.Y,
|
---|
1004 | ConsoleGlobals.coordWindowSize.X,
|
---|
1005 | ConsoleGlobals.hvpsConsole,
|
---|
1006 | rc));
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | WinEndPaint(hps);
|
---|
1010 | break;
|
---|
1011 |
|
---|
1012 |
|
---|
1013 | /*************************************************************************
|
---|
1014 | * WM_SIZE resize the window *
|
---|
1015 | *************************************************************************/
|
---|
1016 | case WM_SIZE:
|
---|
1017 | {
|
---|
1018 | /* calculate scrollbars if neccessary */
|
---|
1019 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
---|
1020 | DRQ_INTERNAL_CONSOLEADJUSTWINDOW,
|
---|
1021 | 0,
|
---|
1022 | 0,
|
---|
1023 | 0,
|
---|
1024 | 0);
|
---|
1025 |
|
---|
1026 | return WinDefAVioWindowProc(hwnd,
|
---|
1027 | (USHORT)msg,
|
---|
1028 | (ULONG)mp1,
|
---|
1029 | (ULONG)mp2);
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 |
|
---|
1033 | /*************************************************************************
|
---|
1034 | * context menue *
|
---|
1035 | *************************************************************************/
|
---|
1036 | case WM_CONTEXTMENU:
|
---|
1037 | {
|
---|
1038 | WinPopupMenu (hwnd,
|
---|
1039 | hwnd,
|
---|
1040 | ConsoleGlobals.hwndMenuConsole,
|
---|
1041 | SHORT1FROMMP(mp1),
|
---|
1042 | SHORT2FROMMP(mp1),
|
---|
1043 | CM_CONSOLE_PROPERTIES, /* item id */
|
---|
1044 | PU_HCONSTRAIN |
|
---|
1045 | PU_VCONSTRAIN |
|
---|
1046 | PU_KEYBOARD |
|
---|
1047 | PU_MOUSEBUTTON1 |
|
---|
1048 | PU_MOUSEBUTTON2 |
|
---|
1049 | PU_POSITIONONITEM);
|
---|
1050 | }
|
---|
1051 | return (MPARAM)FALSE;
|
---|
1052 |
|
---|
1053 |
|
---|
1054 | /*************************************************************************
|
---|
1055 | * WM_COMMAND command processing *
|
---|
1056 | *************************************************************************/
|
---|
1057 | case WM_COMMAND:
|
---|
1058 | {
|
---|
1059 | switch(SHORT1FROMMP(mp1)) /* select appropriate identifier */
|
---|
1060 | {
|
---|
1061 | /* close console window, however we can't call ConsoleTerminate here!*/
|
---|
1062 | case CM_CONSOLE_EXIT:
|
---|
1063 | WinPostMsg (ConsoleGlobals.hwndFrame,
|
---|
1064 | WM_CLOSE,
|
---|
1065 | (MPARAM)NULL,
|
---|
1066 | (MPARAM)NULL);
|
---|
1067 |
|
---|
1068 | return (MPARAM)FALSE;
|
---|
1069 |
|
---|
1070 |
|
---|
1071 | case CM_CONSOLE_REPAINT:
|
---|
1072 | WinInvalidateRect(ConsoleGlobals.hwndClient,/* redraw frame window */
|
---|
1073 | NULL,
|
---|
1074 | TRUE);
|
---|
1075 | return (MPARAM)FALSE;
|
---|
1076 |
|
---|
1077 | /* open the properties dialog */
|
---|
1078 | case CM_CONSOLE_PROPERTIES:
|
---|
1079 | {
|
---|
1080 | ULONG ulResult; /* response from user */
|
---|
1081 |
|
---|
1082 | ConsoleGlobals.Options.hmodResources = /* save module handle */
|
---|
1083 | ConsoleGlobals.hmodResource;
|
---|
1084 |
|
---|
1085 | ulResult = WinDlgBox(HWND_DESKTOP,
|
---|
1086 | ConsoleGlobals.hwndClient,
|
---|
1087 | &ConsolePropertyDlgProc,
|
---|
1088 | ConsoleGlobals.hmodResource,
|
---|
1089 | DLG_CONSOLE_PROPERTIES,
|
---|
1090 | (PVOID)&ConsoleGlobals.Options);
|
---|
1091 | switch (ulResult)
|
---|
1092 | {
|
---|
1093 | case ID_BTN_SAVE:
|
---|
1094 | ConsolePropertySave(&ConsoleGlobals.Options);
|
---|
1095 | ConsolePropertyApply(&ConsoleGlobals.Options);
|
---|
1096 | break;
|
---|
1097 |
|
---|
1098 | case ID_BTN_APPLY:
|
---|
1099 | ConsolePropertyApply(&ConsoleGlobals.Options);
|
---|
1100 | break;
|
---|
1101 |
|
---|
1102 | default: break;
|
---|
1103 | }
|
---|
1104 |
|
---|
1105 | return (MPARAM) FALSE;
|
---|
1106 | }
|
---|
1107 | }
|
---|
1108 | }
|
---|
1109 | break;
|
---|
1110 |
|
---|
1111 |
|
---|
1112 | /*************************************************************************
|
---|
1113 | * WM_CHAR keyboard char processing *
|
---|
1114 | *************************************************************************/
|
---|
1115 |
|
---|
1116 | case WM_CHAR:
|
---|
1117 | iConsoleInputEventPushKey(mp1, /* push event into queue */
|
---|
1118 | mp2);
|
---|
1119 | break; /* enable further processing ! */
|
---|
1120 |
|
---|
1121 |
|
---|
1122 | /*************************************************************************
|
---|
1123 | * WM_SETFOCUS focus changing processing *
|
---|
1124 | *************************************************************************/
|
---|
1125 |
|
---|
1126 | case WM_SETFOCUS:
|
---|
1127 | iConsoleInputEventPushFocus((BOOL)mp2); /* push event into queue */
|
---|
1128 | break; /* enable further processing ! */
|
---|
1129 |
|
---|
1130 |
|
---|
1131 | /*************************************************************************
|
---|
1132 | * WM_MOUSEMOVE mouse event processing *
|
---|
1133 | *************************************************************************/
|
---|
1134 |
|
---|
1135 | case WM_MOUSEMOVE:
|
---|
1136 | case WM_BUTTON1UP:
|
---|
1137 | case WM_BUTTON1DOWN:
|
---|
1138 | case WM_BUTTON2UP:
|
---|
1139 | case WM_BUTTON2DOWN:
|
---|
1140 | case WM_BUTTON3UP:
|
---|
1141 | case WM_BUTTON3DOWN:
|
---|
1142 | case WM_BUTTON1DBLCLK:
|
---|
1143 | case WM_BUTTON2DBLCLK:
|
---|
1144 | case WM_BUTTON3DBLCLK:
|
---|
1145 | iConsoleInputEventPushMouse(msg,
|
---|
1146 | mp1, /* push event into queue */
|
---|
1147 | mp2);
|
---|
1148 | break; /* enable further processing ! */
|
---|
1149 | }
|
---|
1150 |
|
---|
1151 | return WinDefWindowProc(hwnd, /* to default processing */
|
---|
1152 | msg,
|
---|
1153 | mp1,
|
---|
1154 | mp2);
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 |
|
---|
1158 | /*****************************************************************************
|
---|
1159 | * Name : static MRESULT EXPENTRY ConsoleFrameWindowProc
|
---|
1160 | * Purpose : Window Procedure for OUR console frame window
|
---|
1161 | * Parameters: HWND hwnd - window handle
|
---|
1162 | * ULONG msg - message identifier
|
---|
1163 | * MPARAM mp1 - message parameter 1
|
---|
1164 | * MPARAM mp2 - message parameter 2
|
---|
1165 | * Variables :
|
---|
1166 | * Result : MRESULT for PM
|
---|
1167 | * Remark :
|
---|
1168 | * Status :
|
---|
1169 | *
|
---|
1170 | * Author : Patrick Haller [Tue, 1998/02/10 03:24]
|
---|
1171 | *****************************************************************************/
|
---|
1172 |
|
---|
1173 | MRESULT EXPENTRY iConsoleFrameWindowProc(HWND hwnd,
|
---|
1174 | ULONG msg,
|
---|
1175 | MPARAM mp1,
|
---|
1176 | MPARAM mp2)
|
---|
1177 | {
|
---|
1178 | switch(msg)
|
---|
1179 | {
|
---|
1180 | /*************************************************************************
|
---|
1181 | * WM_QUERYTRACKINFO handling *
|
---|
1182 | *************************************************************************/
|
---|
1183 | case WM_QUERYTRACKINFO:
|
---|
1184 | {
|
---|
1185 | MRESULT mr; /* message result */
|
---|
1186 | PTRACKINFO pTrackInfo; /* frame window tracking information */
|
---|
1187 |
|
---|
1188 | /* let the original code do the hard work first */
|
---|
1189 | mr = ConsoleGlobals.pfnwpFrameOriginal(hwnd,
|
---|
1190 | msg,
|
---|
1191 | mp1,
|
---|
1192 | mp2);
|
---|
1193 |
|
---|
1194 | pTrackInfo = (PTRACKINFO)mp2; /* get track information */
|
---|
1195 |
|
---|
1196 | /* @@@PH */
|
---|
1197 | pTrackInfo->ptlMinTrackSize.x = max(pTrackInfo->ptlMinTrackSize.x, 200);
|
---|
1198 | pTrackInfo->ptlMinTrackSize.y = max(pTrackInfo->ptlMinTrackSize.y, 100);
|
---|
1199 | pTrackInfo->ptlMaxTrackSize.x = min(pTrackInfo->ptlMaxTrackSize.x, ConsoleGlobals.coordMaxWindowPels.X);
|
---|
1200 | pTrackInfo->ptlMaxTrackSize.y = min(pTrackInfo->ptlMaxTrackSize.y, ConsoleGlobals.coordMaxWindowPels.Y);
|
---|
1201 |
|
---|
1202 | return (mr); /* deliver result */
|
---|
1203 | }
|
---|
1204 | }
|
---|
1205 |
|
---|
1206 | /* call original frame window procedure code */
|
---|
1207 | return (ConsoleGlobals.pfnwpFrameOriginal(hwnd,
|
---|
1208 | msg,
|
---|
1209 | mp1,
|
---|
1210 | mp2));
|
---|
1211 | }
|
---|
1212 |
|
---|
1213 |
|
---|
1214 | /*****************************************************************************
|
---|
1215 | * Name : static void ConsoleBufferMap
|
---|
1216 | * Purpose : draw a whole consolebuffer into the VIO space
|
---|
1217 | * Parameters: PCONSOLEBUFFER pConsoleBuffer
|
---|
1218 | * Variables :
|
---|
1219 | * Result : none
|
---|
1220 | * Remark :
|
---|
1221 | * Status :
|
---|
1222 | *
|
---|
1223 | * Author : Patrick Haller [Tue, 1998/02/17 12:57]
|
---|
1224 | *****************************************************************************/
|
---|
1225 |
|
---|
1226 | void iConsoleBufferMap(PCONSOLEBUFFER pConsoleBuffer)
|
---|
1227 | {
|
---|
1228 | ULONG ulLine;
|
---|
1229 |
|
---|
1230 | ULONG ulSizeX; /* blitting length and height */
|
---|
1231 | ULONG ulSizeY;
|
---|
1232 |
|
---|
1233 | ulSizeX = 2 * min(ConsoleGlobals.coordWindowSize.X,
|
---|
1234 | pConsoleBuffer->coordBufferSize.X -
|
---|
1235 | ConsoleGlobals.coordWindowPos.X);
|
---|
1236 |
|
---|
1237 | ulSizeY = min(ConsoleGlobals.coordWindowSize.Y,
|
---|
1238 | pConsoleBuffer->coordBufferSize.Y -
|
---|
1239 | ConsoleGlobals.coordWindowPos.Y);
|
---|
1240 |
|
---|
1241 | /* check if we're called with non-existing line buffer */
|
---|
1242 | if (pConsoleBuffer->ppszLine == NULL)
|
---|
1243 | return;
|
---|
1244 |
|
---|
1245 | for (ulLine = ConsoleGlobals.coordWindowPos.Y;
|
---|
1246 | ulLine < ulSizeY;
|
---|
1247 | ulLine++)
|
---|
1248 | VioWrtCellStr(pConsoleBuffer->ppszLine[ulLine] +
|
---|
1249 | ConsoleGlobals.coordWindowPos.X,
|
---|
1250 | ulSizeX,
|
---|
1251 | ulLine,
|
---|
1252 | 0,
|
---|
1253 | ConsoleGlobals.hvpsConsole);
|
---|
1254 | }
|
---|
1255 |
|
---|
1256 |
|
---|
1257 | /*****************************************************************************
|
---|
1258 | * Name : static void ConsoleBufferFillLine
|
---|
1259 | * Purpose : fills a line with a certain output pattern
|
---|
1260 | * Parameters: ULONG ulPattern, PUSHORT pusTarget, ULONG ulSize
|
---|
1261 | * Variables :
|
---|
1262 | * Result : none
|
---|
1263 | * Remark :
|
---|
1264 | * Status :
|
---|
1265 | *
|
---|
1266 | * Author : Patrick Haller [Tue, 1998/02/17 12:57]
|
---|
1267 | *****************************************************************************/
|
---|
1268 |
|
---|
1269 | void iConsoleBufferFillLine(ULONG ulPattern,
|
---|
1270 | PUSHORT pusTarget,
|
---|
1271 | ULONG ulSize)
|
---|
1272 | {
|
---|
1273 | ULONG ulCounter;
|
---|
1274 |
|
---|
1275 | for (ulCounter = 0;
|
---|
1276 | ulCounter < (ulSize >> 1);
|
---|
1277 | ulCounter++,
|
---|
1278 | pusTarget+=2)
|
---|
1279 | *(PULONG)pusTarget = ulPattern;
|
---|
1280 |
|
---|
1281 | if (ulSize & 0x00000001)
|
---|
1282 | *pusTarget = (USHORT)ulPattern;
|
---|
1283 | }
|
---|
1284 |
|
---|
1285 |
|
---|
1286 | /*****************************************************************************
|
---|
1287 | * Name : static void ConsoleBufferScrollUp
|
---|
1288 | * Purpose : scroll whole buffer n lines up,
|
---|
1289 | * fill new lines with default attribute
|
---|
1290 | * Parameters: PCONSOLEBUFFER pConsoleBuffer
|
---|
1291 | * ULONG ulLines
|
---|
1292 | * Variables :
|
---|
1293 | * Result : none
|
---|
1294 | * Remark :
|
---|
1295 | * Status :
|
---|
1296 | *
|
---|
1297 | * Author : Patrick Haller [Tue, 1998/02/17 12:57]
|
---|
1298 | *****************************************************************************/
|
---|
1299 |
|
---|
1300 | void iConsoleBufferScrollUp(PCONSOLEBUFFER pConsoleBuffer,
|
---|
1301 | ULONG ulLines)
|
---|
1302 | {
|
---|
1303 | ULONG ulLine;
|
---|
1304 | ULONG ulPosition;
|
---|
1305 | ULONG ulScrollLine;
|
---|
1306 |
|
---|
1307 | static ULONG ulUpdateCounter; /* counter for jump-scrolling */
|
---|
1308 |
|
---|
1309 | /* calculate new line offset to the first line */
|
---|
1310 | pConsoleBuffer->ulScrollLineOffset += ulLines;
|
---|
1311 | pConsoleBuffer->ulScrollLineOffset %= pConsoleBuffer->coordBufferSize.Y;
|
---|
1312 |
|
---|
1313 | /* do we have to scroll ? */
|
---|
1314 | if (ulLines < pConsoleBuffer->coordBufferSize.Y)
|
---|
1315 | {
|
---|
1316 | for (ulLine = 0; /* do the scrolling */
|
---|
1317 | ulLine < ConsoleGlobals.coordWindowSize.Y;
|
---|
1318 | ulLine++)
|
---|
1319 | {
|
---|
1320 | ulScrollLine = (ulLine + pConsoleBuffer->ulScrollLineOffset)
|
---|
1321 | % pConsoleBuffer->coordBufferSize.Y;
|
---|
1322 |
|
---|
1323 | ulPosition = (ULONG)pConsoleBuffer->ppszLine
|
---|
1324 | + (pConsoleBuffer->coordBufferSize.Y * sizeof (PSZ) )
|
---|
1325 | + (pConsoleBuffer->coordBufferSize.X * 2 * ulScrollLine);
|
---|
1326 |
|
---|
1327 | pConsoleBuffer->ppszLine[ulLine] = (PSZ)ulPosition;
|
---|
1328 | }
|
---|
1329 | }
|
---|
1330 |
|
---|
1331 | /* enforce the upper limit */
|
---|
1332 | if (ulLines > pConsoleBuffer->coordBufferSize.Y)
|
---|
1333 | ulLines = pConsoleBuffer->coordBufferSize.Y;
|
---|
1334 |
|
---|
1335 | ulPosition = ( ((ULONG)(pConsoleBuffer->ucDefaultAttribute) << 8) +
|
---|
1336 | ((ULONG)' ') +
|
---|
1337 | ((ULONG)(pConsoleBuffer->ucDefaultAttribute) << 24) +
|
---|
1338 | ((ULONG)' ' << 16) );
|
---|
1339 |
|
---|
1340 | /* scroll the line index */
|
---|
1341 | for (ulLine = pConsoleBuffer->coordBufferSize.Y - ulLines;
|
---|
1342 | ulLine < pConsoleBuffer->coordBufferSize.Y;
|
---|
1343 | ulLine++)
|
---|
1344 | iConsoleBufferFillLine(ulPosition,
|
---|
1345 | (PUSHORT)(pConsoleBuffer->ppszLine[ulLine]),
|
---|
1346 | pConsoleBuffer->coordBufferSize.X);
|
---|
1347 |
|
---|
1348 | /* this code ensures frequent screen updating, even if the timer prooves */
|
---|
1349 | /* to be to slow */
|
---|
1350 | ulUpdateCounter++;
|
---|
1351 | if (ulUpdateCounter > ConsoleGlobals.Options.ulUpdateLimit)
|
---|
1352 | {
|
---|
1353 | ulUpdateCounter = 0; /* reset the counter */
|
---|
1354 | iConsoleBufferMap(pConsoleBuffer);
|
---|
1355 | VioShowPS(ConsoleGlobals.coordWindowSize.Y,
|
---|
1356 | ConsoleGlobals.coordWindowSize.X,
|
---|
1357 | 0,
|
---|
1358 | ConsoleGlobals.hvpsConsole);
|
---|
1359 |
|
---|
1360 | ConsoleGlobals.fUpdateRequired = FALSE; /* no more required ... */
|
---|
1361 | }
|
---|
1362 | }
|
---|
1363 |
|
---|
1364 |
|
---|
1365 | /*****************************************************************************
|
---|
1366 | * Name : static APIRET ConsoleInputEventPush
|
---|
1367 | * Purpose : add an element to the console input queue
|
---|
1368 | * Parameters: PINPUT_RECORD pInputRecord
|
---|
1369 | * Variables :
|
---|
1370 | * Result : API returncode
|
---|
1371 | * Remark :
|
---|
1372 | * Status :
|
---|
1373 | *
|
---|
1374 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
1375 | *****************************************************************************/
|
---|
1376 |
|
---|
1377 | APIRET iConsoleInputEventPush(PINPUT_RECORD pInputRecord)
|
---|
1378 | {
|
---|
1379 | PINPUT_RECORD pirFree; /* pointer to free record */
|
---|
1380 | APIRET rc; /* API-returncode */
|
---|
1381 |
|
---|
1382 | dprintf2(("KERNEL32/CONSOLE:ConsoleInputEventPush(%08x).\n",
|
---|
1383 | pInputRecord));
|
---|
1384 |
|
---|
1385 | iConsoleInputQueueLock();
|
---|
1386 | /* get free event */
|
---|
1387 | pirFree = &ConsoleInput.arrInputRecord[ConsoleInput.ulIndexFree];
|
---|
1388 | if (pirFree->EventType != 0x0000)
|
---|
1389 | {
|
---|
1390 | iConsoleInputQueueUnlock();
|
---|
1391 | return (ERROR_QUE_NO_MEMORY); /* queue is full ! */
|
---|
1392 | }
|
---|
1393 | /* put event in queue */
|
---|
1394 |
|
---|
1395 | ConsoleInput.ulIndexFree++; /* update index counter */
|
---|
1396 | if (ConsoleInput.ulIndexFree >= CONSOLE_INPUTQUEUESIZE)
|
---|
1397 | ConsoleInput.ulIndexFree = 0;
|
---|
1398 |
|
---|
1399 | ConsoleInput.ulEvents++; /* increate queue event counter */
|
---|
1400 |
|
---|
1401 | iConsoleInputQueueUnlock();
|
---|
1402 |
|
---|
1403 | memcpy(pirFree, /* copy data */
|
---|
1404 | pInputRecord,
|
---|
1405 | sizeof (INPUT_RECORD) );
|
---|
1406 |
|
---|
1407 | if(flVioConsole == FALSE)
|
---|
1408 | { /* unblock reading threads */
|
---|
1409 | rc = DosPostEventSem(ConsoleInput.hevInputQueue);
|
---|
1410 | }
|
---|
1411 | else rc = 0;
|
---|
1412 | return (rc); /* OK */
|
---|
1413 | }
|
---|
1414 |
|
---|
1415 |
|
---|
1416 | /*****************************************************************************
|
---|
1417 | * Name : static APIRET ConsoleInputEventPop
|
---|
1418 | * Purpose : read first element from the console input queue
|
---|
1419 | * Parameters: PINPUT_RECORD pInputRecord
|
---|
1420 | * Variables :
|
---|
1421 | * Result : API returncode
|
---|
1422 | * Remark :
|
---|
1423 | * Status :
|
---|
1424 | *
|
---|
1425 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
1426 | *****************************************************************************/
|
---|
1427 |
|
---|
1428 | APIRET iConsoleInputEventPop(PINPUT_RECORD pInputRecord)
|
---|
1429 | {
|
---|
1430 | PINPUT_RECORD pirEvent; /* pointer to event record */
|
---|
1431 | APIRET rc; /* API-returncode */
|
---|
1432 |
|
---|
1433 | dprintf2(("KERNEL32/CONSOLE:ConsoleInputEventPop(%08x).\n",
|
---|
1434 | pInputRecord));
|
---|
1435 |
|
---|
1436 | if (ConsoleInput.ulEvents == 0) /* empty console ? */
|
---|
1437 | return (ERROR_QUE_EMPTY); /* queue is empty ! */
|
---|
1438 |
|
---|
1439 | iConsoleInputQueueLock();
|
---|
1440 | /* get first event */
|
---|
1441 | pirEvent = &ConsoleInput.arrInputRecord[ConsoleInput.ulIndexEvent];
|
---|
1442 | if (pirEvent->EventType == 0x0000)
|
---|
1443 | {
|
---|
1444 | iConsoleInputQueueUnlock();
|
---|
1445 | return (ERROR_QUE_EMPTY); /* queue is empty ! */
|
---|
1446 | }
|
---|
1447 |
|
---|
1448 | if (ConsoleInput.ulEvents >= 0) /* decrease number of console events */
|
---|
1449 | ConsoleInput.ulEvents--;
|
---|
1450 |
|
---|
1451 | ConsoleInput.ulIndexEvent++; /* update index counter */
|
---|
1452 | if (ConsoleInput.ulIndexEvent >= CONSOLE_INPUTQUEUESIZE)
|
---|
1453 | ConsoleInput.ulIndexEvent = 0;
|
---|
1454 |
|
---|
1455 | /* put event in queue */
|
---|
1456 | memcpy(pInputRecord, /* copy data */
|
---|
1457 | pirEvent,
|
---|
1458 | sizeof (INPUT_RECORD) );
|
---|
1459 |
|
---|
1460 | pirEvent->EventType = 0x0000; /* mark event as read = free */
|
---|
1461 |
|
---|
1462 | iConsoleInputQueueUnlock();
|
---|
1463 |
|
---|
1464 | return (NO_ERROR); /* OK */
|
---|
1465 | }
|
---|
1466 |
|
---|
1467 |
|
---|
1468 | /*****************************************************************************
|
---|
1469 | * Name : static APIRET ConsoleInputEventPushKey
|
---|
1470 | * Purpose : push key event into the queue
|
---|
1471 | * Parameters: MPARAM mp1, MPARAM mp2 from WM_CHAR processing
|
---|
1472 | * Variables :
|
---|
1473 | * Result : API returncode
|
---|
1474 | * Remark : @@@PH: 2nd table that learns codes automatically from "down"
|
---|
1475 | * messages from PM. With Alt-a, etc. it is 0 for "up" ?
|
---|
1476 | * Status :
|
---|
1477 | *
|
---|
1478 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
1479 | *****************************************************************************/
|
---|
1480 |
|
---|
1481 | char tabVirtualKeyCodes[TABVIRTUALKEYCODES] =
|
---|
1482 | {
|
---|
1483 | /* --- PM key -- NT key --- */
|
---|
1484 | /* 0x00 */ 0,
|
---|
1485 | /* VK_BUTTON1 0x01 */ 0x01, /* WIN_VK_LBUTTON ??? */
|
---|
1486 | /* VK_BUTTON2 0x02 */ 0x02, /* WIN_VK_RBUTTON ??? */
|
---|
1487 | /* VK_BUTTON3 0x03 */ 0x04, /* WIN_VK_MBUTTON ??? */
|
---|
1488 | /* VK_BREAK 0x04 */ 0x03, /* WIN_VK_CANCEL ??? */
|
---|
1489 | /* VK_BACKSPACE 0x05 */ 0x08, /* WIN_VK_BACK */
|
---|
1490 | /* VK_TAB 0x06 */ 0x09, /* WIN_VK_TAB */
|
---|
1491 | /* VK_BACKTAB 0x07 */ 0,
|
---|
1492 | /* VK_NEWLINE 0x08 */ 0,
|
---|
1493 | /* VK_SHIFT 0x09 */ 0x10, /* WIN_VK_SHIFT */
|
---|
1494 | /* VK_CTRL 0x0A */ 0x11, /* WIN_VK_CONTROL */
|
---|
1495 | /* VK_ALT 0x0B */ 0x12, /* WIN_VK_MENU */
|
---|
1496 | /* VK_ALTGRAF 0x0C */ 0,
|
---|
1497 | /* VK_PAUSE 0x0D */ 0x13, /* WIN_VK_PAUSE */
|
---|
1498 | /* VK_CAPSLOCK 0x0E */ 0x14, /* WIN_VK_CAPITAL ??? */
|
---|
1499 | /* VK_ESC 0x0F */ 0x1b, /* WIN_VK_ESCAPE */
|
---|
1500 | /* VK_SPACE 0x10 */ 0x20, /* WIN_VK_SPACE */
|
---|
1501 | /* VK_PAGEUP 0x11 */ 0x21, /* WIN_VK_PRIOR ??? */
|
---|
1502 | /* VK_PAGEDOWN 0x12 */ 0x22, /* WIN_VK_NEXT ??? */
|
---|
1503 | /* VK_END 0x13 */ 0x23, /* WIN_VK_END */
|
---|
1504 | /* VK_HOME 0x14 */ 0x24, /* WIN_VK_HOME */
|
---|
1505 | /* VK_LEFT 0x15 */ 0x25, /* WIN_VK_LEFT */
|
---|
1506 | /* VK_UP 0x16 */ 0x26, /* WIN_VK_UP */
|
---|
1507 | /* VK_RIGHT 0x17 */ 0x27, /* WIN_VK_RIGHT */
|
---|
1508 | /* VK_DOWN 0x18 */ 0x28, /* WIN_VK_DOWN */
|
---|
1509 | /* VK_PRINTSCRN 0x19 */ 0x2A, /* WIN_VK_PRINT */
|
---|
1510 | /* VK_INSERT 0x1A */ 0x2D, /* WIN_VK_INSERT */
|
---|
1511 | /* VK_DELETE 0x1B */ 0x2E, /* WIN_VK_DELETE */
|
---|
1512 | /* VK_SCRLLOCK 0x1C */ 0x91, /* WIN_VK_SCROLL */
|
---|
1513 | /* VK_NUMLOCK 0x1D */ 0x90, /* WIN_VK_NUMLOCK */
|
---|
1514 | /* VK_ENTER 0x1E */ 0x0D, /* WIN_VK_RETURN */
|
---|
1515 | /* VK_SYSRQ 0x1F */ 0,
|
---|
1516 | /* VK_F1 0x20 */ 0x70, /* WIN_VK_F1 */
|
---|
1517 | /* VK_F2 0x21 */ 0x71, /* WIN_VK_F2 */
|
---|
1518 | /* VK_F3 0x22 */ 0x72, /* WIN_VK_F3 */
|
---|
1519 | /* VK_F4 0x23 */ 0x73, /* WIN_VK_F4 */
|
---|
1520 | /* VK_F5 0x24 */ 0x74, /* WIN_VK_F5 */
|
---|
1521 | /* VK_F6 0x25 */ 0x75, /* WIN_VK_F6 */
|
---|
1522 | /* VK_F7 0x26 */ 0x76, /* WIN_VK_F7 */
|
---|
1523 | /* VK_F8 0x27 */ 0x77, /* WIN_VK_F8 */
|
---|
1524 | /* VK_F9 0x28 */ 0x78, /* WIN_VK_F9 */
|
---|
1525 | /* VK_F10 0x29 */ 0x79, /* WIN_VK_F10 */
|
---|
1526 | /* VK_F11 0x2A */ 0x7A, /* WIN_VK_F11 */
|
---|
1527 | /* VK_F12 0x2B */ 0x7B, /* WIN_VK_F12 */
|
---|
1528 | /* VK_F13 0x2C */ 0x7C, /* WIN_VK_F13 */
|
---|
1529 | /* VK_F14 0x2D */ 0x7D, /* WIN_VK_F14 */
|
---|
1530 | /* VK_F15 0x2E */ 0x7E, /* WIN_VK_F15 */
|
---|
1531 | /* VK_F16 0x2F */ 0x7F, /* WIN_VK_F16 */
|
---|
1532 | /* VK_F17 0x30 */ 0x80, /* WIN_VK_F17 */
|
---|
1533 | /* VK_F18 0x31 */ 0x81, /* WIN_VK_F18 */
|
---|
1534 | /* VK_F19 0x32 */ 0x82, /* WIN_VK_F19 */
|
---|
1535 | /* VK_F20 0x33 */ 0x83, /* WIN_VK_F20 */
|
---|
1536 | /* VK_F21 0x34 */ 0x84, /* WIN_VK_F21 */
|
---|
1537 | /* VK_F22 0x35 */ 0x85, /* WIN_VK_F22 */
|
---|
1538 | /* VK_F23 0x36 */ 0x86, /* WIN_VK_F23 */
|
---|
1539 | /* VK_F24 0x37 */ 0x87, /* WIN_VK_F24 */
|
---|
1540 | /* VK_ENDDRAG 0x38 */ 0,
|
---|
1541 | /* VK_CLEAR 0x39 */ 0x0C, /* WIN_VK_CLEAR */
|
---|
1542 | /* VK_EREOF 0x3A */ 0xF9, /* WIN_VK_EREOF */
|
---|
1543 | /* VK_PA1 0x3B */ 0xFD, /* WIN_VK_PA1 */
|
---|
1544 | /* VK_ATTN 0x3C */ 0xF6, /* WIN_VK_ATTN */
|
---|
1545 | /* VK_CRSEL 0x3D */ 0xF7, /* WIN_VK_CRSEL */
|
---|
1546 | /* VK_EXSEL 0x3E */ 0xF8, /* WIN_VK_EXSEL */
|
---|
1547 | /* VK_COPY 0x3F */ 0,
|
---|
1548 | /* VK_BLK1 0x40 */ 0,
|
---|
1549 | /* VK_BLK2 0x41 */ 0,
|
---|
1550 | /* 0x42 */ 0,
|
---|
1551 | /* 0x43 */ 0,
|
---|
1552 | /* 0x44 */ 0,
|
---|
1553 | /* 0x45 */ 0,
|
---|
1554 | /* 0x46 */ 0,
|
---|
1555 | /* 0x47 */ 0,
|
---|
1556 | /* 0x48 */ 0,
|
---|
1557 | /* 0x49 */ 0,
|
---|
1558 | /* 0x4A */ 0,
|
---|
1559 | /* 0x4B */ 0,
|
---|
1560 | /* 0x4C */ 0,
|
---|
1561 | /* 0x4D */ 0,
|
---|
1562 | /* 0x4E */ 0,
|
---|
1563 | /* 0x4F */ 0,
|
---|
1564 | /* from UNIKBD.H: */
|
---|
1565 | /* VK_PA2 0x0050 */ 0,
|
---|
1566 | /* VK_PA3 0x0051 */ 0,
|
---|
1567 | /* VK_GROUP 0x0052 */ 0,
|
---|
1568 | /* VK_GROUPLOCK 0x0053 */ 0,
|
---|
1569 | /* VK_APPL 0x0054 */ 0x5D, /* WIN_VK_APPS ??? */
|
---|
1570 | /* VK_WINLEFT 0x0055 */ 0x5B, /* WIN_VK_LWIN */
|
---|
1571 | /* VK_WINRIGHT 0x0056 */ 0x5C, /* WIN_VK_RWIN */
|
---|
1572 | /* 0x0057 */ 0,
|
---|
1573 | /* 0x0058 */ 0,
|
---|
1574 | /* 0x0059 */ 0,
|
---|
1575 | /* 0x005A */ 0,
|
---|
1576 | /* 0x005B */ 0,
|
---|
1577 | /* 0x005C */ 0,
|
---|
1578 | /* 0x005D */ 0,
|
---|
1579 | /* 0x005E */ 0,
|
---|
1580 | /* 0x005F */ 0,
|
---|
1581 | /* 0x0060 */ 0,
|
---|
1582 | /* VK_M_DOWNLEFT 0x0061 */ 0,
|
---|
1583 | /* VK_M_DOWN 0x0062 */ 0,
|
---|
1584 | /* VK_M_DOWNRIGHT 0x0063 */ 0,
|
---|
1585 | /* VK_M_LEFT 0x0064 */ 0,
|
---|
1586 | /* VK_M_CENTER 0x0065 */ 0,
|
---|
1587 | /* VK_M_RIGHT 0x0066 */ 0,
|
---|
1588 | /* VK_M_UPLEFT 0x0067 */ 0,
|
---|
1589 | /* VK_M_UP 0x0068 */ 0,
|
---|
1590 | /* VK_M_UPRIGHT 0x0069 */ 0,
|
---|
1591 | /* VK_M_BUTTONLOCK 0x006A */ 0,
|
---|
1592 | /* VK_M_BUTTONRELEASE 0x006B */ 0,
|
---|
1593 | /* VK_M_DOUBLECLICK 0x006C */ 0,
|
---|
1594 |
|
---|
1595 | #if 0
|
---|
1596 | 0xA4, /* WIN_VK_LMENU ??? */
|
---|
1597 | 0xA5, /* WIN_VK_RMENU ??? */
|
---|
1598 | #define VK_SELECT 0x29
|
---|
1599 | #define VK_EXECUTE 0x2B
|
---|
1600 | #define VK_SNAPSHOT 0x2C
|
---|
1601 | #define VK_HELP 0x2F
|
---|
1602 | #define VK_NUMPAD0 0x60
|
---|
1603 | #define VK_NUMPAD1 0x61
|
---|
1604 | #define VK_NUMPAD2 0x62
|
---|
1605 | #define VK_NUMPAD3 0x63
|
---|
1606 | #define VK_NUMPAD4 0x64
|
---|
1607 | #define VK_NUMPAD5 0x65
|
---|
1608 | #define VK_NUMPAD6 0x66
|
---|
1609 | #define VK_NUMPAD7 0x67
|
---|
1610 | #define VK_NUMPAD8 0x68
|
---|
1611 | #define VK_NUMPAD9 0x69
|
---|
1612 | #define VK_MULTIPLY 0x6A
|
---|
1613 | #define VK_ADD 0x6B
|
---|
1614 | #define VK_SEPARATOR 0x6C
|
---|
1615 | #define VK_SUBTRACT 0x6D
|
---|
1616 | #define VK_DECIMAL 0x6E
|
---|
1617 | #define VK_DIVIDE 0x6F
|
---|
1618 | #define VK_LSHIFT 0xA0
|
---|
1619 | #define VK_RSHIFT 0xA1
|
---|
1620 | #define VK_LCONTROL 0xA2
|
---|
1621 | #define VK_RCONTROL 0xA3
|
---|
1622 | #define VK_PROCESSKEY 0xE5
|
---|
1623 | #define VK_PLAY 0xFA
|
---|
1624 | #define VK_ZOOM 0xFB
|
---|
1625 | #define VK_NONAME 0xFC
|
---|
1626 | #define VK_OEM_CLEAR 0xFE
|
---|
1627 | #endif
|
---|
1628 |
|
---|
1629 | };
|
---|
1630 |
|
---|
1631 |
|
---|
1632 | APIRET iConsoleInputEventPushKey(MPARAM mp1,
|
---|
1633 | MPARAM mp2)
|
---|
1634 | {
|
---|
1635 | INPUT_RECORD InputRecord; /* the input record structure */
|
---|
1636 | APIRET rc; /* API-returncode */
|
---|
1637 | USHORT fsFlags = ((ULONG)mp1 & 0x0000ffff); /* get key flags */
|
---|
1638 | UCHAR ucRepeat = ((ULONG)mp1 & 0x00ff0000) >> 16;
|
---|
1639 | UCHAR ucScanCode = ((ULONG)mp1 & 0xff000000) >> 24;
|
---|
1640 | UCHAR usCh = ((ULONG)mp2 & 0x0000ffff);
|
---|
1641 | USHORT usVk = ((ULONG)mp2 & 0xffff0000) >> 16;
|
---|
1642 | UCHAR ucChar = usCh & 0x00ff;
|
---|
1643 |
|
---|
1644 | dprintf2(("KERNEL32/CONSOLE:ConsoleInputEventPushKey(%08x,%08x).\n",
|
---|
1645 | mp1,
|
---|
1646 | mp2));
|
---|
1647 |
|
---|
1648 |
|
---|
1649 | InputRecord.EventType = KEY_EVENT; /* fill event structure */
|
---|
1650 | InputRecord.Event.KeyEvent.dwControlKeyState = 0;
|
---|
1651 |
|
---|
1652 | if (fsFlags & KC_SHIFT) InputRecord.Event.KeyEvent.dwControlKeyState |= SHIFT_PRESSED;
|
---|
1653 | if (fsFlags & KC_ALT) InputRecord.Event.KeyEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
|
---|
1654 | if (fsFlags & KC_CTRL) InputRecord.Event.KeyEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
|
---|
1655 |
|
---|
1656 | /* @@@PH no support for RIGHT_ALT_PRESSED,
|
---|
1657 | RIGHT_CTRL_PRESSED,
|
---|
1658 | NUMLOCK_ON,
|
---|
1659 | SCROLLLOCK_ON,
|
---|
1660 | CAPSLOCK_ON,
|
---|
1661 | ENHANCED_KEY
|
---|
1662 | */
|
---|
1663 |
|
---|
1664 | InputRecord.Event.KeyEvent.bKeyDown = !(fsFlags & KC_KEYUP);
|
---|
1665 | InputRecord.Event.KeyEvent.wRepeatCount = ucRepeat;
|
---|
1666 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usVk;
|
---|
1667 | InputRecord.Event.KeyEvent.wVirtualScanCode = ucScanCode;
|
---|
1668 |
|
---|
1669 | /* check if ascii is valid, if so then wVirtualKeyCode = ascii, */
|
---|
1670 | /* else go through the table */
|
---|
1671 | if (fsFlags & KC_CHAR) /* usCh valid ? */
|
---|
1672 | {
|
---|
1673 | /* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
|
---|
1674 | /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
|
---|
1675 | if ( ( (usCh >= 'a') && (usCh <= 'z') ) || /* lowercase ? */
|
---|
1676 | ( (usCh >= '0') && (usCh <= '9') )
|
---|
1677 | )
|
---|
1678 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh & 0xDF;
|
---|
1679 | else
|
---|
1680 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh;
|
---|
1681 | }
|
---|
1682 | else
|
---|
1683 | if (fsFlags & KC_VIRTUALKEY) /* translate OS/2 virtual key code */
|
---|
1684 | {
|
---|
1685 | if (usVk < TABVIRTUALKEYCODES) /* limit to table size */
|
---|
1686 | InputRecord.Event.KeyEvent.wVirtualKeyCode =
|
---|
1687 | tabVirtualKeyCodes[usVk]; /* translate keycode */
|
---|
1688 | }
|
---|
1689 |
|
---|
1690 | /* this is a workaround for empty / invalid wVirtualKeyCodes */
|
---|
1691 | if (InputRecord.Event.KeyEvent.wVirtualKeyCode == 0x0000)
|
---|
1692 | {
|
---|
1693 | if ( ( (usCh >= 'a') && (usCh <= 'z') ) || /* lowercase ? */
|
---|
1694 | ( (usCh >= '0') && (usCh <= '9') )
|
---|
1695 | )
|
---|
1696 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh & 0xDF;
|
---|
1697 | else
|
---|
1698 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh;
|
---|
1699 | }
|
---|
1700 |
|
---|
1701 |
|
---|
1702 | /* @@@PH handle special keys */
|
---|
1703 | if ( (ucChar != 0xe0) && (ucChar != 0x00) )
|
---|
1704 | InputRecord.Event.KeyEvent.uChar.AsciiChar = ucChar;
|
---|
1705 | else
|
---|
1706 | {
|
---|
1707 | /* extended key ! */
|
---|
1708 | InputRecord.Event.KeyEvent.dwControlKeyState |= ENHANCED_KEY;
|
---|
1709 | InputRecord.Event.KeyEvent.uChar.AsciiChar = (ucChar >> 8);
|
---|
1710 | }
|
---|
1711 |
|
---|
1712 | /* further processing according the current input console mode */
|
---|
1713 | if (ConsoleInput.dwConsoleMode & ENABLE_PROCESSED_INPUT)
|
---|
1714 | {
|
---|
1715 | /* filter ctrl-c, etc. */
|
---|
1716 | }
|
---|
1717 |
|
---|
1718 | #if 0
|
---|
1719 | /* DEBUG */
|
---|
1720 | dprintf(("DEBUG: mp1=%08x mp2=%08x\n",
|
---|
1721 | mp1,
|
---|
1722 | mp2));
|
---|
1723 | dprintf(("DEBUG: fsFlags = %04x repeat=%u hwscan=%2x",
|
---|
1724 | fsFlags,
|
---|
1725 | ucRepeat,
|
---|
1726 | ucScanCode ));
|
---|
1727 | dprintf((" uscc=%04x usvk=%04x\n",
|
---|
1728 | SHORT1FROMMP(mp2),
|
---|
1729 | SHORT2FROMMP(mp2)));
|
---|
1730 |
|
---|
1731 | dprintf(("DEBUG: ascii=[%c] (%02x)",
|
---|
1732 | InputRecord.Event.KeyEvent.uChar.AsciiChar,
|
---|
1733 | InputRecord.Event.KeyEvent.uChar.AsciiChar));
|
---|
1734 | #endif
|
---|
1735 |
|
---|
1736 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
---|
1737 | return (rc); /* OK */
|
---|
1738 | }
|
---|
1739 |
|
---|
1740 |
|
---|
1741 | /*****************************************************************************
|
---|
1742 | * Name : static APIRET ConsoleInputEventPushMouse
|
---|
1743 | * Purpose : push mouse event into the queue
|
---|
1744 | * Parameters: MPARAM mp1, MPARAM mp2 from WM_MOUSEMOVE processing
|
---|
1745 | * Variables :
|
---|
1746 | * Result : API returncode
|
---|
1747 | * Remark :
|
---|
1748 | * Status :
|
---|
1749 | *
|
---|
1750 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
1751 | *****************************************************************************/
|
---|
1752 |
|
---|
1753 | APIRET iConsoleInputEventPushMouse(ULONG ulMessage,
|
---|
1754 | MPARAM mp1,
|
---|
1755 | MPARAM mp2)
|
---|
1756 | {
|
---|
1757 | INPUT_RECORD InputRecord; /* the input record structure */
|
---|
1758 | APIRET rc; /* API-returncode */
|
---|
1759 | USHORT fsFlags = SHORT2FROMMP(mp2); /* get key flags */
|
---|
1760 | static USHORT usButtonState; /* keeps track of mouse button state */
|
---|
1761 |
|
---|
1762 | /* do we have to process mouse input ? */
|
---|
1763 | if ( !(ConsoleInput.dwConsoleMode & ENABLE_MOUSE_INPUT))
|
---|
1764 | return (NO_ERROR); /* return immediately */
|
---|
1765 |
|
---|
1766 | dprintf2(("KERNEL32/CONSOLE:ConsoleInputEventPushMouse(%08x,%08x,%08x).\n",
|
---|
1767 | ulMessage,
|
---|
1768 | mp1,
|
---|
1769 | mp2));
|
---|
1770 |
|
---|
1771 | memset(&InputRecord, /* zero the structure */
|
---|
1772 | 0,
|
---|
1773 | sizeof (INPUT_RECORD) );
|
---|
1774 |
|
---|
1775 | InputRecord.EventType = MOUSE_EVENT; /* fill event structure */
|
---|
1776 |
|
---|
1777 | switch (ulMessage)
|
---|
1778 | {
|
---|
1779 | case WM_MOUSEMOVE:
|
---|
1780 | InputRecord.Event.MouseEvent.dwEventFlags = MOUSE_MOVED;
|
---|
1781 | InputRecord.Event.MouseEvent.dwMousePosition.X = SHORT1FROMMP(mp1);
|
---|
1782 | InputRecord.Event.MouseEvent.dwMousePosition.Y = SHORT2FROMMP(mp1);
|
---|
1783 |
|
---|
1784 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
---|
1785 |
|
---|
1786 | if (fsFlags & KC_SHIFT) InputRecord.Event.MouseEvent.dwControlKeyState |= SHIFT_PRESSED;
|
---|
1787 | if (fsFlags & KC_ALT) InputRecord.Event.MouseEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
|
---|
1788 | if (fsFlags & KC_CTRL) InputRecord.Event.MouseEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
|
---|
1789 |
|
---|
1790 | /* @@@PH no support for RIGHT_ALT_PRESSED,
|
---|
1791 | RIGHT_CTRL_PRESSED,
|
---|
1792 | NUMLOCK_ON,
|
---|
1793 | SCROLLLOCK_ON,
|
---|
1794 | CAPSLOCK_ON,
|
---|
1795 | ENHANCED_KEY
|
---|
1796 | */
|
---|
1797 | break;
|
---|
1798 |
|
---|
1799 | case WM_BUTTON1UP:
|
---|
1800 | usButtonState &= ~FROM_LEFT_1ST_BUTTON_PRESSED;
|
---|
1801 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
---|
1802 | break;
|
---|
1803 |
|
---|
1804 | case WM_BUTTON1DOWN:
|
---|
1805 | usButtonState |= FROM_LEFT_1ST_BUTTON_PRESSED;
|
---|
1806 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
---|
1807 | break;
|
---|
1808 |
|
---|
1809 | case WM_BUTTON2UP:
|
---|
1810 | usButtonState &= ~FROM_LEFT_2ND_BUTTON_PRESSED;
|
---|
1811 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
---|
1812 | break;
|
---|
1813 |
|
---|
1814 | case WM_BUTTON2DOWN:
|
---|
1815 | usButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
|
---|
1816 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
---|
1817 | break;
|
---|
1818 |
|
---|
1819 | case WM_BUTTON3UP:
|
---|
1820 | usButtonState &= ~FROM_LEFT_3RD_BUTTON_PRESSED;
|
---|
1821 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
---|
1822 | break;
|
---|
1823 |
|
---|
1824 | case WM_BUTTON3DOWN:
|
---|
1825 | usButtonState |= FROM_LEFT_3RD_BUTTON_PRESSED;
|
---|
1826 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
---|
1827 | break;
|
---|
1828 |
|
---|
1829 | case WM_BUTTON1DBLCLK:
|
---|
1830 | InputRecord.Event.MouseEvent.dwEventFlags = DOUBLE_CLICK;
|
---|
1831 | InputRecord.Event.MouseEvent.dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
|
---|
1832 | usButtonState &= ~FROM_LEFT_1ST_BUTTON_PRESSED;
|
---|
1833 | break;
|
---|
1834 |
|
---|
1835 | case WM_BUTTON2DBLCLK:
|
---|
1836 | InputRecord.Event.MouseEvent.dwEventFlags = DOUBLE_CLICK;
|
---|
1837 | InputRecord.Event.MouseEvent.dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
|
---|
1838 | usButtonState &= ~FROM_LEFT_2ND_BUTTON_PRESSED;
|
---|
1839 | break;
|
---|
1840 |
|
---|
1841 | case WM_BUTTON3DBLCLK:
|
---|
1842 | InputRecord.Event.MouseEvent.dwEventFlags = DOUBLE_CLICK;
|
---|
1843 | InputRecord.Event.MouseEvent.dwButtonState = FROM_LEFT_3RD_BUTTON_PRESSED;
|
---|
1844 | usButtonState &= ~FROM_LEFT_3RD_BUTTON_PRESSED;
|
---|
1845 | break;
|
---|
1846 | }
|
---|
1847 |
|
---|
1848 | /* @@@PH pseudo-support for RIGHTMOST_BUTTON_PRESSED */
|
---|
1849 | if (InputRecord.Event.MouseEvent.dwButtonState & FROM_LEFT_3RD_BUTTON_PRESSED)
|
---|
1850 | InputRecord.Event.MouseEvent.dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
|
---|
1851 |
|
---|
1852 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
---|
1853 | return (rc); /* OK */
|
---|
1854 | }
|
---|
1855 |
|
---|
1856 |
|
---|
1857 | /*****************************************************************************
|
---|
1858 | * Name : static APIRET ConsoleInputEventPushWindow
|
---|
1859 | * Purpose : push menu event into the queue
|
---|
1860 | * Parameters: DWORD dwCommandId
|
---|
1861 | * Variables :
|
---|
1862 | * Result : API returncode
|
---|
1863 | * Remark :
|
---|
1864 | * Status :
|
---|
1865 | *
|
---|
1866 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
1867 | *****************************************************************************/
|
---|
1868 |
|
---|
1869 | APIRET iConsoleInputEventPushWindow(COORD coordWindowSize)
|
---|
1870 | {
|
---|
1871 | INPUT_RECORD InputRecord; /* the input record structure */
|
---|
1872 | APIRET rc; /* API-returncode */
|
---|
1873 |
|
---|
1874 | /* do we have to process window input ? */
|
---|
1875 | if ( !(ConsoleInput.dwConsoleMode & ENABLE_WINDOW_INPUT))
|
---|
1876 | return (NO_ERROR); /* return immediately */
|
---|
1877 |
|
---|
1878 | dprintf2(("KERNEL32/CONSOLE:ConsoleInputEventPushWindow(x = %u, y = %u).\n",
|
---|
1879 | coordWindowSize.X,
|
---|
1880 | coordWindowSize.Y));
|
---|
1881 |
|
---|
1882 | InputRecord.EventType = WINDOW_BUFFER_SIZE_EVENT; /* fill event structure */
|
---|
1883 |
|
---|
1884 | InputRecord.Event.WindowBufferSizeEvent.dwSize = coordWindowSize;
|
---|
1885 |
|
---|
1886 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
---|
1887 | return (rc); /* OK */
|
---|
1888 | }
|
---|
1889 |
|
---|
1890 |
|
---|
1891 | /*****************************************************************************
|
---|
1892 | * Name : static APIRET ConsoleInputEventPushMenu
|
---|
1893 | * Purpose : push window event into the queue
|
---|
1894 | * Parameters: COORD coordWindowSize
|
---|
1895 | * Variables :
|
---|
1896 | * Result : API returncode
|
---|
1897 | * Remark :
|
---|
1898 | * Status :
|
---|
1899 | *
|
---|
1900 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
1901 | *****************************************************************************/
|
---|
1902 |
|
---|
1903 | APIRET iConsoleInputEventPushMenu(DWORD dwCommandId)
|
---|
1904 | {
|
---|
1905 | INPUT_RECORD InputRecord; /* the input record structure */
|
---|
1906 | APIRET rc; /* API-returncode */
|
---|
1907 |
|
---|
1908 | /* @@@PH this is unknown to me - there's no separate bit for menu events ? */
|
---|
1909 | /* do we have to process window input ? */
|
---|
1910 | if ( !(ConsoleInput.dwConsoleMode & ENABLE_WINDOW_INPUT))
|
---|
1911 | return (NO_ERROR); /* return immediately */
|
---|
1912 |
|
---|
1913 | dprintf2(("KERNEL32/CONSOLE:ConsoleInputEventPushMenu(%08x).\n",
|
---|
1914 | dwCommandId));
|
---|
1915 |
|
---|
1916 | InputRecord.EventType = MENU_EVENT; /* fill event structure */
|
---|
1917 |
|
---|
1918 | InputRecord.Event.MenuEvent.dwCommandId = dwCommandId;
|
---|
1919 |
|
---|
1920 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
---|
1921 | return (rc); /* OK */
|
---|
1922 | }
|
---|
1923 |
|
---|
1924 |
|
---|
1925 | /*****************************************************************************
|
---|
1926 | * Name : static APIRET ConsoleInputEventPushFocus
|
---|
1927 | * Purpose : push focus event into the queue
|
---|
1928 | * Parameters: BOOL bSetFocus
|
---|
1929 | * Variables :
|
---|
1930 | * Result : API returncode
|
---|
1931 | * Remark :
|
---|
1932 | * Status :
|
---|
1933 | *
|
---|
1934 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
1935 | *****************************************************************************/
|
---|
1936 |
|
---|
1937 | APIRET iConsoleInputEventPushFocus(BOOL bSetFocus)
|
---|
1938 | {
|
---|
1939 | INPUT_RECORD InputRecord; /* the input record structure */
|
---|
1940 | APIRET rc; /* API-returncode */
|
---|
1941 |
|
---|
1942 | /* @@@PH this is unknown to me - there's no separate bit for menu events ? */
|
---|
1943 | /* do we have to process window input ? */
|
---|
1944 | if ( !(ConsoleInput.dwConsoleMode & ENABLE_WINDOW_INPUT))
|
---|
1945 | return (NO_ERROR); /* return immediately */
|
---|
1946 |
|
---|
1947 | dprintf2(("KERNEL32/CONSOLE:ConsoleInputEventPushFocus(%08x).\n",
|
---|
1948 | bSetFocus));
|
---|
1949 |
|
---|
1950 | InputRecord.EventType = FOCUS_EVENT; /* fill event structure */
|
---|
1951 |
|
---|
1952 | InputRecord.Event.FocusEvent.bSetFocus = bSetFocus;
|
---|
1953 |
|
---|
1954 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
---|
1955 | return (rc); /* OK */
|
---|
1956 | }
|
---|
1957 |
|
---|
1958 |
|
---|
1959 | /*****************************************************************************
|
---|
1960 | * Name : static ULONG ConsoleInputQueueEvents
|
---|
1961 | * Purpose : query number of events in the queue
|
---|
1962 | * Parameters:
|
---|
1963 | * Variables :
|
---|
1964 | * Result : number of events
|
---|
1965 | * Remark :
|
---|
1966 | * Status :
|
---|
1967 | *
|
---|
1968 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
1969 | *****************************************************************************/
|
---|
1970 |
|
---|
1971 | ULONG iConsoleInputQueryEvents(PICONSOLEINPUT pConsoleInput, int fWait)
|
---|
1972 | {
|
---|
1973 | ULONG ulPostCounter; /* semaphore post counter - ignored */
|
---|
1974 | APIRET rc; /* API returncode */
|
---|
1975 |
|
---|
1976 | if(flVioConsole)
|
---|
1977 | {
|
---|
1978 | KBDKEYINFO keyinfo;
|
---|
1979 |
|
---|
1980 | rc = KbdCharIn(&keyinfo, IO_NOWAIT, 0); //grab key if present; don't wait
|
---|
1981 | if((rc || !(keyinfo.fbStatus & 0x40)) && fWait == QUERY_EVENT_WAIT && ConsoleInput.ulEvents == 0) {
|
---|
1982 | rc = KbdCharIn(&keyinfo, IO_WAIT, 0);
|
---|
1983 | }
|
---|
1984 | while(rc == 0 && (keyinfo.fbStatus & 0x40))
|
---|
1985 | {
|
---|
1986 | INPUT_RECORD InputRecord = {0};
|
---|
1987 |
|
---|
1988 | InputRecord.EventType = KEY_EVENT;
|
---|
1989 | InputRecord.Event.KeyEvent.wRepeatCount = 1;
|
---|
1990 | InputRecord.Event.KeyEvent.bKeyDown = 1;
|
---|
1991 | InputRecord.Event.KeyEvent.dwControlKeyState = 0;
|
---|
1992 |
|
---|
1993 | if(keyinfo.fbStatus & 2)
|
---|
1994 | InputRecord.Event.KeyEvent.dwControlKeyState |= ENHANCED_KEY;
|
---|
1995 |
|
---|
1996 | if(keyinfo.fsState & (KBDSTF_RIGHTSHIFT|KBDSTF_LEFTSHIFT))
|
---|
1997 | InputRecord.Event.KeyEvent.dwControlKeyState |= SHIFT_PRESSED;
|
---|
1998 |
|
---|
1999 | if(keyinfo.fsState & KBDSTF_LEFTALT)
|
---|
2000 | InputRecord.Event.KeyEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
|
---|
2001 |
|
---|
2002 | if(keyinfo.fsState & KBDSTF_RIGHTALT)
|
---|
2003 | InputRecord.Event.KeyEvent.dwControlKeyState |= RIGHT_ALT_PRESSED;
|
---|
2004 |
|
---|
2005 | if(keyinfo.fsState & KBDSTF_LEFTCONTROL)
|
---|
2006 | InputRecord.Event.KeyEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
|
---|
2007 |
|
---|
2008 | if(keyinfo.fsState & KBDSTF_RIGHTCONTROL)
|
---|
2009 | InputRecord.Event.KeyEvent.dwControlKeyState |= RIGHT_CTRL_PRESSED;
|
---|
2010 |
|
---|
2011 | if(keyinfo.fsState & KBDSTF_CAPSLOCK_ON)
|
---|
2012 | InputRecord.Event.KeyEvent.dwControlKeyState |= CAPSLOCK_ON;
|
---|
2013 |
|
---|
2014 | if(keyinfo.fsState & KBDSTF_SCROLLLOCK_ON)
|
---|
2015 | InputRecord.Event.KeyEvent.dwControlKeyState |= SCROLLLOCK_ON;
|
---|
2016 |
|
---|
2017 | if(keyinfo.fsState & KBDSTF_NUMLOCK_ON)
|
---|
2018 | InputRecord.Event.KeyEvent.dwControlKeyState |= NUMLOCK_ON;
|
---|
2019 |
|
---|
2020 | InputRecord.Event.KeyEvent.wVirtualKeyCode = 0;
|
---|
2021 | InputRecord.Event.KeyEvent.wVirtualScanCode = keyinfo.chScan;
|
---|
2022 | InputRecord.Event.KeyEvent.uChar.AsciiChar = keyinfo.chChar;
|
---|
2023 |
|
---|
2024 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
---|
2025 | if(rc) {
|
---|
2026 | dprintf(("WARNING: lost key!!"));
|
---|
2027 | break;
|
---|
2028 | }
|
---|
2029 |
|
---|
2030 | rc = KbdCharIn(&keyinfo, IO_NOWAIT, 0); //grab key if present; don't wait
|
---|
2031 | }
|
---|
2032 | }
|
---|
2033 | else
|
---|
2034 | if(fWait == QUERY_EVENT_WAIT && ConsoleInput.ulEvents == 0)
|
---|
2035 | {
|
---|
2036 | rc = DosWaitEventSem(pConsoleInput->hevInputQueue, /* wait for input */
|
---|
2037 | SEM_INDEFINITE_WAIT);
|
---|
2038 | DosResetEventSem(pConsoleInput->hevInputQueue, /* reset semaphore */
|
---|
2039 | &ulPostCounter); /* post counter - ignored */
|
---|
2040 | }
|
---|
2041 | return (ConsoleInput.ulEvents); /* return number of events in queue */
|
---|
2042 | }
|
---|
2043 |
|
---|
2044 |
|
---|
2045 | /*****************************************************************************
|
---|
2046 | * Name : static void ConsoleCursorShow
|
---|
2047 | * Purpose : query number of events in the queue
|
---|
2048 | * Parameters:
|
---|
2049 | * Variables :
|
---|
2050 | * Result : number of events
|
---|
2051 | * Remark :
|
---|
2052 | * Status :
|
---|
2053 | *
|
---|
2054 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
2055 | *****************************************************************************/
|
---|
2056 |
|
---|
2057 | void iConsoleCursorShow (PCONSOLEBUFFER pConsoleBuffer,
|
---|
2058 | ULONG ulCursorMode)
|
---|
2059 | {
|
---|
2060 | HPS hps; /* presentation space handle */
|
---|
2061 | RECTL rclCursor; /* the cursor rectangle */
|
---|
2062 | static BOOL fState; /* current cursor state */
|
---|
2063 | RECTL rclWindow; /* current window size */
|
---|
2064 |
|
---|
2065 | dprintf2(("KERNEL32:Console:ConsoleCursorShow(%u)\n",
|
---|
2066 | ulCursorMode));
|
---|
2067 |
|
---|
2068 | if (pConsoleBuffer->CursorInfo.bVisible == FALSE)/* cursor is switched off */
|
---|
2069 | return; /* return immediately */
|
---|
2070 |
|
---|
2071 | switch (ulCursorMode)
|
---|
2072 | {
|
---|
2073 | case CONSOLECURSOR_HIDE:
|
---|
2074 | if (fState == FALSE) /* cursor currently shown ? */
|
---|
2075 | return; /* no, abort immediately */
|
---|
2076 | else
|
---|
2077 | fState = FALSE; /* set to invisible and invert our cursor rect */
|
---|
2078 | break;
|
---|
2079 |
|
---|
2080 | case CONSOLECURSOR_SHOW:
|
---|
2081 | if (fState == TRUE) /* cursor currently shown ? */
|
---|
2082 | return; /* yes,abort immediately */
|
---|
2083 | else
|
---|
2084 | fState = TRUE; /* set to visible and invert our cursor rect */
|
---|
2085 | break;
|
---|
2086 |
|
---|
2087 | case CONSOLECURSOR_BLINK:
|
---|
2088 | fState = !fState; /* let there be on off on off on off on off ... */
|
---|
2089 | break;
|
---|
2090 |
|
---|
2091 | case CONSOLECURSOR_OVERWRITTEN: /* our cursor has been overwritten */
|
---|
2092 | fState = TRUE; /* so show the cursor immediately */
|
---|
2093 | break;
|
---|
2094 | }
|
---|
2095 |
|
---|
2096 |
|
---|
2097 | /* query current window's size */
|
---|
2098 | WinQueryWindowRect(ConsoleGlobals.hwndClient,
|
---|
2099 | &rclWindow);
|
---|
2100 |
|
---|
2101 | /* calculate coordinates of the cursor */
|
---|
2102 | rclCursor.xLeft = ConsoleGlobals.sCellCX * pConsoleBuffer->coordCursorPosition.X;
|
---|
2103 | rclCursor.xRight = rclCursor.xLeft + ConsoleGlobals.sCellCX;
|
---|
2104 |
|
---|
2105 | //@@@PH top calculation is wrong!
|
---|
2106 | rclCursor.yBottom = rclWindow.yTop
|
---|
2107 | - ConsoleGlobals.sCellCY * (pConsoleBuffer->coordCursorPosition.Y + 1);
|
---|
2108 | rclCursor.yTop = rclCursor.yBottom + /* cursor height in percent */
|
---|
2109 | (ConsoleGlobals.sCellCY *
|
---|
2110 | pConsoleBuffer->CursorInfo.dwSize /
|
---|
2111 | 100);
|
---|
2112 |
|
---|
2113 | hps = WinGetPS(ConsoleGlobals.hwndClient); /* get HPS */
|
---|
2114 |
|
---|
2115 | /* @@@PH invert coordinates here ... */
|
---|
2116 | WinInvertRect(hps, /* our cursor is an inverted rectangle */
|
---|
2117 | &rclCursor);
|
---|
2118 |
|
---|
2119 | WinReleasePS(hps); /* release the hps again */
|
---|
2120 | }
|
---|
2121 |
|
---|
2122 |
|
---|
2123 | /*****************************************************************************
|
---|
2124 | * Name : static APIRET ConsoleFontQuery
|
---|
2125 | * Purpose : queries the current font cell sizes
|
---|
2126 | * Parameters:
|
---|
2127 | * Variables :
|
---|
2128 | * Result : API returncode
|
---|
2129 | * Remark :
|
---|
2130 | * Status :
|
---|
2131 | *
|
---|
2132 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
---|
2133 | *****************************************************************************/
|
---|
2134 |
|
---|
2135 | APIRET iConsoleFontQuery (void)
|
---|
2136 | {
|
---|
2137 | return(VioGetDeviceCellSize(&ConsoleGlobals.sCellCY, /* query VIO manager */
|
---|
2138 | &ConsoleGlobals.sCellCX,
|
---|
2139 | ConsoleGlobals.hvpsConsole));
|
---|
2140 | }
|
---|
2141 |
|
---|
2142 |
|
---|
2143 | /*****************************************************************************
|
---|
2144 | * Name : static void ConsoleCursorShow
|
---|
2145 | * Purpose : query number of events in the queue
|
---|
2146 | * Parameters:
|
---|
2147 | * Variables :
|
---|
2148 | * Result : number of events
|
---|
2149 | * Remark : called during INIT, FONTCHANGE, RESIZE, BUFFERCHANGE
|
---|
2150 | * Status :
|
---|
2151 | *
|
---|
2152 | * Author : Patrick Haller [Wed, 1998/04/29 16:55]
|
---|
2153 | *****************************************************************************/
|
---|
2154 |
|
---|
2155 | void iConsoleAdjustWindow (PCONSOLEBUFFER pConsoleBuffer)
|
---|
2156 | {
|
---|
2157 | LONG lX, lY; /* temporary long values */
|
---|
2158 | RECTL rcl;
|
---|
2159 | PRECTL pRcl = &rcl;
|
---|
2160 | ULONG flStyle; /* window frame control style */
|
---|
2161 |
|
---|
2162 | BOOL fNeedVertScroll; /* indicates need of scrollbars */
|
---|
2163 | BOOL fNeedHorzScroll;
|
---|
2164 |
|
---|
2165 | LONG lScrollX; /* width and height of scrollbars */
|
---|
2166 | LONG lScrollY;
|
---|
2167 |
|
---|
2168 | /* now calculate actual window size */
|
---|
2169 | lX = ConsoleGlobals.sCellCX * ConsoleGlobals.coordWindowSize.X;
|
---|
2170 | lY = ConsoleGlobals.sCellCY * ConsoleGlobals.coordWindowSize.Y;
|
---|
2171 |
|
---|
2172 | if ( (ConsoleGlobals.sCellCX == 0) || /* prevent division by zero */
|
---|
2173 | (ConsoleGlobals.sCellCY == 0) )
|
---|
2174 | return;
|
---|
2175 |
|
---|
2176 | /* calculate maximum console window size in pixels for the tracking */
|
---|
2177 | ConsoleGlobals.coordMaxWindowPels.X = ConsoleGlobals.sCellCX * pConsoleBuffer->coordWindowSize.X
|
---|
2178 | + WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER) * 2;
|
---|
2179 |
|
---|
2180 | ConsoleGlobals.coordMaxWindowPels.Y = ConsoleGlobals.sCellCY * pConsoleBuffer->coordWindowSize.Y
|
---|
2181 | + WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER) * 2
|
---|
2182 | + WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);
|
---|
2183 |
|
---|
2184 | /***************************/
|
---|
2185 | /* @@@PH broken code below */
|
---|
2186 | /***************************/
|
---|
2187 | return;
|
---|
2188 |
|
---|
2189 | /* add the window border height and width, etc. */
|
---|
2190 | WinQueryWindowRect (ConsoleGlobals.hwndClient,
|
---|
2191 | pRcl);
|
---|
2192 |
|
---|
2193 | /* calculate visible area */
|
---|
2194 | /* calculate real client window rectangle and take care of the scrollbars */
|
---|
2195 | lScrollX = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
|
---|
2196 | lScrollY = WinQuerySysValue(HWND_DESKTOP, SV_CYHSCROLL);
|
---|
2197 | if (ConsoleGlobals.fHasHorzScroll)
|
---|
2198 | {
|
---|
2199 | lY += lScrollY;
|
---|
2200 | ConsoleGlobals.coordMaxWindowPels.Y += lScrollY;
|
---|
2201 | }
|
---|
2202 |
|
---|
2203 | if (ConsoleGlobals.fHasVertScroll)
|
---|
2204 | {
|
---|
2205 | lX += lScrollX;
|
---|
2206 | ConsoleGlobals.coordMaxWindowPels.X += lScrollX;
|
---|
2207 | }
|
---|
2208 |
|
---|
2209 | /* @@@PH might NOT exceed maximum VioPS size ! */
|
---|
2210 | ConsoleGlobals.coordWindowSize.X = (pRcl->xRight - pRcl->xLeft)
|
---|
2211 | / ConsoleGlobals.sCellCX;
|
---|
2212 |
|
---|
2213 | ConsoleGlobals.coordWindowSize.Y = (pRcl->yTop - pRcl->yBottom)
|
---|
2214 | / ConsoleGlobals.sCellCY;
|
---|
2215 |
|
---|
2216 | /* do we have to enable the scrollbars ? */
|
---|
2217 | fNeedHorzScroll = lX < pConsoleBuffer->coordWindowSize.X * ConsoleGlobals.sCellCX;
|
---|
2218 | fNeedVertScroll = lY < pConsoleBuffer->coordWindowSize.Y * ConsoleGlobals.sCellCY;
|
---|
2219 |
|
---|
2220 |
|
---|
2221 | if ( (ConsoleGlobals.fHasVertScroll != fNeedVertScroll) ||
|
---|
2222 | (ConsoleGlobals.fHasHorzScroll != fNeedHorzScroll) )
|
---|
2223 | {
|
---|
2224 | flStyle = WinQueryWindowULong(ConsoleGlobals.hwndFrame,
|
---|
2225 | QWL_STYLE);
|
---|
2226 |
|
---|
2227 | /* now set or remove the controls */
|
---|
2228 | if (ConsoleGlobals.fHasHorzScroll != fNeedHorzScroll)
|
---|
2229 | if (fNeedHorzScroll)
|
---|
2230 | {
|
---|
2231 | flStyle |= FCF_HORZSCROLL;
|
---|
2232 | WinSetParent(ConsoleGlobals.hwndHorzScroll, /* attach control */
|
---|
2233 | ConsoleGlobals.hwndFrame,
|
---|
2234 | FALSE);
|
---|
2235 | }
|
---|
2236 | else
|
---|
2237 | {
|
---|
2238 | flStyle &= ~FCF_HORZSCROLL;
|
---|
2239 | WinSetParent(ConsoleGlobals.hwndHorzScroll, /* detach control */
|
---|
2240 | HWND_OBJECT,
|
---|
2241 | FALSE);
|
---|
2242 | ConsoleGlobals.coordWindowPos.X = 0; /* we can see the whole buffer */
|
---|
2243 | }
|
---|
2244 |
|
---|
2245 | if (ConsoleGlobals.fHasVertScroll != fNeedVertScroll)
|
---|
2246 | if (fNeedVertScroll)
|
---|
2247 | {
|
---|
2248 | flStyle |= FCF_VERTSCROLL;
|
---|
2249 | WinSetParent(ConsoleGlobals.hwndVertScroll, /* attach control */
|
---|
2250 | ConsoleGlobals.hwndFrame,
|
---|
2251 | FALSE);
|
---|
2252 | }
|
---|
2253 | else
|
---|
2254 | {
|
---|
2255 | flStyle &= ~FCF_VERTSCROLL;
|
---|
2256 | WinSetParent(ConsoleGlobals.hwndVertScroll, /* detach control */
|
---|
2257 | HWND_OBJECT,
|
---|
2258 | FALSE);
|
---|
2259 | ConsoleGlobals.coordWindowPos.Y = 0; /* we can see the whole buffer */
|
---|
2260 | }
|
---|
2261 |
|
---|
2262 |
|
---|
2263 | WinSendMsg(ConsoleGlobals.hwndFrame, /* update frame */
|
---|
2264 | WM_UPDATEFRAME,
|
---|
2265 | MPFROMLONG(flStyle),
|
---|
2266 | MPVOID);
|
---|
2267 |
|
---|
2268 | WinInvalidateRect(ConsoleGlobals.hwndFrame, /* redraw frame window */
|
---|
2269 | NULL,
|
---|
2270 | TRUE);
|
---|
2271 |
|
---|
2272 | ConsoleGlobals.fHasVertScroll = fNeedVertScroll; /* update globals */
|
---|
2273 | ConsoleGlobals.fHasHorzScroll = fNeedHorzScroll; /* update globals */
|
---|
2274 | }
|
---|
2275 |
|
---|
2276 |
|
---|
2277 | /* setup the scrollbars and scrollranges */
|
---|
2278 | if (ConsoleGlobals.fHasVertScroll)
|
---|
2279 | {
|
---|
2280 | /* setup vertical scrollbar */
|
---|
2281 | }
|
---|
2282 |
|
---|
2283 |
|
---|
2284 | if (ConsoleGlobals.fHasHorzScroll)
|
---|
2285 | {
|
---|
2286 | /* setup horizonal scrollbar */
|
---|
2287 | }
|
---|
2288 |
|
---|
2289 |
|
---|
2290 | WinCalcFrameRect(ConsoleGlobals.hwndFrame, /* calculate frame rectangle */
|
---|
2291 | pRcl,
|
---|
2292 | FALSE);
|
---|
2293 |
|
---|
2294 | /* @@@PH client may not overlap frame ! */
|
---|
2295 | /* @@@PH write values to TRACKINFO */
|
---|
2296 |
|
---|
2297 | #if 0
|
---|
2298 | /* @@@PH this results in recursion */
|
---|
2299 | WinSetWindowPos (ConsoleGlobals.hwndClient, /* adjust client window size */
|
---|
2300 | ConsoleGlobals.hwndFrame,
|
---|
2301 | 0,
|
---|
2302 | 0,
|
---|
2303 | lX,
|
---|
2304 | lY,
|
---|
2305 | SWP_SIZE);
|
---|
2306 |
|
---|
2307 | WinSetWindowPos (ConsoleGlobals.hwndFrame, /* adjust client window size */
|
---|
2308 | HWND_DESKTOP,
|
---|
2309 | pRcl->xLeft,
|
---|
2310 | pRcl->yBottom,
|
---|
2311 | pRcl->xRight,
|
---|
2312 | pRcl->yTop,
|
---|
2313 | SWP_SIZE);
|
---|
2314 | #endif
|
---|
2315 | }
|
---|
2316 |
|
---|
2317 | extern "C" {
|
---|
2318 |
|
---|
2319 | /*****************************************************************************
|
---|
2320 | * Name : BOOL WIN32API AllocConsole
|
---|
2321 | * Purpose : The AllocConsole function allocates a new console
|
---|
2322 | * for the calling process
|
---|
2323 | * Parameters: VOID
|
---|
2324 | * Variables :
|
---|
2325 | * Result : BOOL: TRUE - function succeeded
|
---|
2326 | * FALSE - function failed. Extended error information
|
---|
2327 | * obtainable via GetLastError
|
---|
2328 | * Remark :
|
---|
2329 | * Status : REWRITTEN UNTESTED
|
---|
2330 | *
|
---|
2331 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2332 | *****************************************************************************/
|
---|
2333 |
|
---|
2334 | BOOL WIN32API AllocConsole(VOID)
|
---|
2335 | {
|
---|
2336 | APIRET rc; /* API returncode */
|
---|
2337 |
|
---|
2338 | dprintf(("KERNEL32/CONSOLE: OS2AllocConsole() called"));
|
---|
2339 |
|
---|
2340 | rc = iConsoleInit(flVioConsole); /* initialize subsystem if required */
|
---|
2341 | if (rc != NO_ERROR) /* check for errors */
|
---|
2342 | {
|
---|
2343 | SetLastError(rc); /* pass thru the error code */
|
---|
2344 | return FALSE; /* signal failure */
|
---|
2345 | }
|
---|
2346 | else
|
---|
2347 | return TRUE; /* Fine ! :) */
|
---|
2348 | }
|
---|
2349 |
|
---|
2350 |
|
---|
2351 | /*****************************************************************************
|
---|
2352 | * Name : HANDLE WIN32API CreateConsoleScreenBuffer
|
---|
2353 | * Purpose : The CreateConsoleScreenBuffer function creates a console
|
---|
2354 | * screen buffer and returns a handle of it.
|
---|
2355 | * Parameters: DWORD dwDesiredAccess - access flag
|
---|
2356 | * DWORD dwShareMode - buffer share more
|
---|
2357 | * PVOID pIgnored - LPSECURITY_ATTRIBUTES -> NT
|
---|
2358 | * DWORD dwFlags - type of buffer to create
|
---|
2359 | * LPVOID lpScreenBufferData - reserved
|
---|
2360 | * Variables :
|
---|
2361 | * Result :
|
---|
2362 | * Remark : a console buffer is a kernel heap object equipped with
|
---|
2363 | * share modes, access rights, etc.
|
---|
2364 | * we can't really map this to OS/2 unless we build a
|
---|
2365 | * console device driver for it ... maybe this turns out to
|
---|
2366 | * be necessary since we've got to handle CONIN$ and CONOUT$, too.
|
---|
2367 | * Status :
|
---|
2368 | *
|
---|
2369 | * Author : Patrick Haller [Tue, 1998/02/10 03:55]
|
---|
2370 | *****************************************************************************/
|
---|
2371 |
|
---|
2372 | HANDLE WIN32API CreateConsoleScreenBuffer(DWORD dwDesiredAccess,
|
---|
2373 | DWORD dwShareMode,
|
---|
2374 | LPVOID lpSecurityAttributes,
|
---|
2375 | DWORD dwFlags,
|
---|
2376 | LPVOID lpScreenBufferData)
|
---|
2377 | {
|
---|
2378 | HANDLE hResult;
|
---|
2379 |
|
---|
2380 | hResult = HMCreateFile("CONBUFFER$", /* create a new buffer handle */
|
---|
2381 | dwDesiredAccess,
|
---|
2382 | dwShareMode,
|
---|
2383 | (LPSECURITY_ATTRIBUTES)lpSecurityAttributes,
|
---|
2384 | 0,
|
---|
2385 | dwFlags,
|
---|
2386 | INVALID_HANDLE_VALUE);
|
---|
2387 |
|
---|
2388 | return hResult;
|
---|
2389 | }
|
---|
2390 |
|
---|
2391 |
|
---|
2392 | /*****************************************************************************
|
---|
2393 | * Name :
|
---|
2394 | * Purpose :
|
---|
2395 | * Parameters:
|
---|
2396 | * Variables :
|
---|
2397 | * Result :
|
---|
2398 | * Remark :
|
---|
2399 | * Status :
|
---|
2400 | *
|
---|
2401 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2402 | *****************************************************************************/
|
---|
2403 |
|
---|
2404 | BOOL WIN32API FillConsoleOutputAttribute(HANDLE hConsoleOutput,
|
---|
2405 | WORD wAttribute,
|
---|
2406 | DWORD nLength,
|
---|
2407 | COORD dwWriteCoord,
|
---|
2408 | LPDWORD lpNumberOfAttrsWritten)
|
---|
2409 | {
|
---|
2410 | BOOL fResult;
|
---|
2411 |
|
---|
2412 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
2413 | DRQ_FILLCONSOLEOUTPUTATTRIBUTE,
|
---|
2414 | (ULONG)wAttribute,
|
---|
2415 | (ULONG)nLength,
|
---|
2416 | COORD2ULONG(dwWriteCoord),
|
---|
2417 | (ULONG)lpNumberOfAttrsWritten);
|
---|
2418 |
|
---|
2419 | return fResult;
|
---|
2420 | }
|
---|
2421 |
|
---|
2422 |
|
---|
2423 | /*****************************************************************************
|
---|
2424 | * Name :
|
---|
2425 | * Purpose :
|
---|
2426 | * Parameters:
|
---|
2427 | * Variables :
|
---|
2428 | * Result :
|
---|
2429 | * Remark :
|
---|
2430 | * Status :
|
---|
2431 | *
|
---|
2432 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2433 | *****************************************************************************/
|
---|
2434 |
|
---|
2435 | BOOL WIN32API FillConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
---|
2436 | UCHAR cCharacter,
|
---|
2437 | DWORD nLength,
|
---|
2438 | COORD dwWriteCoord,
|
---|
2439 | LPDWORD lpNumberOfCharsWritten )
|
---|
2440 | {
|
---|
2441 | BOOL fResult;
|
---|
2442 |
|
---|
2443 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
2444 | DRQ_FILLCONSOLEOUTPUTCHARACTERA,
|
---|
2445 | (ULONG)cCharacter,
|
---|
2446 | (ULONG)nLength,
|
---|
2447 | COORD2ULONG(dwWriteCoord),
|
---|
2448 | (ULONG)lpNumberOfCharsWritten);
|
---|
2449 |
|
---|
2450 | return fResult;
|
---|
2451 | }
|
---|
2452 |
|
---|
2453 |
|
---|
2454 | /*****************************************************************************
|
---|
2455 | * Name :
|
---|
2456 | * Purpose :
|
---|
2457 | * Parameters:
|
---|
2458 | * Variables :
|
---|
2459 | * Result :
|
---|
2460 | * Remark :
|
---|
2461 | * Status :
|
---|
2462 | *
|
---|
2463 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2464 | *****************************************************************************/
|
---|
2465 |
|
---|
2466 | BOOL WIN32API FillConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
---|
2467 | WCHAR cCharacter,
|
---|
2468 | DWORD nLength,
|
---|
2469 | COORD dwWriteCoord,
|
---|
2470 | LPDWORD lpNumberOfCharsWritten )
|
---|
2471 | {
|
---|
2472 | BOOL fResult;
|
---|
2473 |
|
---|
2474 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
2475 | DRQ_FILLCONSOLEOUTPUTCHARACTERW,
|
---|
2476 | (ULONG)cCharacter,
|
---|
2477 | (ULONG)nLength,
|
---|
2478 | COORD2ULONG(dwWriteCoord),
|
---|
2479 | (ULONG)lpNumberOfCharsWritten);
|
---|
2480 |
|
---|
2481 | return fResult;
|
---|
2482 | }
|
---|
2483 |
|
---|
2484 |
|
---|
2485 | /*****************************************************************************
|
---|
2486 | * Name :
|
---|
2487 | * Purpose :
|
---|
2488 | * Parameters:
|
---|
2489 | * Variables :
|
---|
2490 | * Result :
|
---|
2491 | * Remark :
|
---|
2492 | * Status :
|
---|
2493 | *
|
---|
2494 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2495 | *****************************************************************************/
|
---|
2496 |
|
---|
2497 | BOOL WIN32API FlushConsoleInputBuffer( HANDLE hConsoleInput )
|
---|
2498 | {
|
---|
2499 | BOOL fResult;
|
---|
2500 |
|
---|
2501 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
2502 | DRQ_FLUSHCONSOLEINPUTBUFFER,
|
---|
2503 | 0,
|
---|
2504 | 0,
|
---|
2505 | 0,
|
---|
2506 | 0);
|
---|
2507 |
|
---|
2508 | return fResult;
|
---|
2509 | }
|
---|
2510 |
|
---|
2511 |
|
---|
2512 | /*****************************************************************************
|
---|
2513 | * Name : BOOL WIN32API FreeConsole
|
---|
2514 | * Purpose : The FreeConsole function detaches the calling process
|
---|
2515 | * from its console.
|
---|
2516 | * Parameters: VOID
|
---|
2517 | * Variables :
|
---|
2518 | * Result : BOOL: TRUE - function succeeded
|
---|
2519 | * FALSE - function failed. Extended error information
|
---|
2520 | * obtainable via GetLastError
|
---|
2521 | * Remark :
|
---|
2522 | * Status : REWRITTEN UNTESTED
|
---|
2523 | *
|
---|
2524 | * Author : Patrick Haller [Tue, 1998/02/10 03:35]
|
---|
2525 | *****************************************************************************/
|
---|
2526 |
|
---|
2527 | BOOL WIN32API FreeConsole( VOID )
|
---|
2528 | {
|
---|
2529 | APIRET rc; /* API returncode */
|
---|
2530 |
|
---|
2531 | rc = iConsoleTerminate(); /* terminate subsystem if required */
|
---|
2532 | if (rc != NO_ERROR) /* check for errors */
|
---|
2533 | {
|
---|
2534 | SetLastError(rc); /* pass thru the error code */
|
---|
2535 | return FALSE; /* signal failure */
|
---|
2536 | }
|
---|
2537 | else
|
---|
2538 | return TRUE; /* Fine ! :) */
|
---|
2539 |
|
---|
2540 | return TRUE;
|
---|
2541 | }
|
---|
2542 |
|
---|
2543 |
|
---|
2544 | /*****************************************************************************
|
---|
2545 | * Name :
|
---|
2546 | * Purpose :
|
---|
2547 | * Parameters:
|
---|
2548 | * Variables :
|
---|
2549 | * Result :
|
---|
2550 | * Remark :
|
---|
2551 | * Status :
|
---|
2552 | *
|
---|
2553 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2554 | *****************************************************************************/
|
---|
2555 |
|
---|
2556 | UINT WIN32API GetConsoleCP(VOID)
|
---|
2557 | {
|
---|
2558 | dprintf(("KERNEL32/CONSOLE: GetConsoleCP not implemented"));
|
---|
2559 |
|
---|
2560 | return 1;
|
---|
2561 | }
|
---|
2562 |
|
---|
2563 |
|
---|
2564 | /*****************************************************************************
|
---|
2565 | * Name :
|
---|
2566 | * Purpose :
|
---|
2567 | * Parameters:
|
---|
2568 | * Variables :
|
---|
2569 | * Result :
|
---|
2570 | * Remark :
|
---|
2571 | * Status :
|
---|
2572 | *
|
---|
2573 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2574 | *****************************************************************************/
|
---|
2575 |
|
---|
2576 | BOOL WIN32API GetConsoleCursorInfo(HANDLE hConsoleOutput,
|
---|
2577 | PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
|
---|
2578 | {
|
---|
2579 | BOOL fResult;
|
---|
2580 |
|
---|
2581 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
2582 | DRQ_GETCONSOLECURSORINFO,
|
---|
2583 | (ULONG)lpConsoleCursorInfo,
|
---|
2584 | 0,
|
---|
2585 | 0,
|
---|
2586 | 0);
|
---|
2587 |
|
---|
2588 | return fResult;
|
---|
2589 | }
|
---|
2590 |
|
---|
2591 |
|
---|
2592 | /*****************************************************************************
|
---|
2593 | * Name :
|
---|
2594 | * Purpose :
|
---|
2595 | * Parameters:
|
---|
2596 | * Variables :
|
---|
2597 | * Result :
|
---|
2598 | * Remark :
|
---|
2599 | * Status :
|
---|
2600 | *
|
---|
2601 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2602 | *****************************************************************************/
|
---|
2603 |
|
---|
2604 | BOOL WIN32API GetConsoleMode(HANDLE hConsole,
|
---|
2605 | LPDWORD lpMode)
|
---|
2606 | {
|
---|
2607 | BOOL fResult;
|
---|
2608 |
|
---|
2609 | fResult = (BOOL)HMDeviceRequest(hConsole,
|
---|
2610 | DRQ_GETCONSOLEMODE,
|
---|
2611 | (ULONG) lpMode,
|
---|
2612 | 0,
|
---|
2613 | 0,
|
---|
2614 | 0);
|
---|
2615 |
|
---|
2616 | return fResult;
|
---|
2617 | }
|
---|
2618 |
|
---|
2619 |
|
---|
2620 | /*****************************************************************************
|
---|
2621 | * Name :
|
---|
2622 | * Purpose :
|
---|
2623 | * Parameters:
|
---|
2624 | * Variables :
|
---|
2625 | * Result :
|
---|
2626 | * Remark :
|
---|
2627 | * Status :
|
---|
2628 | *
|
---|
2629 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2630 | *****************************************************************************/
|
---|
2631 |
|
---|
2632 | UINT WIN32API GetConsoleOutputCP(VOID)
|
---|
2633 | {
|
---|
2634 | dprintf(("KERNEL32/CONSOLE: GetConsoleOutputCP not implemented"));
|
---|
2635 |
|
---|
2636 | return 1;
|
---|
2637 | }
|
---|
2638 |
|
---|
2639 |
|
---|
2640 | /*****************************************************************************
|
---|
2641 | * Name :
|
---|
2642 | * Purpose :
|
---|
2643 | * Parameters:
|
---|
2644 | * Variables :
|
---|
2645 | * Result :
|
---|
2646 | * Remark :
|
---|
2647 | * Status :
|
---|
2648 | *
|
---|
2649 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2650 | *****************************************************************************/
|
---|
2651 |
|
---|
2652 | BOOL WIN32API GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
|
---|
2653 | PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
|
---|
2654 | {
|
---|
2655 | BOOL fResult;
|
---|
2656 |
|
---|
2657 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
2658 | DRQ_GETCONSOLESCREENBUFFERINFO,
|
---|
2659 | (ULONG)lpConsoleScreenBufferInfo,
|
---|
2660 | 0,
|
---|
2661 | 0,
|
---|
2662 | 0);
|
---|
2663 |
|
---|
2664 | return fResult;
|
---|
2665 | }
|
---|
2666 |
|
---|
2667 |
|
---|
2668 | /*****************************************************************************
|
---|
2669 | * Name : DWORD WIN32API GetConsoleTitle
|
---|
2670 | * Purpose : Query the current console window title
|
---|
2671 | * Parameters: LPTSTR lpConsoleTitle
|
---|
2672 | * DWORD nSize
|
---|
2673 | * Variables :
|
---|
2674 | * Result : number of copied bytes
|
---|
2675 | * Remark :
|
---|
2676 | * Status : REWRITTEN UNTESTED
|
---|
2677 | *
|
---|
2678 | * Author : Patrick Haller [Thu, 1998/02/12 23:31]
|
---|
2679 | *****************************************************************************/
|
---|
2680 |
|
---|
2681 | DWORD WIN32API GetConsoleTitleA(LPTSTR lpConsoleTitle,
|
---|
2682 | DWORD nSize)
|
---|
2683 | {
|
---|
2684 | ULONG ulLength; /* length of text */
|
---|
2685 |
|
---|
2686 | if (ConsoleGlobals.pszWindowTitle == NULL) /* is there a window title ? */
|
---|
2687 | return 0; /* abort immediately */
|
---|
2688 |
|
---|
2689 | ulLength = strlen(ConsoleGlobals.pszWindowTitle); /* length of text */
|
---|
2690 |
|
---|
2691 | strncpy(lpConsoleTitle,
|
---|
2692 | ConsoleGlobals.pszWindowTitle,
|
---|
2693 | nSize);
|
---|
2694 | lpConsoleTitle[nSize-1] = 0;
|
---|
2695 |
|
---|
2696 | return (nSize < ulLength) ? nSize : ulLength;
|
---|
2697 | }
|
---|
2698 |
|
---|
2699 |
|
---|
2700 | /*****************************************************************************
|
---|
2701 | * Name : DWORD WIN32API GetConsoleTitle
|
---|
2702 | * Purpose : Query the current console window title
|
---|
2703 | * Parameters: LPTSTR lpConsoleTitle
|
---|
2704 | * DWORD nSize
|
---|
2705 | * Variables :
|
---|
2706 | * Result : number of copied bytes
|
---|
2707 | * Remark :
|
---|
2708 | * Status : REWRITTEN UNTESTED
|
---|
2709 | *
|
---|
2710 | * Author : Patrick Haller [Thu, 1998/02/12 23:31]
|
---|
2711 | *****************************************************************************/
|
---|
2712 |
|
---|
2713 |
|
---|
2714 | DWORD WIN32API GetConsoleTitleW(LPWSTR lpConsoleTitle,
|
---|
2715 | DWORD nSize)
|
---|
2716 | {
|
---|
2717 | if (ConsoleGlobals.pszWindowTitle == NULL) /* is there a window title ? */
|
---|
2718 | return 0; /* abort immediately */
|
---|
2719 |
|
---|
2720 | MultiByteToWideChar( GetConsoleCP(), 0, ConsoleGlobals.pszWindowTitle, -1,
|
---|
2721 | lpConsoleTitle, nSize );
|
---|
2722 | lpConsoleTitle[ nSize - 1 ] = 0;
|
---|
2723 |
|
---|
2724 | return lstrlenW( lpConsoleTitle );
|
---|
2725 | }
|
---|
2726 |
|
---|
2727 |
|
---|
2728 | /*****************************************************************************
|
---|
2729 | * Name : COORD WIN32API GetLargestConsoleWindowSize
|
---|
2730 | * Purpose : Determine maximum AVIO size
|
---|
2731 | * Parameters:
|
---|
2732 | * Variables :
|
---|
2733 | * Result :
|
---|
2734 | * Remark :
|
---|
2735 | * Status :
|
---|
2736 | *
|
---|
2737 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2738 | *****************************************************************************/
|
---|
2739 |
|
---|
2740 | COORD WIN32API GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
|
---|
2741 | {
|
---|
2742 | DWORD dwResult;
|
---|
2743 | COORD coordResult;
|
---|
2744 |
|
---|
2745 | dwResult = HMDeviceRequest(hConsoleOutput,
|
---|
2746 | DRQ_GETLARGESTCONSOLEWINDOWSIZE,
|
---|
2747 | 0,
|
---|
2748 | 0,
|
---|
2749 | 0,
|
---|
2750 | 0);
|
---|
2751 |
|
---|
2752 | ULONG2COORD(coordResult,dwResult)
|
---|
2753 | return ( coordResult );
|
---|
2754 | }
|
---|
2755 |
|
---|
2756 |
|
---|
2757 | /*****************************************************************************
|
---|
2758 | * Name :
|
---|
2759 | * Purpose :
|
---|
2760 | * Parameters:
|
---|
2761 | * Variables :
|
---|
2762 | * Result :
|
---|
2763 | * Remark :
|
---|
2764 | * Status :
|
---|
2765 | *
|
---|
2766 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2767 | *****************************************************************************/
|
---|
2768 |
|
---|
2769 | BOOL WIN32API GetNumberOfConsoleInputEvents(HANDLE hConsoleInput,
|
---|
2770 | LPDWORD lpNumberOfEvents)
|
---|
2771 | {
|
---|
2772 | BOOL fResult;
|
---|
2773 |
|
---|
2774 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
2775 | DRQ_GETNUMBEROFCONSOLEINPUTEVENTS,
|
---|
2776 | (ULONG)lpNumberOfEvents,
|
---|
2777 | 0,
|
---|
2778 | 0,
|
---|
2779 | 0);
|
---|
2780 |
|
---|
2781 | return fResult;
|
---|
2782 | }
|
---|
2783 |
|
---|
2784 |
|
---|
2785 | /*****************************************************************************
|
---|
2786 | * Name :
|
---|
2787 | * Purpose :
|
---|
2788 | * Parameters:
|
---|
2789 | * Variables :
|
---|
2790 | * Result :
|
---|
2791 | * Remark :
|
---|
2792 | * Status :
|
---|
2793 | *
|
---|
2794 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2795 | *****************************************************************************/
|
---|
2796 |
|
---|
2797 | BOOL WIN32API GetNumberOfConsoleMouseButtons(LPDWORD lpcNumberOfMouseButtons)
|
---|
2798 | {
|
---|
2799 | LONG lMouseButtons;
|
---|
2800 |
|
---|
2801 | lMouseButtons = WinQuerySysValue(HWND_DESKTOP, /* query PM for that */
|
---|
2802 | SV_CMOUSEBUTTONS);
|
---|
2803 |
|
---|
2804 | *lpcNumberOfMouseButtons = (DWORD)lMouseButtons;
|
---|
2805 |
|
---|
2806 | return TRUE;
|
---|
2807 | }
|
---|
2808 |
|
---|
2809 |
|
---|
2810 | /*****************************************************************************
|
---|
2811 | * Name :
|
---|
2812 | * Purpose :
|
---|
2813 | * Parameters:
|
---|
2814 | * Variables :
|
---|
2815 | * Result :
|
---|
2816 | * Remark :
|
---|
2817 | * Status :
|
---|
2818 | *
|
---|
2819 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2820 | *****************************************************************************/
|
---|
2821 |
|
---|
2822 | BOOL WIN32API PeekConsoleInputW(HANDLE hConsoleInput,
|
---|
2823 | PINPUT_RECORD pirBuffer,
|
---|
2824 | DWORD cInRecords,
|
---|
2825 | LPDWORD lpcRead)
|
---|
2826 | {
|
---|
2827 | BOOL fResult;
|
---|
2828 |
|
---|
2829 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
2830 | DRQ_PEEKCONSOLEINPUTW,
|
---|
2831 | (ULONG)pirBuffer,
|
---|
2832 | (ULONG)cInRecords,
|
---|
2833 | (ULONG)lpcRead,
|
---|
2834 | 0);
|
---|
2835 |
|
---|
2836 | return fResult;
|
---|
2837 | }
|
---|
2838 |
|
---|
2839 |
|
---|
2840 | /*****************************************************************************
|
---|
2841 | * Name :
|
---|
2842 | * Purpose :
|
---|
2843 | * Parameters:
|
---|
2844 | * Variables :
|
---|
2845 | * Result :
|
---|
2846 | * Remark :
|
---|
2847 | * Status :
|
---|
2848 | *
|
---|
2849 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2850 | *****************************************************************************/
|
---|
2851 |
|
---|
2852 | BOOL WIN32API PeekConsoleInputA(HANDLE hConsoleInput,
|
---|
2853 | PINPUT_RECORD pirBuffer,
|
---|
2854 | DWORD cInRecords,
|
---|
2855 | LPDWORD lpcRead)
|
---|
2856 | {
|
---|
2857 | BOOL fResult;
|
---|
2858 |
|
---|
2859 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
2860 | DRQ_PEEKCONSOLEINPUTA,
|
---|
2861 | (ULONG)pirBuffer,
|
---|
2862 | (ULONG)cInRecords,
|
---|
2863 | (ULONG)lpcRead,
|
---|
2864 | 0);
|
---|
2865 |
|
---|
2866 | return fResult;
|
---|
2867 | }
|
---|
2868 |
|
---|
2869 |
|
---|
2870 | /*****************************************************************************
|
---|
2871 | * Name :
|
---|
2872 | * Purpose :
|
---|
2873 | * Parameters:
|
---|
2874 | * Variables :
|
---|
2875 | * Result :
|
---|
2876 | * Remark :
|
---|
2877 | * Status :
|
---|
2878 | *
|
---|
2879 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2880 | *****************************************************************************/
|
---|
2881 |
|
---|
2882 | BOOL WIN32API ReadConsoleA(HANDLE hConsoleInput,
|
---|
2883 | LPVOID lpvBuffer,
|
---|
2884 | DWORD cchToRead,
|
---|
2885 | LPDWORD lpcchRead,
|
---|
2886 | LPVOID lpvReserved)
|
---|
2887 | {
|
---|
2888 | BOOL fResult;
|
---|
2889 |
|
---|
2890 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
2891 | DRQ_READCONSOLEA,
|
---|
2892 | (ULONG)lpvBuffer,
|
---|
2893 | (ULONG)cchToRead,
|
---|
2894 | (ULONG)lpcchRead,
|
---|
2895 | (ULONG)lpvReserved);
|
---|
2896 |
|
---|
2897 | return fResult;
|
---|
2898 | }
|
---|
2899 |
|
---|
2900 |
|
---|
2901 | /*****************************************************************************
|
---|
2902 | * Name :
|
---|
2903 | * Purpose :
|
---|
2904 | * Parameters:
|
---|
2905 | * Variables :
|
---|
2906 | * Result :
|
---|
2907 | * Remark :
|
---|
2908 | * Status :
|
---|
2909 | *
|
---|
2910 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2911 | *****************************************************************************/
|
---|
2912 |
|
---|
2913 | BOOL WIN32API ReadConsoleW(HANDLE hConsoleInput,
|
---|
2914 | LPVOID lpvBuffer,
|
---|
2915 | DWORD cchToRead,
|
---|
2916 | LPDWORD lpcchRead,
|
---|
2917 | LPVOID lpvReserved)
|
---|
2918 | {
|
---|
2919 | BOOL fResult;
|
---|
2920 |
|
---|
2921 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
2922 | DRQ_READCONSOLEW,
|
---|
2923 | (ULONG)lpvBuffer,
|
---|
2924 | (ULONG)cchToRead,
|
---|
2925 | (ULONG)lpcchRead,
|
---|
2926 | (ULONG)lpvReserved);
|
---|
2927 |
|
---|
2928 | return fResult;
|
---|
2929 | }
|
---|
2930 |
|
---|
2931 |
|
---|
2932 | /*****************************************************************************
|
---|
2933 | * Name :
|
---|
2934 | * Purpose :
|
---|
2935 | * Parameters:
|
---|
2936 | * Variables :
|
---|
2937 | * Result :
|
---|
2938 | * Remark :
|
---|
2939 | * Status :
|
---|
2940 | *
|
---|
2941 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2942 | *****************************************************************************/
|
---|
2943 |
|
---|
2944 | BOOL WIN32API ReadConsoleInputA(HANDLE hConsoleInput,
|
---|
2945 | PINPUT_RECORD pirBuffer,
|
---|
2946 | DWORD cInRecords,
|
---|
2947 | LPDWORD lpcRead)
|
---|
2948 | {
|
---|
2949 | BOOL fResult;
|
---|
2950 |
|
---|
2951 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
2952 | DRQ_READCONSOLEINPUTA,
|
---|
2953 | (ULONG)pirBuffer,
|
---|
2954 | (ULONG)cInRecords,
|
---|
2955 | (ULONG)lpcRead,
|
---|
2956 | 0);
|
---|
2957 |
|
---|
2958 | return fResult;
|
---|
2959 | }
|
---|
2960 |
|
---|
2961 |
|
---|
2962 | /*****************************************************************************
|
---|
2963 | * Name :
|
---|
2964 | * Purpose :
|
---|
2965 | * Parameters:
|
---|
2966 | * Variables :
|
---|
2967 | * Result :
|
---|
2968 | * Remark :
|
---|
2969 | * Status :
|
---|
2970 | *
|
---|
2971 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
2972 | *****************************************************************************/
|
---|
2973 |
|
---|
2974 | BOOL WIN32API ReadConsoleInputW(HANDLE hConsoleInput,
|
---|
2975 | PINPUT_RECORD pirBuffer,
|
---|
2976 | DWORD cInRecords,
|
---|
2977 | LPDWORD lpcRead)
|
---|
2978 | {
|
---|
2979 | BOOL fResult;
|
---|
2980 |
|
---|
2981 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
2982 | DRQ_READCONSOLEINPUTW,
|
---|
2983 | (ULONG)pirBuffer,
|
---|
2984 | (ULONG)cInRecords,
|
---|
2985 | (ULONG)lpcRead,
|
---|
2986 | 0);
|
---|
2987 |
|
---|
2988 | return fResult;
|
---|
2989 | }
|
---|
2990 |
|
---|
2991 |
|
---|
2992 | /*****************************************************************************
|
---|
2993 | * Name :
|
---|
2994 | * Purpose :
|
---|
2995 | * Parameters:
|
---|
2996 | * Variables :
|
---|
2997 | * Result :
|
---|
2998 | * Remark :
|
---|
2999 | * Status :
|
---|
3000 | *
|
---|
3001 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3002 | *****************************************************************************/
|
---|
3003 |
|
---|
3004 | BOOL WIN32API ReadConsoleOutputA(HANDLE hConsoleOutput,
|
---|
3005 | PCHAR_INFO pchiDestBuffer,
|
---|
3006 | COORD coordDestBufferSize,
|
---|
3007 | COORD coordDestBufferCoord,
|
---|
3008 | PSMALL_RECT psrctSourceRect)
|
---|
3009 | {
|
---|
3010 | BOOL fResult;
|
---|
3011 |
|
---|
3012 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3013 | DRQ_READCONSOLEOUTPUTA,
|
---|
3014 | (ULONG)pchiDestBuffer,
|
---|
3015 | COORD2ULONG(coordDestBufferSize),
|
---|
3016 | COORD2ULONG(coordDestBufferCoord),
|
---|
3017 | (ULONG)psrctSourceRect);
|
---|
3018 |
|
---|
3019 | return fResult;
|
---|
3020 | }
|
---|
3021 |
|
---|
3022 |
|
---|
3023 | /*****************************************************************************
|
---|
3024 | * Name :
|
---|
3025 | * Purpose :
|
---|
3026 | * Parameters:
|
---|
3027 | * Variables :
|
---|
3028 | * Result :
|
---|
3029 | * Remark :
|
---|
3030 | * Status :
|
---|
3031 | *
|
---|
3032 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3033 | *****************************************************************************/
|
---|
3034 |
|
---|
3035 | BOOL WIN32API ReadConsoleOutputW(HANDLE hConsoleOutput,
|
---|
3036 | PCHAR_INFO pchiDestBuffer,
|
---|
3037 | COORD coordDestBufferSize,
|
---|
3038 | COORD coordDestBufferCoord,
|
---|
3039 | PSMALL_RECT psrctSourceRect)
|
---|
3040 | {
|
---|
3041 | BOOL fResult;
|
---|
3042 |
|
---|
3043 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3044 | DRQ_READCONSOLEOUTPUTW,
|
---|
3045 | (ULONG)pchiDestBuffer,
|
---|
3046 | COORD2ULONG(coordDestBufferSize),
|
---|
3047 | COORD2ULONG(coordDestBufferCoord),
|
---|
3048 | (ULONG)psrctSourceRect);
|
---|
3049 |
|
---|
3050 | return fResult;
|
---|
3051 | }
|
---|
3052 |
|
---|
3053 |
|
---|
3054 | /*****************************************************************************
|
---|
3055 | * Name :
|
---|
3056 | * Purpose :
|
---|
3057 | * Parameters:
|
---|
3058 | * Variables :
|
---|
3059 | * Result :
|
---|
3060 | * Remark :
|
---|
3061 | * Status :
|
---|
3062 | *
|
---|
3063 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3064 | *****************************************************************************/
|
---|
3065 |
|
---|
3066 | BOOL WIN32API ReadConsoleOutputAttribute(HANDLE hConsoleOutput,
|
---|
3067 | LPWORD lpwAttribute,
|
---|
3068 | DWORD cReadCells,
|
---|
3069 | COORD coordReadCoord,
|
---|
3070 | LPDWORD lpcNumberRead)
|
---|
3071 | {
|
---|
3072 | BOOL fResult;
|
---|
3073 |
|
---|
3074 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3075 | DRQ_READCONSOLEOUTPUTATTRIBUTE,
|
---|
3076 | (ULONG)lpwAttribute,
|
---|
3077 | (ULONG)cReadCells,
|
---|
3078 | COORD2ULONG(coordReadCoord),
|
---|
3079 | (ULONG)lpcNumberRead);
|
---|
3080 |
|
---|
3081 | return fResult;
|
---|
3082 | }
|
---|
3083 |
|
---|
3084 |
|
---|
3085 | /*****************************************************************************
|
---|
3086 | * Name :
|
---|
3087 | * Purpose :
|
---|
3088 | * Parameters:
|
---|
3089 | * Variables :
|
---|
3090 | * Result :
|
---|
3091 | * Remark :
|
---|
3092 | * Status :
|
---|
3093 | *
|
---|
3094 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3095 | *****************************************************************************/
|
---|
3096 |
|
---|
3097 | BOOL WIN32API ReadConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
---|
3098 | LPTSTR lpReadBuffer,
|
---|
3099 | DWORD cchRead,
|
---|
3100 | COORD coordReadCoord,
|
---|
3101 | LPDWORD lpcNumberRead)
|
---|
3102 | {
|
---|
3103 | BOOL fResult;
|
---|
3104 |
|
---|
3105 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3106 | DRQ_READCONSOLEOUTPUTCHARACTERA,
|
---|
3107 | (ULONG)lpReadBuffer,
|
---|
3108 | (ULONG)cchRead,
|
---|
3109 | COORD2ULONG(coordReadCoord),
|
---|
3110 | (ULONG)lpcNumberRead);
|
---|
3111 |
|
---|
3112 | return fResult;
|
---|
3113 | }
|
---|
3114 |
|
---|
3115 |
|
---|
3116 | /*****************************************************************************
|
---|
3117 | * Name :
|
---|
3118 | * Purpose :
|
---|
3119 | * Parameters:
|
---|
3120 | * Variables :
|
---|
3121 | * Result :
|
---|
3122 | * Remark :
|
---|
3123 | * Status :
|
---|
3124 | *
|
---|
3125 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3126 | *****************************************************************************/
|
---|
3127 |
|
---|
3128 | BOOL WIN32API ReadConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
---|
3129 | LPTSTR lpReadBuffer,
|
---|
3130 | DWORD cchRead,
|
---|
3131 | COORD coordReadCoord,
|
---|
3132 | LPDWORD lpcNumberRead)
|
---|
3133 | {
|
---|
3134 | BOOL fResult;
|
---|
3135 |
|
---|
3136 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3137 | DRQ_READCONSOLEOUTPUTCHARACTERW,
|
---|
3138 | (ULONG)lpReadBuffer,
|
---|
3139 | (ULONG)cchRead,
|
---|
3140 | COORD2ULONG(coordReadCoord),
|
---|
3141 | (ULONG)lpcNumberRead);
|
---|
3142 |
|
---|
3143 | return fResult;
|
---|
3144 | }
|
---|
3145 |
|
---|
3146 |
|
---|
3147 | /*****************************************************************************
|
---|
3148 | * Name :
|
---|
3149 | * Purpose :
|
---|
3150 | * Parameters:
|
---|
3151 | * Variables :
|
---|
3152 | * Result :
|
---|
3153 | * Remark :
|
---|
3154 | * Status :
|
---|
3155 | *
|
---|
3156 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3157 | *****************************************************************************/
|
---|
3158 |
|
---|
3159 | BOOL WIN32API ScrollConsoleScreenBufferA(HANDLE hConsoleOutput,
|
---|
3160 | PSMALL_RECT psrctSourceRect,
|
---|
3161 | PSMALL_RECT psrctClipRect,
|
---|
3162 | COORD coordDestOrigin,
|
---|
3163 | PCHAR_INFO pchiFill)
|
---|
3164 | {
|
---|
3165 | BOOL fResult;
|
---|
3166 |
|
---|
3167 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3168 | DRQ_SCROLLCONSOLESCREENBUFFERA,
|
---|
3169 | (ULONG)psrctSourceRect,
|
---|
3170 | (ULONG)psrctClipRect,
|
---|
3171 | COORD2ULONG(coordDestOrigin),
|
---|
3172 | (ULONG)pchiFill);
|
---|
3173 |
|
---|
3174 | return fResult;
|
---|
3175 | }
|
---|
3176 |
|
---|
3177 |
|
---|
3178 | /*****************************************************************************
|
---|
3179 | * Name :
|
---|
3180 | * Purpose :
|
---|
3181 | * Parameters:
|
---|
3182 | * Variables :
|
---|
3183 | * Result :
|
---|
3184 | * Remark :
|
---|
3185 | * Status :
|
---|
3186 | *
|
---|
3187 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3188 | *****************************************************************************/
|
---|
3189 |
|
---|
3190 | BOOL WIN32API ScrollConsoleScreenBufferW(HANDLE hConsoleOutput,
|
---|
3191 | PSMALL_RECT psrctSourceRect,
|
---|
3192 | PSMALL_RECT psrctClipRect,
|
---|
3193 | COORD coordDestOrigin,
|
---|
3194 | PCHAR_INFO pchiFill)
|
---|
3195 | {
|
---|
3196 | BOOL fResult;
|
---|
3197 |
|
---|
3198 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3199 | DRQ_SCROLLCONSOLESCREENBUFFERW,
|
---|
3200 | (ULONG)psrctSourceRect,
|
---|
3201 | (ULONG)psrctClipRect,
|
---|
3202 | COORD2ULONG(coordDestOrigin),
|
---|
3203 | (ULONG)pchiFill);
|
---|
3204 |
|
---|
3205 | return fResult;
|
---|
3206 | }
|
---|
3207 |
|
---|
3208 | /*****************************************************************************
|
---|
3209 | * Name :
|
---|
3210 | * Purpose :
|
---|
3211 | * Parameters:
|
---|
3212 | * Variables :
|
---|
3213 | * Result :
|
---|
3214 | * Remark :
|
---|
3215 | * Status :
|
---|
3216 | *
|
---|
3217 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3218 | *****************************************************************************/
|
---|
3219 |
|
---|
3220 | BOOL WIN32API SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
|
---|
3221 | {
|
---|
3222 | BOOL fResult;
|
---|
3223 |
|
---|
3224 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3225 | DRQ_SETCONSOLEACTIVESCREENBUFFER,
|
---|
3226 | 0,
|
---|
3227 | 0,
|
---|
3228 | 0,
|
---|
3229 | 0);
|
---|
3230 |
|
---|
3231 | return fResult;
|
---|
3232 | }
|
---|
3233 |
|
---|
3234 |
|
---|
3235 | /*****************************************************************************
|
---|
3236 | * Name :
|
---|
3237 | * Purpose :
|
---|
3238 | * Parameters:
|
---|
3239 | * Variables :
|
---|
3240 | * Result :
|
---|
3241 | * Remark :
|
---|
3242 | * Status :
|
---|
3243 | *
|
---|
3244 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3245 | *****************************************************************************/
|
---|
3246 |
|
---|
3247 | BOOL WIN32API SetConsoleCP(UINT IDCodePage)
|
---|
3248 | {
|
---|
3249 | dprintf(("KERNEL32/CONSOLE: SetConsoleCP(%08x) not implemented.\n",
|
---|
3250 | IDCodePage));
|
---|
3251 |
|
---|
3252 | return TRUE;
|
---|
3253 | }
|
---|
3254 |
|
---|
3255 |
|
---|
3256 | /*****************************************************************************
|
---|
3257 | * Name :
|
---|
3258 | * Purpose :
|
---|
3259 | * Parameters:
|
---|
3260 | * Variables :
|
---|
3261 | * Result :
|
---|
3262 | * Remark :
|
---|
3263 | * Status :
|
---|
3264 | *
|
---|
3265 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3266 | *****************************************************************************/
|
---|
3267 |
|
---|
3268 | BOOL WIN32API SetConsoleCursorInfo(HANDLE hConsoleOutput,
|
---|
3269 | PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
|
---|
3270 | {
|
---|
3271 | BOOL fResult;
|
---|
3272 |
|
---|
3273 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3274 | DRQ_SETCONSOLECURSORINFO,
|
---|
3275 | (ULONG)lpConsoleCursorInfo,
|
---|
3276 | 0,
|
---|
3277 | 0,
|
---|
3278 | 0);
|
---|
3279 |
|
---|
3280 | return fResult;
|
---|
3281 | }
|
---|
3282 |
|
---|
3283 |
|
---|
3284 | /*****************************************************************************
|
---|
3285 | * Name :
|
---|
3286 | * Purpose :
|
---|
3287 | * Parameters:
|
---|
3288 | * Variables :
|
---|
3289 | * Result :
|
---|
3290 | * Remark :
|
---|
3291 | * Status :
|
---|
3292 | *
|
---|
3293 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3294 |
|
---|
3295 | *****************************************************************************/
|
---|
3296 |
|
---|
3297 | BOOL WIN32API SetConsoleCursorPosition(HANDLE hConsoleOutput,
|
---|
3298 | COORD coordCursor)
|
---|
3299 | {
|
---|
3300 | BOOL fResult;
|
---|
3301 |
|
---|
3302 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3303 | DRQ_SETCONSOLECURSORPOSITION,
|
---|
3304 | COORD2ULONG(coordCursor),
|
---|
3305 | 0,
|
---|
3306 | 0,
|
---|
3307 | 0);
|
---|
3308 |
|
---|
3309 | return fResult;
|
---|
3310 | }
|
---|
3311 |
|
---|
3312 |
|
---|
3313 | /*****************************************************************************
|
---|
3314 | * Name :
|
---|
3315 | * Purpose :
|
---|
3316 | * Parameters:
|
---|
3317 | * Variables :
|
---|
3318 | * Result :
|
---|
3319 | * Remark :
|
---|
3320 | * Status :
|
---|
3321 | *
|
---|
3322 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3323 | *****************************************************************************/
|
---|
3324 |
|
---|
3325 | BOOL WIN32API SetConsoleMode(HANDLE hConsole,
|
---|
3326 | DWORD fdwMode)
|
---|
3327 | {
|
---|
3328 | BOOL fResult;
|
---|
3329 |
|
---|
3330 | fResult = (BOOL)HMDeviceRequest(hConsole,
|
---|
3331 | DRQ_SETCONSOLEMODE,
|
---|
3332 | (ULONG)fdwMode,
|
---|
3333 | 0,
|
---|
3334 | 0,
|
---|
3335 | 0);
|
---|
3336 |
|
---|
3337 | return fResult;
|
---|
3338 | }
|
---|
3339 |
|
---|
3340 |
|
---|
3341 | /*****************************************************************************
|
---|
3342 | * Name :
|
---|
3343 | * Purpose :
|
---|
3344 | * Parameters:
|
---|
3345 | * Variables :
|
---|
3346 | * Result :
|
---|
3347 | * Remark :
|
---|
3348 | * Status :
|
---|
3349 | *
|
---|
3350 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3351 | *****************************************************************************/
|
---|
3352 |
|
---|
3353 | BOOL WIN32API SetConsoleOutputCP(UINT IDCodePage)
|
---|
3354 | {
|
---|
3355 | dprintf(("KERNEL32/CONSOLE: OS2SetConsoleOutputCP(%08x) not implemented.\n",
|
---|
3356 | IDCodePage));
|
---|
3357 |
|
---|
3358 | return TRUE;
|
---|
3359 | }
|
---|
3360 |
|
---|
3361 |
|
---|
3362 | /*****************************************************************************
|
---|
3363 | * Name :
|
---|
3364 | * Purpose :
|
---|
3365 | * Parameters:
|
---|
3366 | * Variables :
|
---|
3367 | * Result :
|
---|
3368 | * Remark :
|
---|
3369 | * Status :
|
---|
3370 | *
|
---|
3371 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3372 | *****************************************************************************/
|
---|
3373 |
|
---|
3374 | BOOL WIN32API SetConsoleScreenBufferSize(HANDLE hConsoleOutput,
|
---|
3375 | COORD coordSize)
|
---|
3376 | {
|
---|
3377 | BOOL fResult;
|
---|
3378 |
|
---|
3379 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3380 | DRQ_SETCONSOLESCREENBUFFERSIZE,
|
---|
3381 | COORD2ULONG(coordSize),
|
---|
3382 | 0,
|
---|
3383 | 0,
|
---|
3384 | 0);
|
---|
3385 |
|
---|
3386 | return fResult;
|
---|
3387 | }
|
---|
3388 |
|
---|
3389 |
|
---|
3390 | /*****************************************************************************
|
---|
3391 | * Name :
|
---|
3392 | * Purpose :
|
---|
3393 | * Parameters:
|
---|
3394 | * Variables :
|
---|
3395 | * Result :
|
---|
3396 | * Remark :
|
---|
3397 | * Status :
|
---|
3398 | *
|
---|
3399 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3400 | *****************************************************************************/
|
---|
3401 |
|
---|
3402 | BOOL WIN32API SetConsoleTextAttribute(HANDLE hConsoleOutput,
|
---|
3403 | WORD wAttr)
|
---|
3404 | {
|
---|
3405 | BOOL fResult;
|
---|
3406 |
|
---|
3407 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3408 | DRQ_SETCONSOLETEXTATTRIBUTE,
|
---|
3409 | (ULONG)wAttr,
|
---|
3410 | 0,
|
---|
3411 | 0,
|
---|
3412 | 0);
|
---|
3413 |
|
---|
3414 | return fResult;
|
---|
3415 | }
|
---|
3416 |
|
---|
3417 |
|
---|
3418 | /*****************************************************************************
|
---|
3419 | * Name : BOOL WIN32API SetConsoleTitleA
|
---|
3420 | * Purpose : Set new title text for the console window
|
---|
3421 | * Parameters: LPTSTR lpszTitle
|
---|
3422 | * Variables :
|
---|
3423 | * Result :
|
---|
3424 | * Remark :
|
---|
3425 | * Status : REWRITTEN UNTESTED
|
---|
3426 | *
|
---|
3427 | * Author : Patrick Haller [Tue, 1998/02/12 23:28]
|
---|
3428 | *****************************************************************************/
|
---|
3429 |
|
---|
3430 | BOOL WIN32API SetConsoleTitleA(LPTSTR lpszTitle)
|
---|
3431 | {
|
---|
3432 | if (ConsoleGlobals.pszWindowTitle != NULL) /* previously set name */
|
---|
3433 | free (ConsoleGlobals.pszWindowTitle); /* then free it */
|
---|
3434 |
|
---|
3435 | ConsoleGlobals.pszWindowTitle = strdup(lpszTitle); /* copy the new name */
|
---|
3436 |
|
---|
3437 | WinSetWindowText(ConsoleGlobals.hwndFrame, /* set new title text */
|
---|
3438 | ConsoleGlobals.pszWindowTitle);
|
---|
3439 |
|
---|
3440 | return TRUE;
|
---|
3441 | }
|
---|
3442 |
|
---|
3443 |
|
---|
3444 | /*****************************************************************************
|
---|
3445 | * Name : BOOL WIN32API SetConsoleTitleW
|
---|
3446 | * Purpose : Set new title text for the console window
|
---|
3447 | * Parameters: LPTSTR lpszTitle
|
---|
3448 | * Variables :
|
---|
3449 | * Result :
|
---|
3450 | * Remark :
|
---|
3451 | * Status : REWRITTEN UNTESTED
|
---|
3452 | *
|
---|
3453 | * Author : Patrick Haller [Tue, 1998/02/12 23:28]
|
---|
3454 | *****************************************************************************/
|
---|
3455 |
|
---|
3456 | BOOL WIN32API SetConsoleTitleW(LPWSTR lpszTitle)
|
---|
3457 | {
|
---|
3458 | int alen;
|
---|
3459 |
|
---|
3460 | if (lpszTitle == NULL) /* check parameters */
|
---|
3461 | return FALSE;
|
---|
3462 |
|
---|
3463 | if (ConsoleGlobals.pszWindowTitle != NULL) /* previously set name */
|
---|
3464 | free (ConsoleGlobals.pszWindowTitle); /* then free it */
|
---|
3465 |
|
---|
3466 | alen = WideCharToMultiByte( GetConsoleCP(), 0, lpszTitle, -1, 0, 0, 0, 0 );
|
---|
3467 | /* create an ascii copy of the lpszTitle */
|
---|
3468 | ConsoleGlobals.pszWindowTitle = (PSZ)malloc( alen );
|
---|
3469 | WideCharToMultiByte( GetConsoleCP(), 0, lpszTitle, -1,
|
---|
3470 | ConsoleGlobals.pszWindowTitle, alen, 0, 0 );
|
---|
3471 |
|
---|
3472 | WinSetWindowText(ConsoleGlobals.hwndFrame, /* set new title text */
|
---|
3473 | ConsoleGlobals.pszWindowTitle);
|
---|
3474 |
|
---|
3475 | return TRUE;
|
---|
3476 | }
|
---|
3477 |
|
---|
3478 |
|
---|
3479 | /*****************************************************************************
|
---|
3480 | * Name :
|
---|
3481 | * Purpose :
|
---|
3482 | * Parameters:
|
---|
3483 | * Variables :
|
---|
3484 | * Result :
|
---|
3485 | * Remark :
|
---|
3486 | * Status :
|
---|
3487 | *
|
---|
3488 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3489 | *****************************************************************************/
|
---|
3490 |
|
---|
3491 | BOOL WIN32API SetConsoleWindowInfo(HANDLE hConsoleOutput,
|
---|
3492 | BOOL fAbsolute,
|
---|
3493 | PSMALL_RECT psrctWindowRect)
|
---|
3494 | {
|
---|
3495 | BOOL fResult;
|
---|
3496 |
|
---|
3497 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3498 | DRQ_SETCONSOLEWINDOWINFO,
|
---|
3499 | (ULONG)fAbsolute,
|
---|
3500 | (ULONG)psrctWindowRect,
|
---|
3501 | 0,
|
---|
3502 | 0);
|
---|
3503 |
|
---|
3504 | return fResult;
|
---|
3505 | }
|
---|
3506 |
|
---|
3507 |
|
---|
3508 | /*****************************************************************************
|
---|
3509 | * Name :
|
---|
3510 | * Purpose :
|
---|
3511 | * Parameters:
|
---|
3512 | * Variables :
|
---|
3513 | * Result :
|
---|
3514 | * Remark :
|
---|
3515 | * Status :
|
---|
3516 | *
|
---|
3517 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3518 | *****************************************************************************/
|
---|
3519 |
|
---|
3520 | BOOL WIN32API WriteConsoleA(HANDLE hConsoleOutput,
|
---|
3521 | CONST VOID* lpvBuffer,
|
---|
3522 | DWORD cchToWrite,
|
---|
3523 | LPDWORD lpcchWritten,
|
---|
3524 | LPVOID lpvReserved)
|
---|
3525 | {
|
---|
3526 | BOOL fResult;
|
---|
3527 |
|
---|
3528 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3529 | DRQ_WRITECONSOLEA,
|
---|
3530 | (ULONG)lpvBuffer,
|
---|
3531 | (ULONG)cchToWrite,
|
---|
3532 | (ULONG)lpcchWritten,
|
---|
3533 | (ULONG)lpvReserved);
|
---|
3534 |
|
---|
3535 | return fResult;
|
---|
3536 | }
|
---|
3537 |
|
---|
3538 |
|
---|
3539 | /*****************************************************************************
|
---|
3540 | * Name :
|
---|
3541 | * Purpose :
|
---|
3542 | * Parameters:
|
---|
3543 | * Variables :
|
---|
3544 | * Result :
|
---|
3545 | * Remark :
|
---|
3546 | * Status :
|
---|
3547 | *
|
---|
3548 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3549 | *****************************************************************************/
|
---|
3550 |
|
---|
3551 | BOOL WIN32API WriteConsoleW(HANDLE hConsoleOutput,
|
---|
3552 | CONST VOID* lpvBuffer,
|
---|
3553 | DWORD cchToWrite,
|
---|
3554 | LPDWORD lpcchWritten,
|
---|
3555 | LPVOID lpvReserved)
|
---|
3556 | {
|
---|
3557 | BOOL fResult;
|
---|
3558 |
|
---|
3559 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3560 | DRQ_WRITECONSOLEW,
|
---|
3561 | (ULONG)lpvBuffer,
|
---|
3562 | (ULONG)cchToWrite,
|
---|
3563 | (ULONG)lpcchWritten,
|
---|
3564 | (ULONG)lpvReserved);
|
---|
3565 |
|
---|
3566 | return fResult;
|
---|
3567 | }
|
---|
3568 |
|
---|
3569 |
|
---|
3570 | /*****************************************************************************
|
---|
3571 | * Name :
|
---|
3572 | * Purpose :
|
---|
3573 | * Parameters:
|
---|
3574 | * Variables :
|
---|
3575 | * Result :
|
---|
3576 | * Remark :
|
---|
3577 | * Status :
|
---|
3578 | *
|
---|
3579 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3580 | *****************************************************************************/
|
---|
3581 |
|
---|
3582 | BOOL WIN32API WriteConsoleInputA(HANDLE hConsoleInput,
|
---|
3583 | PINPUT_RECORD pirBuffer,
|
---|
3584 | DWORD cInRecords,
|
---|
3585 | LPDWORD lpcWritten)
|
---|
3586 | {
|
---|
3587 | BOOL fResult;
|
---|
3588 |
|
---|
3589 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
3590 | DRQ_WRITECONSOLEINPUTA,
|
---|
3591 | (ULONG)pirBuffer,
|
---|
3592 | (ULONG)cInRecords,
|
---|
3593 | (ULONG)lpcWritten,
|
---|
3594 | 0);
|
---|
3595 |
|
---|
3596 | return fResult;
|
---|
3597 | }
|
---|
3598 |
|
---|
3599 |
|
---|
3600 | /*****************************************************************************
|
---|
3601 | * Name :
|
---|
3602 | * Purpose :
|
---|
3603 | * Parameters:
|
---|
3604 | * Variables :
|
---|
3605 | * Result :
|
---|
3606 | * Remark :
|
---|
3607 | * Status :
|
---|
3608 | *
|
---|
3609 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3610 | *****************************************************************************/
|
---|
3611 |
|
---|
3612 | BOOL WIN32API WriteConsoleInputW(HANDLE hConsoleInput,
|
---|
3613 | PINPUT_RECORD pirBuffer,
|
---|
3614 | DWORD cInRecords,
|
---|
3615 | LPDWORD lpcWritten)
|
---|
3616 | {
|
---|
3617 | BOOL fResult;
|
---|
3618 |
|
---|
3619 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
---|
3620 | DRQ_WRITECONSOLEINPUTW,
|
---|
3621 | (ULONG)pirBuffer,
|
---|
3622 | (ULONG)cInRecords,
|
---|
3623 | (ULONG)lpcWritten,
|
---|
3624 | 0);
|
---|
3625 |
|
---|
3626 | return fResult;
|
---|
3627 | }
|
---|
3628 |
|
---|
3629 |
|
---|
3630 | /*****************************************************************************
|
---|
3631 | * Name :
|
---|
3632 | * Purpose :
|
---|
3633 | * Parameters:
|
---|
3634 | * Variables :
|
---|
3635 | * Result :
|
---|
3636 | * Remark :
|
---|
3637 | * Status :
|
---|
3638 | *
|
---|
3639 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3640 | *****************************************************************************/
|
---|
3641 |
|
---|
3642 | BOOL WIN32API WriteConsoleOutputA(HANDLE hConsoleOutput,
|
---|
3643 | PCHAR_INFO pchiSrcBuffer,
|
---|
3644 | COORD coordSrcBufferSize,
|
---|
3645 | COORD coordSrcBufferCoord,
|
---|
3646 | PSMALL_RECT psrctDestRect)
|
---|
3647 | {
|
---|
3648 | BOOL fResult;
|
---|
3649 |
|
---|
3650 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3651 | DRQ_WRITECONSOLEOUTPUTA,
|
---|
3652 | (ULONG)pchiSrcBuffer,
|
---|
3653 | COORD2ULONG(coordSrcBufferSize),
|
---|
3654 | COORD2ULONG(coordSrcBufferCoord),
|
---|
3655 | (ULONG)psrctDestRect);
|
---|
3656 |
|
---|
3657 | return fResult;
|
---|
3658 | }
|
---|
3659 |
|
---|
3660 |
|
---|
3661 | /*****************************************************************************
|
---|
3662 | * Name :
|
---|
3663 | * Purpose :
|
---|
3664 | * Parameters:
|
---|
3665 | * Variables :
|
---|
3666 | * Result :
|
---|
3667 | * Remark :
|
---|
3668 | * Status :
|
---|
3669 | *
|
---|
3670 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3671 | *****************************************************************************/
|
---|
3672 |
|
---|
3673 | BOOL WIN32API WriteConsoleOutputW(HANDLE hConsoleOutput,
|
---|
3674 | PCHAR_INFO pchiSrcBuffer,
|
---|
3675 | COORD coordSrcBufferSize,
|
---|
3676 | COORD coordSrcBufferCoord,
|
---|
3677 | PSMALL_RECT psrctDestRect)
|
---|
3678 | {
|
---|
3679 | BOOL fResult;
|
---|
3680 |
|
---|
3681 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3682 | DRQ_WRITECONSOLEOUTPUTW,
|
---|
3683 | (ULONG)pchiSrcBuffer,
|
---|
3684 | COORD2ULONG(coordSrcBufferSize),
|
---|
3685 | COORD2ULONG(coordSrcBufferCoord),
|
---|
3686 | (ULONG)psrctDestRect);
|
---|
3687 |
|
---|
3688 | return fResult;
|
---|
3689 | }
|
---|
3690 |
|
---|
3691 | /*****************************************************************************
|
---|
3692 | * Name :
|
---|
3693 | * Purpose :
|
---|
3694 | * Parameters:
|
---|
3695 | * Variables :
|
---|
3696 | * Result :
|
---|
3697 | * Remark :
|
---|
3698 | * Status :
|
---|
3699 | *
|
---|
3700 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3701 | *****************************************************************************/
|
---|
3702 |
|
---|
3703 | BOOL WIN32API WriteConsoleOutputAttribute(HANDLE hConsoleOutput,
|
---|
3704 | LPWORD lpwAttribute,
|
---|
3705 | DWORD cWriteCells,
|
---|
3706 | COORD coordWriteCoord,
|
---|
3707 | LPDWORD lpcNumberWritten)
|
---|
3708 | {
|
---|
3709 | BOOL fResult;
|
---|
3710 |
|
---|
3711 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3712 | DRQ_WRITECONSOLEOUTPUTATTRIBUTE,
|
---|
3713 | (ULONG)lpwAttribute,
|
---|
3714 | (ULONG)cWriteCells,
|
---|
3715 | COORD2ULONG(coordWriteCoord),
|
---|
3716 | (ULONG)lpcNumberWritten);
|
---|
3717 |
|
---|
3718 | return fResult;
|
---|
3719 | }
|
---|
3720 |
|
---|
3721 |
|
---|
3722 | /*****************************************************************************
|
---|
3723 | * Name :
|
---|
3724 | * Purpose :
|
---|
3725 | * Parameters:
|
---|
3726 | * Variables :
|
---|
3727 | * Result :
|
---|
3728 | * Remark :
|
---|
3729 | * Status :
|
---|
3730 | *
|
---|
3731 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3732 | *****************************************************************************/
|
---|
3733 |
|
---|
3734 | BOOL WIN32API WriteConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
---|
3735 | LPTSTR lpWriteBuffer,
|
---|
3736 | DWORD cchWrite,
|
---|
3737 | COORD coordWriteCoord,
|
---|
3738 | LPDWORD lpcWritten)
|
---|
3739 | {
|
---|
3740 | BOOL fResult;
|
---|
3741 |
|
---|
3742 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3743 | DRQ_WRITECONSOLEOUTPUTCHARACTERA,
|
---|
3744 | (ULONG)lpWriteBuffer,
|
---|
3745 | (ULONG)cchWrite,
|
---|
3746 | COORD2ULONG(coordWriteCoord),
|
---|
3747 | (ULONG)lpcWritten);
|
---|
3748 |
|
---|
3749 | return fResult;
|
---|
3750 | }
|
---|
3751 |
|
---|
3752 |
|
---|
3753 | /*****************************************************************************
|
---|
3754 | * Name :
|
---|
3755 | * Purpose :
|
---|
3756 | * Parameters:
|
---|
3757 | * Variables :
|
---|
3758 | * Result :
|
---|
3759 | * Remark :
|
---|
3760 | * Status :
|
---|
3761 | *
|
---|
3762 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
3763 | *****************************************************************************/
|
---|
3764 |
|
---|
3765 | BOOL WIN32API WriteConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
---|
3766 | LPTSTR lpWriteBuffer,
|
---|
3767 | DWORD cchWrite,
|
---|
3768 | COORD coordWriteCoord,
|
---|
3769 | LPDWORD lpcWritten)
|
---|
3770 | {
|
---|
3771 | BOOL fResult;
|
---|
3772 |
|
---|
3773 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
---|
3774 | DRQ_WRITECONSOLEOUTPUTCHARACTERW,
|
---|
3775 | (ULONG)lpWriteBuffer,
|
---|
3776 | (ULONG)cchWrite,
|
---|
3777 | COORD2ULONG(coordWriteCoord),
|
---|
3778 | (ULONG)lpcWritten);
|
---|
3779 |
|
---|
3780 | return fResult;
|
---|
3781 | }
|
---|
3782 |
|
---|
3783 | } // extern "C"
|
---|