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