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