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

Last change on this file since 3976 was 3976, checked in by phaller, 25 years ago

.

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