source: trunk/src/kernel32/console.cpp@ 296

Last change on this file since 296 was 296, checked in by phaller, 26 years ago

Fix: console input queue fixes

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