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

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

Add: console properties update

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