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