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