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

Last change on this file since 3804 was 3804, checked in by sandervl, 25 years ago

strncpy call changes + language api updates/fixes

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