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