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

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

Fix: console cursor fixes

File size: 137.5 KB
Line 
1/* $Id: console.cpp,v 1.17 1999-10-27 19:47:39 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
2036 //@@@PH top calculation is wrong!
2037 rclCursor.yBottom = rclWindow.yTop
2038 - ConsoleGlobals.sCellCY * (pConsoleBuffer->coordCursorPosition.Y + 1);
2039 rclCursor.yTop = rclCursor.yBottom + /* cursor height in percent */
2040 (ConsoleGlobals.sCellCY *
2041 pConsoleBuffer->CursorInfo.dwSize /
2042 100);
2043
2044 hps = WinGetPS(ConsoleGlobals.hwndClient); /* get HPS */
2045
2046 /* @@@PH invert coordinates here ... */
2047 WinInvertRect(hps, /* our cursor is an inverted rectangle */
2048 &rclCursor);
2049
2050 WinReleasePS(hps); /* release the hps again */
2051}
2052
2053
2054/*****************************************************************************
2055 * Name : static APIRET ConsoleFontQuery
2056 * Purpose : queries the current font cell sizes
2057 * Parameters:
2058 * Variables :
2059 * Result : API returncode
2060 * Remark :
2061 * Status :
2062 *
2063 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
2064 *****************************************************************************/
2065
2066APIRET iConsoleFontQuery (void)
2067{
2068 return(VioGetDeviceCellSize(&ConsoleGlobals.sCellCY, /* query VIO manager */
2069 &ConsoleGlobals.sCellCX,
2070 ConsoleGlobals.hvpsConsole));
2071}
2072
2073
2074/*****************************************************************************
2075 * Name : static void ConsoleCursorShow
2076 * Purpose : query number of events in the queue
2077 * Parameters:
2078 * Variables :
2079 * Result : number of events
2080 * Remark : called during INIT, FONTCHANGE, RESIZE, BUFFERCHANGE
2081 * Status :
2082 *
2083 * Author : Patrick Haller [Wed, 1998/04/29 16:55]
2084 *****************************************************************************/
2085
2086void iConsoleAdjustWindow (PCONSOLEBUFFER pConsoleBuffer)
2087{
2088 LONG lX, lY; /* temporary long values */
2089 RECTL rcl;
2090 PRECTL pRcl = &rcl;
2091 ULONG flStyle; /* window frame control style */
2092
2093 BOOL fNeedVertScroll; /* indicates need of scrollbars */
2094 BOOL fNeedHorzScroll;
2095
2096 LONG lScrollX; /* width and height of scrollbars */
2097 LONG lScrollY;
2098
2099 /* now calculate actual window size */
2100 lX = ConsoleGlobals.sCellCX * ConsoleGlobals.coordWindowSize.X;
2101 lY = ConsoleGlobals.sCellCY * ConsoleGlobals.coordWindowSize.Y;
2102
2103 if ( (ConsoleGlobals.sCellCX == 0) || /* prevent division by zero */
2104 (ConsoleGlobals.sCellCY == 0) )
2105 return;
2106
2107 /* calculate maximum console window size in pixels for the tracking */
2108 ConsoleGlobals.coordMaxWindowPels.X = ConsoleGlobals.sCellCX * pConsoleBuffer->coordWindowSize.X
2109 + WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER) * 2;
2110
2111 ConsoleGlobals.coordMaxWindowPels.Y = ConsoleGlobals.sCellCY * pConsoleBuffer->coordWindowSize.Y
2112 + WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER) * 2
2113 + WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);
2114
2115 /***************************/
2116 /* @@@PH broken code below */
2117 /***************************/
2118 return;
2119
2120 /* add the window border height and width, etc. */
2121 WinQueryWindowRect (ConsoleGlobals.hwndClient,
2122 pRcl);
2123
2124 /* calculate visible area */
2125 /* calculate real client window rectangle and take care of the scrollbars */
2126 lScrollX = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
2127 lScrollY = WinQuerySysValue(HWND_DESKTOP, SV_CYHSCROLL);
2128 if (ConsoleGlobals.fHasHorzScroll)
2129 {
2130 lY += lScrollY;
2131 ConsoleGlobals.coordMaxWindowPels.Y += lScrollY;
2132 }
2133
2134 if (ConsoleGlobals.fHasVertScroll)
2135 {
2136 lX += lScrollX;
2137 ConsoleGlobals.coordMaxWindowPels.X += lScrollX;
2138 }
2139
2140 /* @@@PH might NOT exceed maximum VioPS size ! */
2141 ConsoleGlobals.coordWindowSize.X = (pRcl->xRight - pRcl->xLeft)
2142 / ConsoleGlobals.sCellCX;
2143
2144 ConsoleGlobals.coordWindowSize.Y = (pRcl->yTop - pRcl->yBottom)
2145 / ConsoleGlobals.sCellCY;
2146
2147 /* do we have to enable the scrollbars ? */
2148 fNeedHorzScroll = lX < pConsoleBuffer->coordWindowSize.X * ConsoleGlobals.sCellCX;
2149 fNeedVertScroll = lY < pConsoleBuffer->coordWindowSize.Y * ConsoleGlobals.sCellCY;
2150
2151
2152 if ( (ConsoleGlobals.fHasVertScroll != fNeedVertScroll) ||
2153 (ConsoleGlobals.fHasHorzScroll != fNeedHorzScroll) )
2154 {
2155 flStyle = WinQueryWindowULong(ConsoleGlobals.hwndFrame,
2156 QWL_STYLE);
2157
2158 /* now set or remove the controls */
2159 if (ConsoleGlobals.fHasHorzScroll != fNeedHorzScroll)
2160 if (fNeedHorzScroll)
2161 {
2162 flStyle |= FCF_HORZSCROLL;
2163 WinSetParent(ConsoleGlobals.hwndHorzScroll, /* attach control */
2164 ConsoleGlobals.hwndFrame,
2165 FALSE);
2166 }
2167 else
2168 {
2169 flStyle &= ~FCF_HORZSCROLL;
2170 WinSetParent(ConsoleGlobals.hwndHorzScroll, /* detach control */
2171 HWND_OBJECT,
2172 FALSE);
2173 ConsoleGlobals.coordWindowPos.X = 0; /* we can see the whole buffer */
2174 }
2175
2176 if (ConsoleGlobals.fHasVertScroll != fNeedVertScroll)
2177 if (fNeedVertScroll)
2178 {
2179 flStyle |= FCF_VERTSCROLL;
2180 WinSetParent(ConsoleGlobals.hwndVertScroll, /* attach control */
2181 ConsoleGlobals.hwndFrame,
2182 FALSE);
2183 }
2184 else
2185 {
2186 flStyle &= ~FCF_VERTSCROLL;
2187 WinSetParent(ConsoleGlobals.hwndVertScroll, /* detach control */
2188 HWND_OBJECT,
2189 FALSE);
2190 ConsoleGlobals.coordWindowPos.Y = 0; /* we can see the whole buffer */
2191 }
2192
2193
2194 WinSendMsg(ConsoleGlobals.hwndFrame, /* update frame */
2195 WM_UPDATEFRAME,
2196 MPFROMLONG(flStyle),
2197 MPVOID);
2198
2199 WinInvalidateRect(ConsoleGlobals.hwndFrame, /* redraw frame window */
2200 NULL,
2201 TRUE);
2202
2203 ConsoleGlobals.fHasVertScroll = fNeedVertScroll; /* update globals */
2204 ConsoleGlobals.fHasHorzScroll = fNeedHorzScroll; /* update globals */
2205 }
2206
2207
2208 /* setup the scrollbars and scrollranges */
2209 if (ConsoleGlobals.fHasVertScroll)
2210 {
2211 /* setup vertical scrollbar */
2212 }
2213
2214
2215 if (ConsoleGlobals.fHasHorzScroll)
2216 {
2217 /* setup horizonal scrollbar */
2218 }
2219
2220
2221 WinCalcFrameRect(ConsoleGlobals.hwndFrame, /* calculate frame rectangle */
2222 pRcl,
2223 FALSE);
2224
2225 /* @@@PH client may not overlap frame ! */
2226 /* @@@PH write values to TRACKINFO */
2227
2228#if 0
2229 /* @@@PH this results in recursion */
2230 WinSetWindowPos (ConsoleGlobals.hwndClient, /* adjust client window size */
2231 ConsoleGlobals.hwndFrame,
2232 0,
2233 0,
2234 lX,
2235 lY,
2236 SWP_SIZE);
2237
2238 WinSetWindowPos (ConsoleGlobals.hwndFrame, /* adjust client window size */
2239 HWND_DESKTOP,
2240 pRcl->xLeft,
2241 pRcl->yBottom,
2242 pRcl->xRight,
2243 pRcl->yTop,
2244 SWP_SIZE);
2245#endif
2246}
2247
2248
2249/*****************************************************************************
2250 * Name : BOOL WIN32API AllocConsole
2251 * Purpose : The AllocConsole function allocates a new console
2252 * for the calling process
2253 * Parameters: VOID
2254 * Variables :
2255 * Result : BOOL: TRUE - function succeeded
2256 * FALSE - function failed. Extended error information
2257 * obtainable via GetLastError
2258 * Remark :
2259 * Status : REWRITTEN UNTESTED
2260 *
2261 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2262 *****************************************************************************/
2263
2264BOOL WIN32API AllocConsole(VOID)
2265{
2266 APIRET rc; /* API returncode */
2267
2268#ifdef DEBUG_LOCAL2
2269 WriteLog("KERNEL32/CONSOLE: OS2AllocConsole() called.\n");
2270#endif
2271
2272 rc = iConsoleInit(); /* initialize subsystem if required */
2273 if (rc != NO_ERROR) /* check for errors */
2274 {
2275 SetLastError(rc); /* pass thru the error code */
2276 return FALSE; /* signal failure */
2277 }
2278 else
2279 return TRUE; /* Fine ! :) */
2280}
2281
2282
2283/*****************************************************************************
2284 * Name : HANDLE WIN32API CreateConsoleScreenBuffer
2285 * Purpose : The CreateConsoleScreenBuffer function creates a console
2286 * screen buffer and returns a handle of it.
2287 * Parameters: DWORD dwDesiredAccess - access flag
2288 * DWORD dwShareMode - buffer share more
2289 * PVOID pIgnored - LPSECURITY_ATTRIBUTES -> NT
2290 * DWORD dwFlags - type of buffer to create
2291 * LPVOID lpScreenBufferData - reserved
2292 * Variables :
2293 * Result :
2294 * Remark : a console buffer is a kernel heap object equipped with
2295 * share modes, access rights, etc.
2296 * we can't really map this to OS/2 unless we build a
2297 * console device driver for it ... maybe this turns out to
2298 * be necessary since we've got to handle CONIN$ and CONOUT$, too.
2299 * Status :
2300 *
2301 * Author : Patrick Haller [Tue, 1998/02/10 03:55]
2302 *****************************************************************************/
2303
2304HANDLE WIN32API CreateConsoleScreenBuffer(DWORD dwDesiredAccess,
2305 DWORD dwShareMode,
2306 LPVOID lpSecurityAttributes,
2307 DWORD dwFlags,
2308 LPVOID lpScreenBufferData)
2309{
2310 HANDLE hResult;
2311
2312#ifdef DEBUG_LOCAL2
2313 WriteLog("KERNEL32/CONSOLE:OS2CreateConsoleScreenBuffer(%08x,%08x,%08x,%08x,%08x).\n",
2314 dwDesiredAccess,
2315 dwShareMode,
2316 lpSecurityAttributes,
2317 dwFlags,
2318 lpScreenBufferData);
2319#endif
2320
2321 hResult = HMCreateFile("CONBUFFER$", /* create a new buffer handle */
2322 dwDesiredAccess,
2323 dwShareMode,
2324 (LPSECURITY_ATTRIBUTES)lpSecurityAttributes,
2325 0,
2326 dwFlags,
2327 INVALID_HANDLE_VALUE);
2328
2329 return hResult;
2330}
2331
2332
2333/*****************************************************************************
2334 * Name :
2335 * Purpose :
2336 * Parameters:
2337 * Variables :
2338 * Result :
2339 * Remark :
2340 * Status :
2341 *
2342 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2343 *****************************************************************************/
2344
2345BOOL WIN32API FillConsoleOutputAttribute(HANDLE hConsoleOutput,
2346 WORD wAttribute,
2347 DWORD nLength,
2348 COORD dwWriteCoord,
2349 LPDWORD lpNumberOfAttrsWritten)
2350{
2351 BOOL fResult;
2352
2353#ifdef DEBUG_LOCAL2
2354 WriteLog("KERNEL32/CONSOLE: OS2FillConsoleOutputAttribute(%08x,%04x,%08x,%08x,%08x).\n",
2355 hConsoleOutput,
2356 wAttribute,
2357 nLength,
2358 dwWriteCoord,
2359 lpNumberOfAttrsWritten);
2360#endif
2361
2362 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
2363 DRQ_FILLCONSOLEOUTPUTATTRIBUTE,
2364 (ULONG)wAttribute,
2365 (ULONG)nLength,
2366 COORD2ULONG(dwWriteCoord),
2367 (ULONG)lpNumberOfAttrsWritten);
2368
2369 return fResult;
2370}
2371
2372
2373/*****************************************************************************
2374 * Name :
2375 * Purpose :
2376 * Parameters:
2377 * Variables :
2378 * Result :
2379 * Remark :
2380 * Status :
2381 *
2382 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2383 *****************************************************************************/
2384
2385BOOL WIN32API FillConsoleOutputCharacterA(HANDLE hConsoleOutput,
2386 UCHAR cCharacter,
2387 DWORD nLength,
2388 COORD dwWriteCoord,
2389 LPDWORD lpNumberOfCharsWritten )
2390{
2391 BOOL fResult;
2392
2393#ifdef DEBUG_LOCAL2
2394 WriteLog("KERNEL32/CONSOLE: OS2FillConsoleOutputCharacterA(%08x,%c,%08x,%08x,%08x).\n",
2395 hConsoleOutput,
2396 cCharacter,
2397 nLength,
2398 dwWriteCoord,
2399 lpNumberOfCharsWritten);
2400#endif
2401
2402 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
2403 DRQ_FILLCONSOLEOUTPUTCHARACTERA,
2404 (ULONG)cCharacter,
2405 (ULONG)nLength,
2406 COORD2ULONG(dwWriteCoord),
2407 (ULONG)lpNumberOfCharsWritten);
2408
2409 return fResult;
2410}
2411
2412
2413/*****************************************************************************
2414 * Name :
2415 * Purpose :
2416 * Parameters:
2417 * Variables :
2418 * Result :
2419 * Remark :
2420 * Status :
2421 *
2422 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2423 *****************************************************************************/
2424
2425BOOL WIN32API FillConsoleOutputCharacterW(HANDLE hConsoleOutput,
2426 WCHAR cCharacter,
2427 DWORD nLength,
2428 COORD dwWriteCoord,
2429 LPDWORD lpNumberOfCharsWritten )
2430{
2431 BOOL fResult;
2432
2433#ifdef DEBUG_LOCAL2
2434 WriteLog("KERNEL32/CONSOLE: OS2FillConsoleOutputCharacterW(%08x,%c,%08x,%08x,%08x) .\n",
2435 hConsoleOutput,
2436 cCharacter,
2437 nLength,
2438 dwWriteCoord,
2439 lpNumberOfCharsWritten);
2440#endif
2441
2442 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
2443 DRQ_FILLCONSOLEOUTPUTCHARACTERW,
2444 (ULONG)cCharacter,
2445 (ULONG)nLength,
2446 COORD2ULONG(dwWriteCoord),
2447 (ULONG)lpNumberOfCharsWritten);
2448
2449 return fResult;
2450}
2451
2452
2453/*****************************************************************************
2454 * Name :
2455 * Purpose :
2456 * Parameters:
2457 * Variables :
2458 * Result :
2459 * Remark :
2460 * Status :
2461 *
2462 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2463 *****************************************************************************/
2464
2465BOOL WIN32API FlushConsoleInputBuffer( HANDLE hConsoleInput )
2466{
2467 BOOL fResult;
2468
2469#ifdef DEBUG_LOCAL2
2470 WriteLog("KERNEL32/CONSOLE: OS2FlushConsoleInputBuffer(%08x).\n",
2471 hConsoleInput);
2472#endif
2473
2474 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
2475 DRQ_FLUSHCONSOLEINPUTBUFFER,
2476 0,
2477 0,
2478 0,
2479 0);
2480
2481 return fResult;
2482}
2483
2484
2485/*****************************************************************************
2486 * Name : BOOL WIN32API FreeConsole
2487 * Purpose : The FreeConsole function detaches the calling process
2488 * from its console.
2489 * Parameters: VOID
2490 * Variables :
2491 * Result : BOOL: TRUE - function succeeded
2492 * FALSE - function failed. Extended error information
2493 * obtainable via GetLastError
2494 * Remark :
2495 * Status : REWRITTEN UNTESTED
2496 *
2497 * Author : Patrick Haller [Tue, 1998/02/10 03:35]
2498 *****************************************************************************/
2499
2500BOOL WIN32API FreeConsole( VOID )
2501{
2502 APIRET rc; /* API returncode */
2503
2504#ifdef DEBUG_LOCAL2
2505 WriteLog("KERNEL32/CONSOLE: OS2FreeConsole() called.\n");
2506#endif
2507
2508 rc = iConsoleTerminate(); /* terminate subsystem if required */
2509 if (rc != NO_ERROR) /* check for errors */
2510 {
2511 SetLastError(rc); /* pass thru the error code */
2512 return FALSE; /* signal failure */
2513 }
2514 else
2515 return TRUE; /* Fine ! :) */
2516
2517 return TRUE;
2518}
2519
2520
2521/*****************************************************************************
2522 * Name :
2523 * Purpose :
2524 * Parameters:
2525 * Variables :
2526 * Result :
2527 * Remark :
2528 * Status :
2529 *
2530 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2531 *****************************************************************************/
2532
2533BOOL WIN32API GenerateConsoleCtrlEvent(DWORD dwCtrlEvent,
2534 DWORD dwProcessGroupId)
2535{
2536#ifdef DEBUG_LOCAL2
2537 WriteLog("KERNEL32/CONSOLE: OS2GenerateConsoleCtrlEvent(%08x,%08x) not implemented.\n",
2538 dwCtrlEvent,
2539 dwProcessGroupId);
2540#endif
2541
2542 return TRUE;
2543}
2544
2545
2546/*****************************************************************************
2547 * Name :
2548 * Purpose :
2549 * Parameters:
2550 * Variables :
2551 * Result :
2552 * Remark :
2553 * Status :
2554 *
2555 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2556 *****************************************************************************/
2557
2558UINT WIN32API GetConsoleCP(VOID)
2559{
2560#ifdef DEBUG_LOCAL2
2561 WriteLog("KERNEL32/CONSOLE: OS2GetConsoleCP not implemented.\n");
2562#endif
2563
2564 return 1;
2565}
2566
2567
2568/*****************************************************************************
2569 * Name :
2570 * Purpose :
2571 * Parameters:
2572 * Variables :
2573 * Result :
2574 * Remark :
2575 * Status :
2576 *
2577 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2578 *****************************************************************************/
2579
2580BOOL WIN32API GetConsoleCursorInfo(HANDLE hConsoleOutput,
2581 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
2582{
2583 BOOL fResult;
2584
2585#ifdef DEBUG_LOCAL2
2586 WriteLog("KERNEL32/CONSOLE: OS2GetConsoleCursorInfo(%08x,%08x).\n",
2587 hConsoleOutput,
2588 lpConsoleCursorInfo);
2589#endif
2590
2591 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
2592 DRQ_GETCONSOLECURSORINFO,
2593 (ULONG)lpConsoleCursorInfo,
2594 0,
2595 0,
2596 0);
2597
2598 return fResult;
2599}
2600
2601
2602/*****************************************************************************
2603 * Name :
2604 * Purpose :
2605 * Parameters:
2606 * Variables :
2607 * Result :
2608 * Remark :
2609 * Status :
2610 *
2611 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2612 *****************************************************************************/
2613
2614BOOL WIN32API GetConsoleMode(HANDLE hConsole,
2615 LPDWORD lpMode)
2616{
2617 BOOL fResult;
2618
2619#ifdef DEBUG_LOCAL2
2620 WriteLog("KERNEL32/CONSOLE: OS2GetConsoleMode(%08x,%08x).\n",
2621 hConsole,
2622 lpMode);
2623#endif
2624
2625 fResult = (BOOL)HMDeviceRequest(hConsole,
2626 DRQ_GETCONSOLEMODE,
2627 (ULONG) lpMode,
2628 0,
2629 0,
2630 0);
2631
2632 return fResult;
2633}
2634
2635
2636/*****************************************************************************
2637 * Name :
2638 * Purpose :
2639 * Parameters:
2640 * Variables :
2641 * Result :
2642 * Remark :
2643 * Status :
2644 *
2645 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2646 *****************************************************************************/
2647
2648UINT WIN32API GetConsoleOutputCP(VOID)
2649{
2650#ifdef DEBUG_LOCAL2
2651 WriteLog("KERNEL32/CONSOLE: OS2GetConsoleOutputCP not implemented.\n");
2652#endif
2653
2654 return 1;
2655}
2656
2657
2658/*****************************************************************************
2659 * Name :
2660 * Purpose :
2661 * Parameters:
2662 * Variables :
2663 * Result :
2664 * Remark :
2665 * Status :
2666 *
2667 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2668 *****************************************************************************/
2669
2670BOOL WIN32API GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
2671 PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
2672{
2673 BOOL fResult;
2674
2675#ifdef DEBUG_LOCAL2
2676 WriteLog("KERNEL32/CONSOLE: OS2GetConsoleScreenBufferInfo(%08x,%08x).\n",
2677 hConsoleOutput,
2678 lpConsoleScreenBufferInfo);
2679#endif
2680
2681 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
2682 DRQ_GETCONSOLESCREENBUFFERINFO,
2683 (ULONG)lpConsoleScreenBufferInfo,
2684 0,
2685 0,
2686 0);
2687
2688 return fResult;
2689}
2690
2691
2692/*****************************************************************************
2693 * Name : DWORD WIN32API GetConsoleTitle
2694 * Purpose : Query the current console window title
2695 * Parameters: LPTSTR lpConsoleTitle
2696 * DWORD nSize
2697 * Variables :
2698 * Result : number of copied bytes
2699 * Remark :
2700 * Status : REWRITTEN UNTESTED
2701 *
2702 * Author : Patrick Haller [Thu, 1998/02/12 23:31]
2703 *****************************************************************************/
2704
2705DWORD WIN32API GetConsoleTitleA(LPTSTR lpConsoleTitle,
2706 DWORD nSize)
2707{
2708 ULONG ulLength; /* length of text */
2709
2710#ifdef DEBUG_LOCAL2
2711 WriteLog("KERNEL32/CONSOLE: OS2GetConsoleTitleA(%08x,%08x).\n",
2712 lpConsoleTitle,
2713 nSize);
2714#endif
2715
2716 if (ConsoleGlobals.pszWindowTitle == NULL) /* is there a window title ? */
2717 return 0; /* abort immediately */
2718
2719 ulLength = strlen(ConsoleGlobals.pszWindowTitle); /* length of text */
2720
2721 strncpy(lpConsoleTitle,
2722 ConsoleGlobals.pszWindowTitle,
2723 nSize);
2724
2725 return (nSize < ulLength) ? nSize : ulLength;
2726}
2727
2728
2729/*****************************************************************************
2730 * Name : DWORD WIN32API GetConsoleTitle
2731 * Purpose : Query the current console window title
2732 * Parameters: LPTSTR lpConsoleTitle
2733 * DWORD nSize
2734 * Variables :
2735 * Result : number of copied bytes
2736 * Remark :
2737 * Status : REWRITTEN UNTESTED
2738 *
2739 * Author : Patrick Haller [Thu, 1998/02/12 23:31]
2740 *****************************************************************************/
2741
2742DWORD WIN32API GetConsoleTitleW(LPTSTR lpConsoleTitle,
2743 DWORD nSize)
2744{
2745 ULONG ulLength; /* length of text */
2746
2747#ifdef DEBUG_LOCAL2
2748 WriteLog("KERNEL32/CONSOLE: OS2GetConsoleTitleW(%08x,%08x).\n",
2749 lpConsoleTitle,
2750 nSize);
2751#endif
2752
2753 if (ConsoleGlobals.pszWindowTitle == NULL) /* is there a window title ? */
2754 return 0; /* abort immediately */
2755
2756 ulLength = strlen(ConsoleGlobals.pszWindowTitle); /* length of text */
2757
2758 strncpy(lpConsoleTitle,
2759 ConsoleGlobals.pszWindowTitle,
2760 nSize);
2761
2762 /* @@@PH Ascii2Unicode */
2763
2764 return (nSize < ulLength) ? nSize : ulLength;
2765}
2766
2767
2768/*****************************************************************************
2769 * Name : COORD WIN32API GetLargestConsoleWindowSize
2770 * Purpose : Determine maximum AVIO size
2771 * Parameters:
2772 * Variables :
2773 * Result :
2774 * Remark :
2775 * Status :
2776 *
2777 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2778 *****************************************************************************/
2779
2780COORD WIN32API GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
2781{
2782 DWORD dwResult;
2783 COORD coordResult;
2784
2785#ifdef DEBUG_LOCAL2
2786 WriteLog("KERNEL32/CONSOLE: OS2GetLargestConsoleWindowSize(%08x).\n",
2787 hConsoleOutput);
2788#endif
2789
2790 dwResult = HMDeviceRequest(hConsoleOutput,
2791 DRQ_GETLARGESTCONSOLEWINDOWSIZE,
2792 0,
2793 0,
2794 0,
2795 0);
2796
2797 ULONG2COORD(coordResult,dwResult)
2798 return ( coordResult );
2799}
2800
2801
2802/*****************************************************************************
2803 * Name :
2804 * Purpose :
2805 * Parameters:
2806 * Variables :
2807 * Result :
2808 * Remark :
2809 * Status :
2810 *
2811 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2812 *****************************************************************************/
2813
2814BOOL WIN32API GetNumberOfConsoleInputEvents(HANDLE hConsoleInput,
2815 LPDWORD lpNumberOfEvents)
2816{
2817 BOOL fResult;
2818
2819#ifdef DEBUG_LOCAL2
2820 WriteLog("KERNEL32/CONSOLE: OS2GetNumberOfConsoleInputEvents(%08x,%08x).\n",
2821 hConsoleInput,
2822 lpNumberOfEvents);
2823#endif
2824
2825 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
2826 DRQ_GETNUMBEROFCONSOLEINPUTEVENTS,
2827 (ULONG)lpNumberOfEvents,
2828 0,
2829 0,
2830 0);
2831
2832 return fResult;
2833}
2834
2835
2836/*****************************************************************************
2837 * Name :
2838 * Purpose :
2839 * Parameters:
2840 * Variables :
2841 * Result :
2842 * Remark :
2843 * Status :
2844 *
2845 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2846 *****************************************************************************/
2847
2848BOOL WIN32API GetNumberOfConsoleMouseButtons(LPDWORD lpcNumberOfMouseButtons)
2849{
2850 LONG lMouseButtons;
2851
2852#ifdef DEBUG_LOCAL2
2853 WriteLog("KERNEL32/CONSOLE: OS2GetNumberOfConsoleMouseButtons(%08x).\n",
2854 lpcNumberOfMouseButtons);
2855#endif
2856
2857 lMouseButtons = WinQuerySysValue(HWND_DESKTOP, /* query PM for that */
2858 SV_CMOUSEBUTTONS);
2859
2860 *lpcNumberOfMouseButtons = (DWORD)lMouseButtons;
2861
2862 return TRUE;
2863}
2864
2865
2866/*****************************************************************************
2867 * Name :
2868 * Purpose :
2869 * Parameters:
2870 * Variables :
2871 * Result :
2872 * Remark :
2873 * Status :
2874 *
2875 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2876 *****************************************************************************/
2877
2878BOOL WIN32API PeekConsoleInputW(HANDLE hConsoleInput,
2879 PINPUT_RECORD pirBuffer,
2880 DWORD cInRecords,
2881 LPDWORD lpcRead)
2882{
2883 BOOL fResult;
2884
2885#ifdef DEBUG_LOCAL2
2886 WriteLog("KERNEL32/CONSOLE: OS2PeekConsoleInputW(%08x,%08x,%08x,%08x).\n",
2887 hConsoleInput,
2888 pirBuffer,
2889 cInRecords,
2890 lpcRead);
2891#endif
2892
2893 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
2894 DRQ_PEEKCONSOLEINPUTW,
2895 (ULONG)pirBuffer,
2896 (ULONG)cInRecords,
2897 (ULONG)lpcRead,
2898 0);
2899
2900 return fResult;
2901}
2902
2903
2904/*****************************************************************************
2905 * Name :
2906 * Purpose :
2907 * Parameters:
2908 * Variables :
2909 * Result :
2910 * Remark :
2911 * Status :
2912 *
2913 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2914 *****************************************************************************/
2915
2916BOOL WIN32API PeekConsoleInputA(HANDLE hConsoleInput,
2917 PINPUT_RECORD pirBuffer,
2918 DWORD cInRecords,
2919 LPDWORD lpcRead)
2920{
2921 BOOL fResult;
2922
2923#ifdef DEBUG_LOCAL2
2924 WriteLog("KERNEL32/CONSOLE: OS2PeekConsoleInputA(%08x,%08x,%08x,%08x).\n",
2925 hConsoleInput,
2926 pirBuffer,
2927 cInRecords,
2928 lpcRead);
2929#endif
2930
2931 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
2932 DRQ_PEEKCONSOLEINPUTA,
2933 (ULONG)pirBuffer,
2934 (ULONG)cInRecords,
2935 (ULONG)lpcRead,
2936 0);
2937
2938 return fResult;
2939}
2940
2941
2942/*****************************************************************************
2943 * Name :
2944 * Purpose :
2945 * Parameters:
2946 * Variables :
2947 * Result :
2948 * Remark :
2949 * Status :
2950 *
2951 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2952 *****************************************************************************/
2953
2954BOOL WIN32API ReadConsoleA(HANDLE hConsoleInput,
2955 LPVOID lpvBuffer,
2956 DWORD cchToRead,
2957 LPDWORD lpcchRead,
2958 LPVOID lpvReserved)
2959{
2960 BOOL fResult;
2961
2962#ifdef DEBUG_LOCAL2
2963 WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleA(%08x,%08x,%08x,%08x,%08x).\n",
2964 hConsoleInput,
2965 lpvBuffer,
2966 cchToRead,
2967 lpcchRead,
2968 lpvReserved);
2969#endif
2970
2971 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
2972 DRQ_READCONSOLEA,
2973 (ULONG)lpvBuffer,
2974 (ULONG)cchToRead,
2975 (ULONG)lpcchRead,
2976 (ULONG)lpvReserved);
2977
2978 return fResult;
2979}
2980
2981
2982/*****************************************************************************
2983 * Name :
2984 * Purpose :
2985 * Parameters:
2986 * Variables :
2987 * Result :
2988 * Remark :
2989 * Status :
2990 *
2991 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
2992 *****************************************************************************/
2993
2994BOOL WIN32API ReadConsoleW(HANDLE hConsoleInput,
2995 LPVOID lpvBuffer,
2996 DWORD cchToRead,
2997 LPDWORD lpcchRead,
2998 LPVOID lpvReserved)
2999{
3000 BOOL fResult;
3001
3002#ifdef DEBUG_LOCAL2
3003 WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleW(%08x,%08x,%08x,%08x,%08x).\n",
3004 hConsoleInput,
3005 lpvBuffer,
3006 cchToRead,
3007 lpcchRead,
3008 lpvReserved);
3009#endif
3010
3011 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
3012 DRQ_READCONSOLEW,
3013 (ULONG)lpvBuffer,
3014 (ULONG)cchToRead,
3015 (ULONG)lpcchRead,
3016 (ULONG)lpvReserved);
3017
3018 return fResult;
3019}
3020
3021
3022/*****************************************************************************
3023 * Name :
3024 * Purpose :
3025 * Parameters:
3026 * Variables :
3027 * Result :
3028 * Remark :
3029 * Status :
3030 *
3031 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3032 *****************************************************************************/
3033
3034BOOL WIN32API ReadConsoleInputA(HANDLE hConsoleInput,
3035 PINPUT_RECORD pirBuffer,
3036 DWORD cInRecords,
3037 LPDWORD lpcRead)
3038{
3039 BOOL fResult;
3040
3041#ifdef DEBUG_LOCAL2
3042 WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleInputA(%08x,%08x,%08x,%08x).\n",
3043 hConsoleInput,
3044 pirBuffer,
3045 cInRecords,
3046 lpcRead);
3047#endif
3048
3049 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
3050 DRQ_READCONSOLEINPUTA,
3051 (ULONG)pirBuffer,
3052 (ULONG)cInRecords,
3053 (ULONG)lpcRead,
3054 0);
3055
3056 return fResult;
3057}
3058
3059
3060/*****************************************************************************
3061 * Name :
3062 * Purpose :
3063 * Parameters:
3064 * Variables :
3065 * Result :
3066 * Remark :
3067 * Status :
3068 *
3069 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3070 *****************************************************************************/
3071
3072BOOL WIN32API ReadConsoleInputW(HANDLE hConsoleInput,
3073 PINPUT_RECORD pirBuffer,
3074 DWORD cInRecords,
3075 LPDWORD lpcRead)
3076{
3077 BOOL fResult;
3078
3079#ifdef DEBUG_LOCAL2
3080 WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleInputW(%08x,%08x,%08x,%08x).\n",
3081 hConsoleInput,
3082 pirBuffer,
3083 cInRecords,
3084 lpcRead);
3085#endif
3086
3087 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
3088 DRQ_READCONSOLEINPUTW,
3089 (ULONG)pirBuffer,
3090 (ULONG)cInRecords,
3091 (ULONG)lpcRead,
3092 0);
3093
3094 return fResult;
3095}
3096
3097
3098/*****************************************************************************
3099 * Name :
3100 * Purpose :
3101 * Parameters:
3102 * Variables :
3103 * Result :
3104 * Remark :
3105 * Status :
3106 *
3107 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3108 *****************************************************************************/
3109
3110BOOL WIN32API ReadConsoleOutputA(HANDLE hConsoleOutput,
3111 PCHAR_INFO pchiDestBuffer,
3112 COORD coordDestBufferSize,
3113 COORD coordDestBufferCoord,
3114 PSMALL_RECT psrctSourceRect)
3115{
3116 BOOL fResult;
3117
3118#ifdef DEBUG_LOCAL2
3119 WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputA(%08x,%08x,%08x,%08x,%08x).\n",
3120 hConsoleOutput,
3121 pchiDestBuffer,
3122 coordDestBufferSize,
3123 coordDestBufferCoord,
3124 psrctSourceRect);
3125#endif
3126
3127 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3128 DRQ_READCONSOLEOUTPUTA,
3129 (ULONG)pchiDestBuffer,
3130 COORD2ULONG(coordDestBufferSize),
3131 COORD2ULONG(coordDestBufferCoord),
3132 (ULONG)psrctSourceRect);
3133
3134 return fResult;
3135}
3136
3137
3138/*****************************************************************************
3139 * Name :
3140 * Purpose :
3141 * Parameters:
3142 * Variables :
3143 * Result :
3144 * Remark :
3145 * Status :
3146 *
3147 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3148 *****************************************************************************/
3149
3150BOOL WIN32API ReadConsoleOutputW(HANDLE hConsoleOutput,
3151 PCHAR_INFO pchiDestBuffer,
3152 COORD coordDestBufferSize,
3153 COORD coordDestBufferCoord,
3154 PSMALL_RECT psrctSourceRect)
3155{
3156 BOOL fResult;
3157
3158#ifdef DEBUG_LOCAL2
3159 WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputW(%08x,%08x,%08x,%08x,%08x).\n",
3160 hConsoleOutput,
3161 pchiDestBuffer,
3162 coordDestBufferSize,
3163 coordDestBufferCoord,
3164 psrctSourceRect);
3165#endif
3166
3167 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3168 DRQ_READCONSOLEOUTPUTW,
3169 (ULONG)pchiDestBuffer,
3170 COORD2ULONG(coordDestBufferSize),
3171 COORD2ULONG(coordDestBufferCoord),
3172 (ULONG)psrctSourceRect);
3173
3174 return fResult;
3175}
3176
3177
3178/*****************************************************************************
3179 * Name :
3180 * Purpose :
3181 * Parameters:
3182 * Variables :
3183 * Result :
3184 * Remark :
3185 * Status :
3186 *
3187 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3188 *****************************************************************************/
3189
3190BOOL WIN32API ReadConsoleOutputAttribute(HANDLE hConsoleOutput,
3191 LPWORD lpwAttribute,
3192 DWORD cReadCells,
3193 COORD coordReadCoord,
3194 LPDWORD lpcNumberRead)
3195{
3196 BOOL fResult;
3197
3198#ifdef DEBUG_LOCAL2
3199 WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputAttribute(%08x,%08x,%08x,%08x,%08x).\n",
3200 hConsoleOutput,
3201 lpwAttribute,
3202 cReadCells,
3203 coordReadCoord,
3204 lpcNumberRead);
3205#endif
3206
3207 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3208 DRQ_READCONSOLEOUTPUTATTRIBUTE,
3209 (ULONG)lpwAttribute,
3210 (ULONG)cReadCells,
3211 COORD2ULONG(coordReadCoord),
3212 (ULONG)lpcNumberRead);
3213
3214 return fResult;
3215}
3216
3217
3218/*****************************************************************************
3219 * Name :
3220 * Purpose :
3221 * Parameters:
3222 * Variables :
3223 * Result :
3224 * Remark :
3225 * Status :
3226 *
3227 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3228 *****************************************************************************/
3229
3230BOOL WIN32API ReadConsoleOutputCharacterA(HANDLE hConsoleOutput,
3231 LPTSTR lpReadBuffer,
3232 DWORD cchRead,
3233 COORD coordReadCoord,
3234 LPDWORD lpcNumberRead)
3235{
3236 BOOL fResult;
3237
3238#ifdef DEBUG_LOCAL2
3239 WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputCharacterA(%08x,%08x,%08x,%08x,%08x).\n",
3240 hConsoleOutput,
3241 lpReadBuffer,
3242 cchRead,
3243 coordReadCoord,
3244 lpcNumberRead);
3245#endif
3246
3247 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3248 DRQ_READCONSOLEOUTPUTCHARACTERA,
3249 (ULONG)lpReadBuffer,
3250 (ULONG)cchRead,
3251 COORD2ULONG(coordReadCoord),
3252 (ULONG)lpcNumberRead);
3253
3254 return fResult;
3255}
3256
3257
3258/*****************************************************************************
3259 * Name :
3260 * Purpose :
3261 * Parameters:
3262 * Variables :
3263 * Result :
3264 * Remark :
3265 * Status :
3266 *
3267 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3268 *****************************************************************************/
3269
3270BOOL WIN32API ReadConsoleOutputCharacterW(HANDLE hConsoleOutput,
3271 LPTSTR lpReadBuffer,
3272 DWORD cchRead,
3273 COORD coordReadCoord,
3274 LPDWORD lpcNumberRead)
3275{
3276 BOOL fResult;
3277
3278#ifdef DEBUG_LOCAL2
3279 WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputCharacterW(%08x,%08x,%08x,%08x,%08x).\n",
3280 hConsoleOutput,
3281 lpReadBuffer,
3282 cchRead,
3283 coordReadCoord,
3284 lpcNumberRead);
3285#endif
3286
3287 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3288 DRQ_READCONSOLEOUTPUTCHARACTERW,
3289 (ULONG)lpReadBuffer,
3290 (ULONG)cchRead,
3291 COORD2ULONG(coordReadCoord),
3292 (ULONG)lpcNumberRead);
3293
3294 return fResult;
3295}
3296
3297
3298/*****************************************************************************
3299 * Name :
3300 * Purpose :
3301 * Parameters:
3302 * Variables :
3303 * Result :
3304 * Remark :
3305 * Status :
3306 *
3307 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3308 *****************************************************************************/
3309
3310BOOL WIN32API ScrollConsoleScreenBufferA(HANDLE hConsoleOutput,
3311 PSMALL_RECT psrctSourceRect,
3312 PSMALL_RECT psrctClipRect,
3313 COORD coordDestOrigin,
3314 PCHAR_INFO pchiFill)
3315{
3316 BOOL fResult;
3317
3318#ifdef DEBUG_LOCAL2
3319 WriteLog("KERNEL32/CONSOLE: OS2ScrollConsoleScreenBufferA(%08x,%08x,%08x,%08x,%08x).\n",
3320 hConsoleOutput,
3321 psrctSourceRect,
3322 psrctClipRect,
3323 coordDestOrigin,
3324 pchiFill);
3325#endif
3326
3327 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3328 DRQ_SCROLLCONSOLESCREENBUFFERA,
3329 (ULONG)psrctSourceRect,
3330 (ULONG)psrctClipRect,
3331 COORD2ULONG(coordDestOrigin),
3332 (ULONG)pchiFill);
3333
3334 return fResult;
3335}
3336
3337
3338/*****************************************************************************
3339 * Name :
3340 * Purpose :
3341 * Parameters:
3342 * Variables :
3343 * Result :
3344 * Remark :
3345 * Status :
3346 *
3347 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3348 *****************************************************************************/
3349
3350BOOL WIN32API ScrollConsoleScreenBufferW(HANDLE hConsoleOutput,
3351 PSMALL_RECT psrctSourceRect,
3352 PSMALL_RECT psrctClipRect,
3353 COORD coordDestOrigin,
3354 PCHAR_INFO pchiFill)
3355{
3356 BOOL fResult;
3357
3358#ifdef DEBUG_LOCAL2
3359 WriteLog("KERNEL32/CONSOLE: OS2ScrollConsoleScreenBufferW(%08x,%08x,%08x,%08x,%08x).\n",
3360 hConsoleOutput,
3361 psrctSourceRect,
3362 psrctClipRect,
3363 coordDestOrigin,
3364 pchiFill);
3365#endif
3366
3367 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3368 DRQ_SCROLLCONSOLESCREENBUFFERW,
3369 (ULONG)psrctSourceRect,
3370 (ULONG)psrctClipRect,
3371 COORD2ULONG(coordDestOrigin),
3372 (ULONG)pchiFill);
3373
3374 return fResult;
3375}
3376
3377/*****************************************************************************
3378 * Name :
3379 * Purpose :
3380 * Parameters:
3381 * Variables :
3382 * Result :
3383 * Remark :
3384 * Status :
3385 *
3386 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3387 *****************************************************************************/
3388
3389BOOL WIN32API SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
3390{
3391 BOOL fResult;
3392
3393#ifdef DEBUG_LOCAL2
3394 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleActiveScreenBuffer(%08x).\n",
3395 hConsoleOutput);
3396#endif
3397
3398 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3399 DRQ_SETCONSOLEACTIVESCREENBUFFER,
3400 0,
3401 0,
3402 0,
3403 0);
3404
3405 return fResult;
3406}
3407
3408
3409/*****************************************************************************
3410 * Name :
3411 * Purpose :
3412 * Parameters:
3413 * Variables :
3414 * Result :
3415 * Remark :
3416 * Status :
3417 *
3418 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3419 *****************************************************************************/
3420
3421BOOL WIN32API SetConsoleCP(UINT IDCodePage)
3422{
3423#ifdef DEBUG_LOCAL2
3424 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCP(%08x) not implemented.\n",
3425 IDCodePage);
3426#endif
3427
3428 return TRUE;
3429}
3430
3431
3432/*****************************************************************************
3433 * Name :
3434 * Purpose :
3435 * Parameters:
3436 * Variables :
3437 * Result :
3438 * Remark :
3439 * Status :
3440 *
3441 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3442 *****************************************************************************/
3443
3444BOOL WIN32API SetConsoleCtrlHandler(PHANDLER_ROUTINE pHandlerRoutine,
3445 BOOL fAdd)
3446{
3447#ifdef DEBUG_LOCAL2
3448 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCtrlHandler(%08x,%08x) not implemented.\n",
3449 pHandlerRoutine,
3450 fAdd);
3451#endif
3452
3453 return TRUE;
3454}
3455
3456
3457/*****************************************************************************
3458 * Name :
3459 * Purpose :
3460 * Parameters:
3461 * Variables :
3462 * Result :
3463 * Remark :
3464 * Status :
3465 *
3466 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3467 *****************************************************************************/
3468
3469BOOL WIN32API SetConsoleCursorInfo(HANDLE hConsoleOutput,
3470 PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
3471{
3472 BOOL fResult;
3473
3474#ifdef DEBUG_LOCAL2
3475 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCursorInfo(%08x,%08x).\n",
3476 hConsoleOutput,
3477 lpConsoleCursorInfo);
3478#endif
3479
3480 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3481 DRQ_SETCONSOLECURSORINFO,
3482 (ULONG)lpConsoleCursorInfo,
3483 0,
3484 0,
3485 0);
3486
3487 return fResult;
3488}
3489
3490
3491/*****************************************************************************
3492 * Name :
3493 * Purpose :
3494 * Parameters:
3495 * Variables :
3496 * Result :
3497 * Remark :
3498 * Status :
3499 *
3500 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3501
3502 *****************************************************************************/
3503
3504BOOL WIN32API SetConsoleCursorPosition(HANDLE hConsoleOutput,
3505 COORD coordCursor)
3506{
3507 BOOL fResult;
3508
3509#ifdef DEBUG_LOCAL2
3510 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCursorPosition(%08x,%08x).\n",
3511 hConsoleOutput,
3512 coordCursor);
3513#endif
3514
3515 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3516 DRQ_SETCONSOLECURSORPOSITION,
3517 COORD2ULONG(coordCursor),
3518 0,
3519 0,
3520 0);
3521
3522 return fResult;
3523}
3524
3525
3526/*****************************************************************************
3527 * Name :
3528 * Purpose :
3529 * Parameters:
3530 * Variables :
3531 * Result :
3532 * Remark :
3533 * Status :
3534 *
3535 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3536 *****************************************************************************/
3537
3538BOOL WIN32API SetConsoleMode(HANDLE hConsole,
3539 DWORD fdwMode)
3540{
3541 BOOL fResult;
3542
3543#ifdef DEBUG_LOCAL2
3544 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleMode(%08x,%08x).\n",
3545 hConsole,
3546 fdwMode);
3547#endif
3548
3549 fResult = (BOOL)HMDeviceRequest(hConsole,
3550 DRQ_SETCONSOLEMODE,
3551 (ULONG)fdwMode,
3552 0,
3553 0,
3554 0);
3555
3556 return fResult;
3557}
3558
3559
3560/*****************************************************************************
3561 * Name :
3562 * Purpose :
3563 * Parameters:
3564 * Variables :
3565 * Result :
3566 * Remark :
3567 * Status :
3568 *
3569 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3570 *****************************************************************************/
3571
3572BOOL WIN32API SetConsoleOutputCP(UINT IDCodePage)
3573{
3574#ifdef DEBUG_LOCAL2
3575 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleOutputCP(%08x) not implemented.\n",
3576 IDCodePage);
3577#endif
3578
3579 return TRUE;
3580}
3581
3582
3583/*****************************************************************************
3584 * Name :
3585 * Purpose :
3586 * Parameters:
3587 * Variables :
3588 * Result :
3589 * Remark :
3590 * Status :
3591 *
3592 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3593 *****************************************************************************/
3594
3595BOOL WIN32API SetConsoleScreenBufferSize(HANDLE hConsoleOutput,
3596 COORD coordSize)
3597{
3598 BOOL fResult;
3599
3600#ifdef DEBUG_LOCAL2
3601 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleScreenBufferSize(%08x,%08x).\n",
3602 hConsoleOutput,
3603 coordSize);
3604#endif
3605
3606 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3607 DRQ_SETCONSOLESCREENBUFFERSIZE,
3608 COORD2ULONG(coordSize),
3609 0,
3610 0,
3611 0);
3612
3613 return fResult;
3614}
3615
3616
3617/*****************************************************************************
3618 * Name :
3619 * Purpose :
3620 * Parameters:
3621 * Variables :
3622 * Result :
3623 * Remark :
3624 * Status :
3625 *
3626 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3627 *****************************************************************************/
3628
3629BOOL WIN32API SetConsoleTextAttribute(HANDLE hConsoleOutput,
3630 WORD wAttr)
3631{
3632 BOOL fResult;
3633
3634#ifdef DEBUG_LOCAL2
3635 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleTextAttribute(%08x,%04x).\n",
3636 hConsoleOutput,
3637 wAttr);
3638#endif
3639
3640 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3641 DRQ_SETCONSOLETEXTATTRIBUTE,
3642 (ULONG)wAttr,
3643 0,
3644 0,
3645 0);
3646
3647 return fResult;
3648}
3649
3650
3651/*****************************************************************************
3652 * Name : BOOL WIN32API SetConsoleTitleA
3653 * Purpose : Set new title text for the console window
3654 * Parameters: LPTSTR lpszTitle
3655 * Variables :
3656 * Result :
3657 * Remark :
3658 * Status : REWRITTEN UNTESTED
3659 *
3660 * Author : Patrick Haller [Tue, 1998/02/12 23:28]
3661 *****************************************************************************/
3662
3663BOOL WIN32API SetConsoleTitleA(LPTSTR lpszTitle)
3664{
3665#ifdef DEBUG_LOCAL2
3666 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleTitleA(%s).\n",
3667 lpszTitle);
3668#endif
3669
3670 if (ConsoleGlobals.pszWindowTitle != NULL) /* previously set name */
3671 free (ConsoleGlobals.pszWindowTitle); /* then free it */
3672
3673 ConsoleGlobals.pszWindowTitle = strdup(lpszTitle); /* copy the new name */
3674
3675 WinSetWindowText(ConsoleGlobals.hwndFrame, /* set new title text */
3676 ConsoleGlobals.pszWindowTitle);
3677
3678 return TRUE;
3679}
3680
3681
3682/*****************************************************************************
3683 * Name : BOOL WIN32API SetConsoleTitleW
3684 * Purpose : Set new title text for the console window
3685 * Parameters: LPTSTR lpszTitle
3686 * Variables :
3687 * Result :
3688 * Remark :
3689 * Status : REWRITTEN UNTESTED
3690 *
3691 * Author : Patrick Haller [Tue, 1998/02/12 23:28]
3692 *****************************************************************************/
3693
3694BOOL WIN32API SetConsoleTitleW(LPTSTR lpszTitle)
3695{
3696#ifdef DEBUG_LOCAL2
3697 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleTitleW(%s) not implemented.\n",
3698 lpszTitle);
3699#endif
3700
3701 /* @@@PH Unicode2Ascii */
3702
3703 if (ConsoleGlobals.pszWindowTitle != NULL) /* previously set name */
3704 free (ConsoleGlobals.pszWindowTitle); /* then free it */
3705
3706 ConsoleGlobals.pszWindowTitle = strdup(lpszTitle); /* copy the new name */
3707
3708 WinSetWindowText(ConsoleGlobals.hwndFrame, /* set new title text */
3709 ConsoleGlobals.pszWindowTitle);
3710
3711 return TRUE;
3712}
3713
3714
3715/*****************************************************************************
3716 * Name :
3717 * Purpose :
3718 * Parameters:
3719 * Variables :
3720 * Result :
3721 * Remark :
3722 * Status :
3723 *
3724 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3725 *****************************************************************************/
3726
3727BOOL WIN32API SetConsoleWindowInfo(HANDLE hConsoleOutput,
3728 BOOL fAbsolute,
3729 PSMALL_RECT psrctWindowRect)
3730{
3731 BOOL fResult;
3732
3733#ifdef DEBUG_LOCAL2
3734 WriteLog("KERNEL32/CONSOLE: OS2SetConsoleWindowInfo(%08x,%08x,%08x).\n",
3735 hConsoleOutput,
3736 fAbsolute,
3737 psrctWindowRect);
3738#endif
3739
3740 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3741 DRQ_SETCONSOLEWINDOWINFO,
3742 (ULONG)fAbsolute,
3743 (ULONG)psrctWindowRect,
3744 0,
3745 0);
3746
3747 return fResult;
3748}
3749
3750
3751/*****************************************************************************
3752 * Name :
3753 * Purpose :
3754 * Parameters:
3755 * Variables :
3756 * Result :
3757 * Remark :
3758 * Status :
3759 *
3760 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3761 *****************************************************************************/
3762
3763BOOL WIN32API WriteConsoleA(HANDLE hConsoleOutput,
3764 CONST VOID* lpvBuffer,
3765 DWORD cchToWrite,
3766 LPDWORD lpcchWritten,
3767 LPVOID lpvReserved)
3768{
3769 BOOL fResult;
3770
3771#ifdef DEBUG_LOCAL2
3772 WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleA(%08x,%08x,%08x,%08x,%08x).\n",
3773 hConsoleOutput,
3774 lpvBuffer,
3775 cchToWrite,
3776 lpcchWritten,
3777 lpvReserved);
3778#endif
3779
3780 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3781 DRQ_WRITECONSOLEA,
3782 (ULONG)lpvBuffer,
3783 (ULONG)cchToWrite,
3784 (ULONG)lpcchWritten,
3785 (ULONG)lpvReserved);
3786
3787 return fResult;
3788}
3789
3790
3791/*****************************************************************************
3792 * Name :
3793 * Purpose :
3794 * Parameters:
3795 * Variables :
3796 * Result :
3797 * Remark :
3798 * Status :
3799 *
3800 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3801 *****************************************************************************/
3802
3803BOOL WIN32API WriteConsoleW(HANDLE hConsoleOutput,
3804 CONST VOID* lpvBuffer,
3805 DWORD cchToWrite,
3806 LPDWORD lpcchWritten,
3807 LPVOID lpvReserved)
3808{
3809 BOOL fResult;
3810
3811#ifdef DEBUG_LOCAL2
3812 WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleW(%08x,%08x,%08x,%08x,%08x).\n",
3813 hConsoleOutput,
3814 lpvBuffer,
3815 cchToWrite,
3816 lpcchWritten,
3817 lpvReserved);
3818#endif
3819
3820 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3821 DRQ_WRITECONSOLEW,
3822 (ULONG)lpvBuffer,
3823 (ULONG)cchToWrite,
3824 (ULONG)lpcchWritten,
3825 (ULONG)lpvReserved);
3826
3827 return fResult;
3828}
3829
3830
3831/*****************************************************************************
3832 * Name :
3833 * Purpose :
3834 * Parameters:
3835 * Variables :
3836 * Result :
3837 * Remark :
3838 * Status :
3839 *
3840 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3841 *****************************************************************************/
3842
3843BOOL WIN32API WriteConsoleInputA(HANDLE hConsoleInput,
3844 PINPUT_RECORD pirBuffer,
3845 DWORD cInRecords,
3846 LPDWORD lpcWritten)
3847{
3848 BOOL fResult;
3849
3850#ifdef DEBUG_LOCAL2
3851 WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleInputA(%08x,%08x,%08x,%08x).\n",
3852 hConsoleInput,
3853 pirBuffer,
3854 cInRecords,
3855 lpcWritten);
3856#endif
3857
3858 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
3859 DRQ_WRITECONSOLEINPUTA,
3860 (ULONG)pirBuffer,
3861 (ULONG)cInRecords,
3862 (ULONG)lpcWritten,
3863 0);
3864
3865 return fResult;
3866}
3867
3868
3869/*****************************************************************************
3870 * Name :
3871 * Purpose :
3872 * Parameters:
3873 * Variables :
3874 * Result :
3875 * Remark :
3876 * Status :
3877 *
3878 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3879 *****************************************************************************/
3880
3881BOOL WIN32API WriteConsoleInputW(HANDLE hConsoleInput,
3882 PINPUT_RECORD pirBuffer,
3883 DWORD cInRecords,
3884 LPDWORD lpcWritten)
3885{
3886 BOOL fResult;
3887
3888#ifdef DEBUG_LOCAL2
3889 WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleInputW(%08x,%08x,%08x,%08x).\n",
3890 hConsoleInput,
3891 pirBuffer,
3892 cInRecords,
3893 lpcWritten);
3894#endif
3895
3896 fResult = (BOOL)HMDeviceRequest(hConsoleInput,
3897 DRQ_WRITECONSOLEINPUTW,
3898 (ULONG)pirBuffer,
3899 (ULONG)cInRecords,
3900 (ULONG)lpcWritten,
3901 0);
3902
3903 return fResult;
3904}
3905
3906
3907/*****************************************************************************
3908 * Name :
3909 * Purpose :
3910 * Parameters:
3911 * Variables :
3912 * Result :
3913 * Remark :
3914 * Status :
3915 *
3916 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3917 *****************************************************************************/
3918
3919BOOL WIN32API WriteConsoleOutputA(HANDLE hConsoleOutput,
3920 PCHAR_INFO pchiSrcBuffer,
3921 COORD coordSrcBufferSize,
3922 COORD coordSrcBufferCoord,
3923 PSMALL_RECT psrctDestRect)
3924{
3925 BOOL fResult;
3926
3927#ifdef DEBUG_LOCAL2
3928 WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputA(%08x,%08x,%08x,%08x,%08x).\n",
3929 hConsoleOutput,
3930 pchiSrcBuffer,
3931 coordSrcBufferSize,
3932 coordSrcBufferCoord,
3933 psrctDestRect);
3934#endif
3935
3936 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3937 DRQ_WRITECONSOLEOUTPUTA,
3938 (ULONG)pchiSrcBuffer,
3939 COORD2ULONG(coordSrcBufferSize),
3940 COORD2ULONG(coordSrcBufferCoord),
3941 (ULONG)psrctDestRect);
3942
3943 return fResult;
3944}
3945
3946
3947/*****************************************************************************
3948 * Name :
3949 * Purpose :
3950 * Parameters:
3951 * Variables :
3952 * Result :
3953 * Remark :
3954 * Status :
3955 *
3956 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3957 *****************************************************************************/
3958
3959BOOL WIN32API WriteConsoleOutputW(HANDLE hConsoleOutput,
3960 PCHAR_INFO pchiSrcBuffer,
3961 COORD coordSrcBufferSize,
3962 COORD coordSrcBufferCoord,
3963 PSMALL_RECT psrctDestRect)
3964{
3965 BOOL fResult;
3966
3967#ifdef DEBUG_LOCAL2
3968 WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputW(%08x,%08x,%08x,%08x,%08x).\n",
3969 hConsoleOutput,
3970 pchiSrcBuffer,
3971 coordSrcBufferSize,
3972 coordSrcBufferCoord,
3973 psrctDestRect);
3974#endif
3975
3976 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
3977 DRQ_WRITECONSOLEOUTPUTW,
3978 (ULONG)pchiSrcBuffer,
3979 COORD2ULONG(coordSrcBufferSize),
3980 COORD2ULONG(coordSrcBufferCoord),
3981 (ULONG)psrctDestRect);
3982
3983 return fResult;
3984}
3985
3986/*****************************************************************************
3987 * Name :
3988 * Purpose :
3989 * Parameters:
3990 * Variables :
3991 * Result :
3992 * Remark :
3993 * Status :
3994 *
3995 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
3996 *****************************************************************************/
3997
3998BOOL WIN32API WriteConsoleOutputAttribute(HANDLE hConsoleOutput,
3999 LPWORD lpwAttribute,
4000 DWORD cWriteCells,
4001 COORD coordWriteCoord,
4002 LPDWORD lpcNumberWritten)
4003{
4004 BOOL fResult;
4005
4006#ifdef DEBUG_LOCAL2
4007 WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputAttribute(%08x,%08x,%08x,%08x,%08x).\n",
4008 hConsoleOutput,
4009 lpwAttribute,
4010 cWriteCells,
4011 coordWriteCoord,
4012 lpcNumberWritten);
4013#endif
4014
4015 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
4016 DRQ_WRITECONSOLEOUTPUTATTRIBUTE,
4017 (ULONG)lpwAttribute,
4018 (ULONG)cWriteCells,
4019 COORD2ULONG(coordWriteCoord),
4020 (ULONG)lpcNumberWritten);
4021
4022 return fResult;
4023}
4024
4025
4026/*****************************************************************************
4027 * Name :
4028 * Purpose :
4029 * Parameters:
4030 * Variables :
4031 * Result :
4032 * Remark :
4033 * Status :
4034 *
4035 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
4036 *****************************************************************************/
4037
4038BOOL WIN32API WriteConsoleOutputCharacterA(HANDLE hConsoleOutput,
4039 LPTSTR lpWriteBuffer,
4040 DWORD cchWrite,
4041 COORD coordWriteCoord,
4042 LPDWORD lpcWritten)
4043{
4044 BOOL fResult;
4045
4046#ifdef DEBUG_LOCAL2
4047 WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputCharacterA(%08x,%08x,%08x,%08x,%08x).\n",
4048 hConsoleOutput,
4049 lpWriteBuffer,
4050 cchWrite,
4051 coordWriteCoord,
4052 lpcWritten);
4053#endif
4054
4055 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
4056 DRQ_WRITECONSOLEOUTPUTCHARACTERA,
4057 (ULONG)lpWriteBuffer,
4058 (ULONG)cchWrite,
4059 COORD2ULONG(coordWriteCoord),
4060 (ULONG)lpcWritten);
4061
4062 return fResult;
4063}
4064
4065
4066/*****************************************************************************
4067 * Name :
4068 * Purpose :
4069 * Parameters:
4070 * Variables :
4071 * Result :
4072 * Remark :
4073 * Status :
4074 *
4075 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
4076 *****************************************************************************/
4077
4078BOOL WIN32API WriteConsoleOutputCharacterW(HANDLE hConsoleOutput,
4079 LPTSTR lpWriteBuffer,
4080 DWORD cchWrite,
4081 COORD coordWriteCoord,
4082 LPDWORD lpcWritten)
4083{
4084 BOOL fResult;
4085
4086#ifdef DEBUG_LOCAL2
4087 WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputCharacterW(%08x,%08x,%08x,%08x,%08x).\n",
4088 hConsoleOutput,
4089 lpWriteBuffer,
4090 cchWrite,
4091 coordWriteCoord,
4092 lpcWritten);
4093#endif
4094
4095 fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
4096 DRQ_WRITECONSOLEOUTPUTCHARACTERW,
4097 (ULONG)lpWriteBuffer,
4098 (ULONG)cchWrite,
4099 COORD2ULONG(coordWriteCoord),
4100 (ULONG)lpcWritten);
4101
4102 return fResult;
4103}
Note: See TracBrowser for help on using the repository browser.