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