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

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

Fix: Console buffer fixes.

File size: 138.1 KB
Line 
1/* $Id: console.cpp,v 1.10 1999-07-12 17:45:51 phaller Exp $ */
2
3/*
4 * Win32 Console API Translation for OS/2
5 *
6 * 1998/02/10 Patrick Haller (haller@zebra.fh-weingarten.de)
7 *
8 * @(#) console.cpp 1.0.0 1998/02/10 PH Start from scratch
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13
14
15#ifdef DEBUG
16#define DEBUG_LOCAL
17#define DEBUG_LOCAL2
18#endif
19
20#undef DEBUG_LOCAL
21#undef DEBUG_LOCAL2
22
23
24/*****************************************************************************
25 * Remark *
26 *****************************************************************************
27
28 - DWORD HandlerRoutine (DWORD dwCtrlType)
29 basically an exception handler routine. handles a few signals / excpts.
30 should be somewhere near the exception handling code ... :)
31
32 Hmm, however as PM applications don't really get a ctrl-c signal,
33 I'll have to do this on my own ...
34
35 - supply unicode<->ascii conversions for all the _A and _W function pairs.
36
37 - problem: we can't prevent thread1 from blocking the message queue ?
38 what will happen if a WinTerminate() is issued there ?
39 will the message queue be closed and provide smooth tasking ?
40 how will open32 react on this ?
41
42 - ECHO_LINE_INPUT / ReadFile blocks till CR
43
44 - scrollbars
45 * do some flowchart to exactly determine WHEN to use WHICH setting
46 and perform WHAT action
47
48 - clipboard support
49*/
50
51
52/*****************************************************************************
53 * Includes *
54 *****************************************************************************/
55
56#define INCL_WIN
57#define INCL_DOSMEMMGR
58#define INCL_DOSSEMAPHORES
59#define INCL_DOSERRORS
60#define INCL_DOSPROCESS
61#define INCL_DOSMODULEMGR
62#define INCL_VIO
63#define INCL_AVIO
64#include <os2wrap.h> //Odin32 OS/2 api wrappers
65#include <builtin.h>
66#include <stdlib.h>
67#include <string.h>
68
69#include <win32type.h>
70#include <misc.h>
71
72#include "conwin.h" // Windows Header for console only
73#include "HandleManager.h"
74#include "HMDevice.h"
75
76#include "console.h"
77#include "console2.h"
78#include "conin.h"
79#include "conout.h"
80#include "conbuffer.h"
81
82#include "conprop.h"
83#include "unicode.h"
84
85
86/***********************************
87 * PH: fixups for missing os2win.h *
88 ***********************************/
89
90#include <os2sel.h>
91
92extern "C"
93{
94 void _System _O32_SetLastError(DWORD dwError);
95 DWORD _System _O32_GetLastError(void);
96 LPSTR _System _O32_GetCommandLine(void);
97 void _System _O32_ExitProcess(UINT exitcode);
98 HANDLE _System _O32_GetStdHandle(DWORD dwDevice);
99 DWORD _System _O32_GetFileType(HANDLE hFile);
100
101inline void SetLastError(DWORD a)
102{
103 USHORT sel = GetFS();
104
105 _O32_SetLastError(a);
106 SetFS(sel);
107}
108
109inline DWORD GetLastError()
110{
111 DWORD yyrc;
112 USHORT sel = GetFS();
113
114 yyrc = _O32_GetLastError();
115 SetFS(sel);
116
117 return yyrc;
118}
119
120inline LPSTR GetCommandLine()
121{
122 LPSTR yyrc;
123 USHORT sel = GetFS();
124
125 yyrc = _O32_GetCommandLine();
126 SetFS(sel);
127
128 return yyrc;
129}
130
131inline void ExitProcess(UINT a)
132{
133 USHORT sel = GetFS();
134
135 _O32_ExitProcess(a);
136 SetFS(sel);
137}
138
139inline HANDLE GetStdHandle(DWORD a)
140{
141 HANDLE yyrc;
142 USHORT sel = GetFS();
143
144 yyrc = _O32_GetStdHandle(a);
145 SetFS(sel);
146
147 return yyrc;
148}
149
150inline DWORD GetFileType(HANDLE a)
151{
152 DWORD yyrc;
153 USHORT sel = GetFS();
154
155 yyrc = _O32_GetFileType(a);
156 SetFS(sel);
157
158 return yyrc;
159}
160
161}
162
163/*****************************************************************************
164 * Defines *
165 *****************************************************************************/
166
167/*****************************************************************************
168 * Structures *
169 *****************************************************************************/
170
171
172/*****************************************************************************
173 * Process Global Structures *
174 *****************************************************************************/
175
176static ICONSOLEGLOBALS ConsoleGlobals;
177static ICONSOLEINPUT ConsoleInput;
178
179
180/*****************************************************************************
181 * Prototypes *
182 *****************************************************************************/
183
184
185/*****************************************************************************
186 * Name : iConsoleInputQueueLock
187 * Purpose : lock the input queue to ensure correct event sequence
188 * Parameters:
189 * Variables :
190 * Result :
191 * Remark :
192 * Status :
193 *
194 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
195 *****************************************************************************/
196
197void static iConsoleInputQueueLock()
198{
199 APIRET rc;
200
201 rc = DosRequestMutexSem(ConsoleInput.hmtxInputQueue,
202 SEM_INDEFINITE_WAIT);
203 if (rc != NO_ERROR)
204 dprintf(("KERNEL32: Console:iConsoleInputQueueLock error %08xh\n",
205 rc));
206}
207
208
209/*****************************************************************************
210 * Name : iConsoleInputQueueUnlock
211 * Purpose : unlock the input queue
212 * Parameters:
213 * Variables :
214 * Result :
215 * Remark :
216 * Status :
217 *
218 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
219 *****************************************************************************/
220
221void static iConsoleInputQueueUnlock()
222{
223 APIRET rc;
224
225 rc = DosReleaseMutexSem(ConsoleInput.hmtxInputQueue);
226 if (rc != NO_ERROR)
227 dprintf(("KERNEL32: Console:iConsoleInputQueueUnlock error %08xh\n",
228 rc));
229}
230
231
232/*****************************************************************************
233 * Name :
234 * Purpose :
235 * Parameters:
236 * Variables :
237 * Result :
238 * Remark :
239 * Status :
240 *
241 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
242 *****************************************************************************/
243
244APIRET iConsoleInit(void) /* creation of the console subsystem */
245{
246 APIRET rc; /* API return code */
247 ULONG ulPostCount; /* semaphore post counter */
248
249
250
251 if (ConsoleGlobals.hevConsole != NULLHANDLE) /* we're already initialized ?*/
252 return (NO_ERROR); /* then abort immediately */
253
254 /* create console synchronization semaphore */
255 rc = DosCreateEventSem (NULL,
256 &ConsoleGlobals.hevConsole,
257 0L, /* semaphore is private */
258 FALSE); /* reset state */
259 if (rc != NO_ERROR) /* other error ? */
260 return (rc); /* raise error condition */
261
262
263 /* create console input queue semaphore */
264 rc = DosCreateEventSem (NULL,
265 &ConsoleInput.hevInputQueue,
266 0L, /* semaphore is private */
267 FALSE); /* reset state */
268 if (rc != NO_ERROR) /* other error ? */
269 {
270 DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
271 return (rc); /* raise error condition */
272 }
273
274
275 rc = DosCreateMutexSem(NULL,
276 &ConsoleInput.hmtxInputQueue,
277 0L,
278 FALSE);
279 if (rc != NO_ERROR) /* other error ? */
280 {
281 DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
282 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
283 return (rc); /* raise error condition */
284 }
285
286 /***************************************************************************
287 * Create pseudo-devices and initialize ConsoleGlobals *
288 ***************************************************************************/
289
290 rc = iConsoleDevicesRegister(); /* ensure devices are there */
291 if (rc != NO_ERROR) /* check for errors */
292 {
293 DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
294 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
295 return (rc); /* raise error condition */
296 }
297
298
299 /***************************************************************************
300 * Presentation Manager Initialization phase *
301 ***************************************************************************/
302
303 /* OK, we're about to initialize the console subsystem for this process. */
304 /* start message thread for console object window */
305 ConsoleGlobals.tidConsole = _beginthread(iConsoleMsgThread,
306 NULL,
307 12288,
308 NULL);
309 /* has the thread been created properly ? */
310 if (ConsoleGlobals.tidConsole == -1)
311 {
312 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
313 DosCloseEventSem(ConsoleGlobals.hevConsole); /* close event semaphore */
314 ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
315 return (rc); /* raise error condition */
316 }
317 else
318 DosSetPriority(PRTYS_THREAD, /* set priority */
319 ConsoleGlobals.Options.ulConsoleThreadPriorityClass,
320 ConsoleGlobals.Options.ulConsoleThreadPriorityDelta,
321 ConsoleGlobals.tidConsole);
322
323
324 /* wait for the child thread to do it's initialization */
325 /* timeout isn't really useful */
326 rc = DosWaitEventSem(ConsoleGlobals.hevConsole,
327 SEM_INDEFINITE_WAIT);
328 if (rc != NO_ERROR) /* check for errors */
329 {
330 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
331 DosCloseEventSem(ConsoleGlobals.hevConsole); /* close event semaphore */
332 ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
333 return (rc); /* raise error condition */
334 }
335
336 DosResetEventSem(ConsoleGlobals.hevConsole, /* reset event semaphore */
337 &ulPostCount);
338
339 rc = ConsoleGlobals.rcConsole; /* pass thru console thread's return code */
340
341 return (rc); /* OK */
342}
343
344
345/*****************************************************************************
346 * Name : ConsoleDevicesRegister
347 * Purpose : creates and registers console devices if the standard handles
348 * are not redirected to a file
349 * Parameters:
350 * Variables :
351 * Result :
352 * Remark :
353 * Status :
354 *
355 * Author : Patrick Haller [Tue, 1998/03/17 01:55]
356 *****************************************************************************/
357
358APIRET iConsoleDevicesRegister(void)
359{
360 DWORD dwType; /* device handle type */
361 HANDLE hStandardIn; /* stdin handle to CONIN$ */
362 HANDLE hStandardOut; /* stdout handle to CONOUT$ */
363 HANDLE hStandardError; /* stderr handle to CONOUT$ */
364
365 HMDeviceConsoleInClass *pHMDeviceConsoleIn;
366 HMDeviceConsoleOutClass *pHMDeviceConsoleOut;
367 HMDeviceConsoleBufferClass *pHMDeviceConsoleBuffer;
368
369 DWORD rc;
370
371 static fDevicesInitialized; /* have we been initialized already ? */
372
373 if (fDevicesInitialized == TRUE) /* OK, we're already done */
374 return (NO_ERROR);
375 else
376 fDevicesInitialized = TRUE;
377
378 dprintf(("KERNEL32:ConsoleDevicesRegister\n"));
379
380
381 /*************************************
382 * Initialize Console Window Options *
383 *************************************/
384
385 ConsoleGlobals.Options.fTerminateAutomatically = FALSE;
386 ConsoleGlobals.Options.fSpeakerEnabled = TRUE;
387
388 ConsoleGlobals.Options.fSetWindowPosition = FALSE;
389 ConsoleGlobals.Options.coordDefaultPosition.X = 0;
390 ConsoleGlobals.Options.coordDefaultPosition.Y = 0;
391 ConsoleGlobals.Options.coordDefaultSize.X = 80;
392 ConsoleGlobals.Options.coordDefaultSize.Y = 25;
393 ConsoleGlobals.coordWindowSize.X = ConsoleGlobals.Options.coordDefaultSize.X;
394 ConsoleGlobals.coordWindowSize.Y = ConsoleGlobals.Options.coordDefaultSize.Y;
395 ConsoleGlobals.coordWindowPos.X = 0;
396 ConsoleGlobals.coordWindowPos.Y = 0;
397
398 ConsoleGlobals.Options.fQuickInsert = FALSE;
399 ConsoleGlobals.Options.fInsertMode = FALSE;
400 ConsoleGlobals.Options.fMouseActions = FALSE;
401 ConsoleGlobals.Options.fToolbarActive = FALSE;
402
403 ConsoleGlobals.Options.ucDefaultAttribute = 0x0007; /* 07 = grey on black */
404
405 ConsoleGlobals.Options.ulTabSize = 8; /* tabulator size */
406 ConsoleGlobals.Options.ulUpdateLimit = 8; /* scroll max. n lines */
407
408 /* priority settings for message thread */
409 ConsoleGlobals.Options.ulConsoleThreadPriorityClass = PRTYC_REGULAR;
410 ConsoleGlobals.Options.ulConsoleThreadPriorityDelta = +10;
411
412 ConsoleGlobals.Options.ucCursorDivisor = 10; /* timer divisor for blinking */
413
414 ConsoleGlobals.ulTimerFrequency = 10; /* cursor + blitter timer frequency */
415
416
417 ConsoleGlobals.flFrameFlags = FCF_SIZEBORDER | /* frame creation flags */
418 FCF_TITLEBAR |
419 FCF_SHELLPOSITION|
420 FCF_SYSMENU |
421 FCF_TASKLIST |
422 FCF_AUTOICON |
423 FCF_HORZSCROLL |
424 FCF_VERTSCROLL |
425 FCF_MINMAX;
426
427 /* generate copy of title */
428 ConsoleGlobals.pszWindowTitle = strdup(GetCommandLine());
429
430 /* obtain module handle to our resources */
431 rc = DosQueryModuleHandle("KERNEL32",
432 &ConsoleGlobals.hmodResource);
433 if (rc != NO_ERROR)
434 WriteLog("KERNEL32/CONSOLE: Can't get handle to KERNEL32 (%u).\n",
435 rc);
436
437 /* standard console input modes */
438 ConsoleInput.dwConsoleMode = ENABLE_LINE_INPUT |
439 ENABLE_PROCESSED_INPUT;
440 /* @@@PH ENABLE_ECHO_INPUT || ENABLE_MOUSE_INPUT; */
441
442 ConsoleGlobals.hConsoleBufferDefault = INVALID_HANDLE_VALUE;
443 ConsoleGlobals.hConsoleBuffer = INVALID_HANDLE_VALUE;
444
445
446 /***************************************************************************
447 * Standard handles Initialization phase *
448 ***************************************************************************/
449
450 /* create devices and register devices with handlemanager */
451
452 pHMDeviceConsoleIn = new HMDeviceConsoleInClass("CONIN$",
453 &ConsoleInput,
454 &ConsoleGlobals);
455 rc = HMDeviceRegister ("CONIN$",
456 pHMDeviceConsoleIn);
457 if (rc != NO_ERROR) /* check for errors */
458 dprintf(("KERNEL32:ConsoleDevicesRegister: registering CONIN$ failed with %u.\n",
459 rc));
460
461
462 pHMDeviceConsoleOut = new HMDeviceConsoleOutClass("CONOUT$",
463 &ConsoleInput,
464 &ConsoleGlobals);
465 rc = HMDeviceRegister ("CONOUT$",
466 pHMDeviceConsoleOut);
467 if (rc != NO_ERROR) /* check for errors */
468 dprintf(("KERNEL32:ConsoleDevicesRegister: registering CONOUT$ failed with %u.\n",
469 rc));
470
471
472 pHMDeviceConsoleBuffer = new HMDeviceConsoleBufferClass("CONBUFFER$",
473 &ConsoleInput,
474 &ConsoleGlobals);
475 rc = HMDeviceRegister ("CONBUFFER$",
476 pHMDeviceConsoleBuffer);
477 if (rc != NO_ERROR) /* check for errors */
478 dprintf(("KERNEL32:ConsoleDevicesRegister: registering CONBUFFER$ failed with %u.\n",
479 rc));
480
481
482 /***********************************************************************
483 * initialize stdin handle *
484 ***********************************************************************/
485 hStandardIn = GetStdHandle(STD_INPUT_HANDLE);
486 dwType = GetFileType(hStandardIn);
487 if (dwType == FILE_TYPE_CHAR) /* is handle redirected ? */
488 hStandardIn = HMCreateFile("CONIN$",
489 GENERIC_READ | GENERIC_WRITE,
490 FILE_SHARE_READ | FILE_SHARE_WRITE,
491 NULL,
492 0,
493 CONSOLE_TEXTMODE_BUFFER,
494 0);
495
496 HMSetStdHandle(STD_INPUT_HANDLE,
497 hStandardIn);
498
499 /***********************************************************************
500 * initialize stdout handle *
501 ***********************************************************************/
502 hStandardOut = GetStdHandle(STD_OUTPUT_HANDLE);
503 dwType = GetFileType(hStandardOut);
504 if (dwType == FILE_TYPE_CHAR) /* is handle redirected ? */
505 hStandardOut = HMCreateFile("CONOUT$",
506 GENERIC_READ | GENERIC_WRITE,
507 FILE_SHARE_READ | FILE_SHARE_WRITE,
508 NULL,
509 0,
510 CONSOLE_TEXTMODE_BUFFER,
511 0);
512
513 HMSetStdHandle(STD_OUTPUT_HANDLE,
514 hStandardOut);
515
516
517 /***********************************************************************
518 * initialize stderr handle *
519 ***********************************************************************/
520 hStandardError = GetStdHandle(STD_ERROR_HANDLE);
521 dwType = GetFileType(hStandardError);
522 if (dwType == FILE_TYPE_CHAR) /* is handle redirected ? */
523 hStandardError = HMCreateFile("CONOUT$",
524 GENERIC_READ | GENERIC_WRITE,
525 FILE_SHARE_READ | FILE_SHARE_WRITE,
526 NULL,
527 0,
528 CONSOLE_TEXTMODE_BUFFER,
529 0);
530
531 HMSetStdHandle(STD_ERROR_HANDLE,
532 hStandardError);
533
534 return (NO_ERROR); /* OK */
535}
536
537
538/*****************************************************************************
539 * Name : static APIRET ConsoleTerminate
540 * Purpose : Shuts the OS/2 console subsystem down
541 * Parameters: VOID
542 * Variables :
543 * Result : OS/2 API return code
544 * Remark : That consolebuffer handle that became allocated as default
545 * screen buffer is lost here. This would be a serious memory
546 * leak if an application keeps opening and closing the console
547 * frequently.
548 * Status :
549 *
550 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
551 *****************************************************************************/
552
553APIRET iConsoleTerminate(VOID)
554{
555 APIRET rc;
556
557 DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
558 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
559 DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */
560
561
562 WinPostMsg (ConsoleGlobals.hwndFrame, /* force thread to terminate */
563 WM_CLOSE,
564 (MPARAM)NULL,
565 (MPARAM)NULL);
566
567 rc = DosWaitThread(&ConsoleGlobals.tidConsole,/* wait until thd terminates */
568 DCWW_WAIT);
569
570 /* close the consolebuffer handle */
571 HMCloseHandle(ConsoleGlobals.hConsoleBufferDefault);
572 free(ConsoleGlobals.pszWindowTitle); /* free previously allocated memory */
573
574 return (rc); /* OK */
575}
576
577
578/*****************************************************************************
579 * Name : static void ConsoleWaitClose
580 * Purpose : Wait for the user to close console window
581 * Parameters: VOID
582 * Variables :
583 * Result :
584 * Remark :
585 * Status :
586 *
587 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
588 *****************************************************************************/
589
590void iConsoleWaitClose(void)
591{
592 CHAR szBuffer[128]; /* buffer for the title */
593 BOOL fResult; /* result from subsequent calls to Win32 APIs */
594
595 /* check if there is a console window at all */
596 if (iConsoleIsActive() == FALSE)
597 return; /* nope */
598
599 strcpy (szBuffer, /* indicate console process has terminated */
600 "Completed: ");
601
602 fResult = GetConsoleTitleA(szBuffer + 11,/* 11 is length of Completed:_ */
603 sizeof(szBuffer) - 11);
604
605
606 /* Set new title: Win32 Console - Terminated */
607 fResult = SetConsoleTitleA(szBuffer);
608
609 DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
610 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
611 DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */
612
613
614 /* terminate console immediately ? */
615 if (ConsoleGlobals.Options.fTerminateAutomatically == FALSE)
616 DosWaitThread(&ConsoleGlobals.tidConsole, /* wait until thd terminates */
617 DCWW_WAIT);
618}
619
620
621/*****************************************************************************
622 * Name : static BOOL ConsoleIsActive
623 * Purpose : Check if Console window is opened
624 * Parameters: VOID
625 * Variables :
626 * Result :
627 * Remark :
628 * Status :
629 *
630 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
631 *****************************************************************************/
632
633BOOL iConsoleIsActive(void)
634{
635 return (NULLHANDLE != ConsoleGlobals.hevConsole);
636}
637
638
639/*****************************************************************************
640 * Name : static VOID ConsoleMsgThread
641 * Purpose : Message handler thread for the console object window
642 * Parameters: PVOID pDummy
643 * Variables :
644 * Result : is placed in Globals.rcConsole
645 * Remark : the main thread has to wait for this thread
646 * Status :
647 *
648 * Author : Patrick Haller [Tue, 1998/02/10 02:49]
649 *****************************************************************************/
650
651VOID iConsoleMsgThread(PVOID pParameters)
652{
653 APIRET rc; /* API return code */
654
655
656 ConsoleGlobals.rcConsole = NO_ERROR; /* initialization */
657
658 ConsoleGlobals.hab = WinInitialize(0); /* enable thread for PM */
659 if (ConsoleGlobals.hab == NULLHANDLE) /* if anchor block allocation failed */
660 ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
661 else
662 {
663 /* create message queue */
664 ConsoleGlobals.hmq = WinCreateMsgQueue(ConsoleGlobals.hab,
665 0);
666 if (ConsoleGlobals.hmq == NULLHANDLE) /* if msg queue allocation failed */
667 {
668 WinTerminate(ConsoleGlobals.hab); /* stop thread from accessing PM */
669 ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
670 }
671 else
672 {
673 if (WinRegisterClass(ConsoleGlobals.hab, /* register our class with PM */
674 SZ_CONSOLE_CLASS,
675 iConsoleWindowProc,
676 CS_SIZEREDRAW,
677 0)
678 == FALSE)
679 {
680 WinDestroyMsgQueue(ConsoleGlobals.hmq); /* destroy message queue */
681 WinTerminate(ConsoleGlobals.hab); /* stop thread from accessing PM */
682 ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
683 }
684 else
685 {
686 ConsoleGlobals.hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
687 WS_VISIBLE,
688 &ConsoleGlobals.flFrameFlags,
689 SZ_CONSOLE_CLASS,
690 ConsoleGlobals.pszWindowTitle,
691 0,
692 ConsoleGlobals.hmodResource,
693 ID_CONSOLE_MAIN,
694 &ConsoleGlobals.hwndClient);
695 if (ConsoleGlobals.hwndFrame == NULLHANDLE) /* check window creation */
696 {
697 WinDestroyMsgQueue(ConsoleGlobals.hmq); /* destroy message queue */
698 WinTerminate(ConsoleGlobals.hab); /* stop thread from accessing PM */
699 ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
700 } /* WinCreateStdWindow */
701 } /* WinRegisterClass */
702 } /* WinCreateMsgQueue */
703 } /* WinInitialize */
704
705
706 DosPostEventSem(ConsoleGlobals.hevConsole); /* signal the main thread */
707
708
709 if (ConsoleGlobals.rcConsole != NO_ERROR) /* if we ran into a problem */
710 {
711 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
712 DosCloseEventSem(ConsoleGlobals.hevConsole); /* subsystem not running .. */
713 ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
714 return; /* abort the message queue thread immediately */
715 }
716
717
718 while( WinGetMsg(ConsoleGlobals.hab, /* message loop */
719 &ConsoleGlobals.qmsg,
720 NULLHANDLE,
721 0,
722 0) )
723 WinDispatchMsg(ConsoleGlobals.hab, /* dispatch the message */
724 &ConsoleGlobals.qmsg);
725
726 /* do the cleanup, destroy window, queue */
727 /* and stop thread from using PM */
728 WinDestroyWindow (ConsoleGlobals.hwndFrame);
729 WinDestroyMsgQueue(ConsoleGlobals.hmq);
730 WinTerminate (ConsoleGlobals.hab);
731
732 /* destruction of semaphore indicates console is shutdown */
733 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
734 DosCloseEventSem(ConsoleGlobals.hevConsole);
735 DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */
736
737 ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
738 ConsoleInput.hevInputQueue = NULLHANDLE;
739 ConsoleInput.hmtxInputQueue = NULLHANDLE;
740
741 /* @@@PH we've got to exit the process here ! */
742 ExitProcess(1);
743}
744
745
746/*****************************************************************************
747 * Name : static MRESULT EXPENTRY ConsoleWindowProc
748 * Purpose : Window Procedure for OUR console window
749 * Parameters: HWND hwnd - window handle
750 * ULONG msg - message identifier
751 * MPARAM mp1 - message parameter 1
752 * MPARAM mp2 - message parameter 2
753 * Variables :
754 * Result : MRESULT for PM
755 * Remark :
756 * Status :
757 *
758 * Author : Patrick Haller [Tue, 1998/02/10 03:24]
759 *****************************************************************************/
760
761MRESULT EXPENTRY iConsoleWindowProc(HWND hwnd,
762 ULONG msg,
763 MPARAM mp1,
764 MPARAM mp2)
765{
766 static RECTL rcl; /* window rectangle */
767 static HPS hps;
768
769 switch(msg)
770 {
771 /*************************************************************************
772 * WM_CREATE window creation *
773 *************************************************************************/
774
775 case WM_CREATE:
776 WinPostMsg(hwnd, /* deferred initialization */
777 UM_CONSOLE_CREATE,
778 (MPARAM)NULL,
779 (MPARAM)NULL);
780 break;
781
782
783 case UM_CONSOLE_CREATE:
784 {
785 APIRET rc; /* API return code */
786 HWND hwndFrame; /* frame window handle */
787
788 /* subclass the frame window */
789 hwndFrame = ConsoleGlobals.hwndFrame;
790 ConsoleGlobals.pfnwpFrameOriginal = WinSubclassWindow(hwndFrame,
791 iConsoleFrameWindowProc);
792
793 ConsoleGlobals.hwndMenuConsole
794 = WinLoadMenu (hwnd, /* load context menue */
795 ConsoleGlobals.hmodResource,
796 ID_CONSOLE_MAIN);
797
798 /* set an icon for the dialog */
799 ConsoleGlobals.hPtrConsole = WinLoadPointer(HWND_DESKTOP,
800 ConsoleGlobals.hmodResource,
801 ID_CONSOLE_MAIN );
802 WinSendMsg(ConsoleGlobals.hwndFrame,
803 WM_SETICON,
804 (MPARAM)ConsoleGlobals.hPtrConsole,
805 0L );
806
807 /* determine handles of the horizontal / vertical scroll bars */
808 ConsoleGlobals.hwndVertScroll = WinWindowFromID(ConsoleGlobals.hwndFrame,
809 FID_VERTSCROLL);
810
811 ConsoleGlobals.hwndHorzScroll = WinWindowFromID(ConsoleGlobals.hwndFrame,
812 FID_HORZSCROLL);
813
814 /* the initial state of the controls is DETACHED */
815 WinSetParent(ConsoleGlobals.hwndHorzScroll, /* detach control */
816 HWND_OBJECT,
817 FALSE);
818
819 WinSetParent(ConsoleGlobals.hwndVertScroll, /* detach control */
820 HWND_OBJECT,
821 FALSE);
822
823
824 /* create AVIO presentation space */
825 rc = VioCreatePS(&ConsoleGlobals.hvpsConsole,
826 ConsoleGlobals.coordWindowSize.Y,
827 ConsoleGlobals.coordWindowSize.X,
828 0, /* format, must be 0 */
829 FORMAT_CGA,
830 0); /* template hvps, must be 0 */
831 if (rc != NO_ERROR) /* check errors */
832 WriteLog("KERNEL32/CONSOLE:VioCreatePS=%u\n",
833 rc);
834
835 /* PH 1998/02/12 this seems to be an OS/2 PM bug:
836 when doing a WinOpenWindowDC here, PM hangs. Seems it never gets back into
837 the message loop. To investigate and report to IBM
838 */
839
840 /* get a device context for the client window */
841 ConsoleGlobals.hdcConsole = WinOpenWindowDC(hwnd);
842 /* associate AVIO PS with the HDC */
843 rc = VioAssociate(ConsoleGlobals.hdcConsole,
844 ConsoleGlobals.hvpsConsole);
845 if (rc != NO_ERROR) /* check errors */
846 WriteLog("KERNEL32/CONSOLE:VioAssociate=%u\n",
847 rc);
848
849 iConsoleFontQuery(); /* query current cell sizes */
850
851 /* adjust window size and position */
852 HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
853 DRQ_INTERNAL_CONSOLEADJUSTWINDOW,
854 0,
855 0,
856 0,
857 0);
858
859 /* @@@PH if console is maximized - now switched on per default ! */
860 WinSetWindowPos (ConsoleGlobals.hwndFrame,
861 HWND_DESKTOP,
862 0,
863 0,
864 ConsoleGlobals.Options.coordDefaultPosition.X *
865 ConsoleGlobals.sCellCX +
866 2 * WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER),
867 ConsoleGlobals.Options.coordDefaultPosition.Y *
868 ConsoleGlobals.sCellCY +
869 WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR) +
870 2 * WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER),
871 SWP_SIZE);
872
873 /* do we have to set the window position also ? */
874 if (ConsoleGlobals.Options.fSetWindowPosition == TRUE)
875 WinSetWindowPos (ConsoleGlobals.hwndFrame,
876 HWND_DESKTOP,
877 ConsoleGlobals.Options.coordDefaultPosition.X,
878 ConsoleGlobals.Options.coordDefaultPosition.Y,
879 0,
880 0,
881 SWP_MOVE);
882
883 /* start timer service for blitting and cursor blinking */
884 ConsoleGlobals.idTimer = WinStartTimer (ConsoleGlobals.hab,
885 hwnd,
886 CONSOLE_TIMER_ID, /* timer id */
887 ConsoleGlobals.ulTimerFrequency);
888
889 WinPostMsg (hwnd, /* send myself a start message so we get the first */
890 WM_TIMER, /* frame immediately */
891 (MPARAM)NULL,
892 (MPARAM)NULL);
893 }
894 break;
895
896
897 /*************************************************************************
898 * WM_DESTROY window destruction *
899 *************************************************************************/
900
901 case WM_DESTROY:
902 WinStopTimer (ConsoleGlobals.hab, /* anchor block */
903 hwnd,
904 ConsoleGlobals.idTimer); /* timer ID */
905
906 VioAssociate(NULL,
907 ConsoleGlobals.hvpsConsole); /* disassociates the AVIO PS */
908 VioDestroyPS(ConsoleGlobals.hvpsConsole); /* destroys the AVIO PS */
909
910 WinDestroyWindow(ConsoleGlobals.hwndMenuConsole);
911 WinDestroyPointer(ConsoleGlobals.hPtrConsole);
912 break;
913
914
915 /*************************************************************************
916 * WM_TIMER display cursor and update AVIO PS if required *
917 *************************************************************************/
918
919 case WM_TIMER:
920 /* check if console has to be updated */
921 if (ConsoleGlobals.fUpdateRequired == TRUE)
922 {
923 ConsoleGlobals.fUpdateRequired = FALSE; /* as soon as possible ! */
924
925 /* as device to map itself to the VIO buffer */
926 HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
927 DRQ_INTERNAL_CONSOLEBUFFERMAP,
928 0,
929 0,
930 0,
931 0);
932
933 { /* DEBUG */
934 APIRET rc;
935 /* and now bring it to the screen */
936 rc = VioShowPS(ConsoleGlobals.coordWindowSize.Y,
937 ConsoleGlobals.coordWindowSize.X,
938 0,
939 ConsoleGlobals.hvpsConsole);
940
941 dprintf(("KERNEL32::Console::1 VioShowPS(%u,%u,%u)=%u\n",
942 ConsoleGlobals.coordWindowSize.Y,
943 ConsoleGlobals.coordWindowSize.X,
944 ConsoleGlobals.hvpsConsole,
945 rc));
946 }
947
948 /* cursor is overwritten here ! */
949 HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
950 DRQ_INTERNAL_CONSOLECURSORSHOW,
951 CONSOLECURSOR_OVERWRITTEN,
952 0,
953 0,
954 0);
955 }
956 else
957 {
958 ConsoleGlobals.ulTimerCursor++; /* increase counter */
959 if (ConsoleGlobals.ulTimerCursor > ConsoleGlobals.Options.ucCursorDivisor)
960 {
961 ConsoleGlobals.ulTimerCursor = 0; /* reset counter */
962 /* let our cursor blink */
963 HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
964 DRQ_INTERNAL_CONSOLECURSORSHOW,
965 CONSOLECURSOR_BLINK,
966 0,
967 0,
968 0);
969 }
970 }
971 break;
972
973
974 /*************************************************************************
975 * WM_MINMAXFRAME handle window repaint in case of iconized window *
976 *************************************************************************/
977
978 case WM_MINMAXFRAME :
979 {
980 BOOL fShow = ! (((PSWP) mp1)->fl & SWP_MINIMIZE);
981 HENUM henum;
982 HWND hwndChild;
983
984 WinEnableWindowUpdate ( hwnd, FALSE );
985
986 for (henum=WinBeginEnumWindows(hwnd);
987 (hwndChild = WinGetNextWindow (henum)) != 0; )
988 WinShowWindow ( hwndChild, fShow );
989
990 WinEndEnumWindows ( henum );
991 WinEnableWindowUpdate ( hwnd, TRUE );
992 }
993 break;
994
995
996 /*************************************************************************
997 * WM_PAINT repaint the window *
998 *************************************************************************/
999 case WM_PAINT:
1000 hps = WinBeginPaint(hwnd,
1001 (HPS)NULL,
1002 &rcl);
1003 /* blit the whole AVIO presentation space */
1004 { /* DEBUG */
1005 APIRET rc;
1006 /* and now bring it to the screen */
1007 rc = VioShowPS(ConsoleGlobals.coordWindowSize.Y,
1008 ConsoleGlobals.coordWindowSize.X,
1009 0,
1010 ConsoleGlobals.hvpsConsole);
1011
1012 dprintf(("KERNEL32::Console::2 VioShowPS(%u,%u,%u)=%u\n",
1013 ConsoleGlobals.coordWindowSize.Y,
1014 ConsoleGlobals.coordWindowSize.X,
1015 ConsoleGlobals.hvpsConsole,
1016 rc));
1017 }
1018
1019 WinEndPaint(hps);
1020 break;
1021
1022
1023 /*************************************************************************
1024 * WM_SIZE resize the window *
1025 *************************************************************************/
1026 case WM_SIZE:
1027 {
1028 /* calculate scrollbars if neccessary */
1029 HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
1030 DRQ_INTERNAL_CONSOLEADJUSTWINDOW,
1031 0,
1032 0,
1033 0,
1034 0);
1035
1036 return WinDefAVioWindowProc(hwnd,
1037 (USHORT)msg,
1038 (ULONG)mp1,
1039 (ULONG)mp2);
1040 }
1041
1042
1043 /*************************************************************************
1044 * context menue *
1045 *************************************************************************/
1046 case WM_CONTEXTMENU:
1047 {
1048 WinPopupMenu (hwnd,
1049 hwnd,
1050 ConsoleGlobals.hwndMenuConsole,
1051 SHORT1FROMMP(mp1),
1052 SHORT2FROMMP(mp1),
1053 CM_CONSOLE_PROPERTIES, /* item id */
1054 PU_HCONSTRAIN |
1055 PU_VCONSTRAIN |
1056 PU_KEYBOARD |
1057 PU_MOUSEBUTTON1 |
1058 PU_MOUSEBUTTON2 |
1059 PU_POSITIONONITEM);
1060 }
1061 return (MPARAM)FALSE;
1062
1063
1064 /*************************************************************************
1065 * WM_COMMAND command processing *
1066 *************************************************************************/
1067 case WM_COMMAND:
1068 {
1069 switch(SHORT1FROMMP(mp1)) /* select appropriate identifier */
1070 {
1071 /* close console window, however we can't call ConsoleTerminate here!*/
1072 case CM_CONSOLE_EXIT:
1073 WinPostMsg (ConsoleGlobals.hwndFrame,
1074 WM_CLOSE,
1075 (MPARAM)NULL,
1076 (MPARAM)NULL);
1077
1078 return (MPARAM)FALSE;
1079
1080
1081 case CM_CONSOLE_REPAINT:
1082 WinInvalidateRect(ConsoleGlobals.hwndClient,/* redraw frame window */
1083 NULL,
1084 TRUE);
1085 return (MPARAM)FALSE;
1086
1087 /* open the properties dialog */
1088 case CM_CONSOLE_PROPERTIES:
1089 {
1090 ULONG ulResult; /* response from user */
1091
1092 ConsoleGlobals.Options.hmodResources = /* save module handle */
1093 ConsoleGlobals.hmodResource;
1094
1095 ulResult = WinDlgBox(HWND_DESKTOP,
1096 ConsoleGlobals.hwndClient,
1097 &ConsolePropertyDlgProc,
1098 ConsoleGlobals.hmodResource,
1099 DLG_CONSOLE_PROPERTIES,
1100 (PVOID)&ConsoleGlobals.Options);
1101 return (MPARAM) FALSE;
1102 }
1103 }
1104 }
1105 break;
1106
1107
1108 /*************************************************************************
1109 * WM_CHAR keyboard char processing *
1110 *************************************************************************/
1111
1112 case WM_CHAR:
1113 iConsoleInputEventPushKey(mp1, /* push event into queue */
1114 mp2);
1115 break; /* enable further processing ! */
1116
1117
1118 /*************************************************************************
1119 * WM_SETFOCUS focus changing processing *
1120 *************************************************************************/
1121
1122 case WM_SETFOCUS:
1123 iConsoleInputEventPushFocus((BOOL)mp2); /* push event into queue */
1124 break; /* enable further processing ! */
1125
1126
1127 /*************************************************************************
1128 * WM_MOUSEMOVE mouse event processing *
1129 *************************************************************************/
1130
1131 case WM_MOUSEMOVE:
1132 case WM_BUTTON1UP:
1133 case WM_BUTTON1DOWN:
1134 case WM_BUTTON2UP:
1135 case WM_BUTTON2DOWN:
1136 case WM_BUTTON3UP:
1137 case WM_BUTTON3DOWN:
1138 case WM_BUTTON1DBLCLK:
1139 case WM_BUTTON2DBLCLK:
1140 case WM_BUTTON3DBLCLK:
1141 iConsoleInputEventPushMouse(msg,
1142 mp1, /* push event into queue */
1143 mp2);
1144 break; /* enable further processing ! */
1145 }
1146
1147 return WinDefWindowProc(hwnd, /* to default processing */
1148 msg,
1149 mp1,
1150 mp2);
1151}
1152
1153
1154/*****************************************************************************
1155 * Name : static MRESULT EXPENTRY ConsoleFrameWindowProc
1156 * Purpose : Window Procedure for OUR console frame window
1157 * Parameters: HWND hwnd - window handle
1158 * ULONG msg - message identifier
1159 * MPARAM mp1 - message parameter 1
1160 * MPARAM mp2 - message parameter 2
1161 * Variables :
1162 * Result : MRESULT for PM
1163 * Remark :
1164 * Status :
1165 *
1166 * Author : Patrick Haller [Tue, 1998/02/10 03:24]
1167 *****************************************************************************/
1168
1169MRESULT EXPENTRY iConsoleFrameWindowProc(HWND hwnd,
1170 ULONG msg,
1171 MPARAM mp1,
1172 MPARAM mp2)
1173{
1174 switch(msg)
1175 {
1176 /*************************************************************************
1177 * WM_QUERYTRACKINFO handling *
1178 *************************************************************************/
1179 case WM_QUERYTRACKINFO:
1180 {
1181 MRESULT mr; /* message result */
1182 PTRACKINFO pTrackInfo; /* frame window tracking information */
1183
1184 /* let the original code do the hard work first */
1185 mr = ConsoleGlobals.pfnwpFrameOriginal(hwnd,
1186 msg,
1187 mp1,
1188 mp2);
1189
1190 pTrackInfo = (PTRACKINFO)mp2; /* get track information */
1191
1192 /* @@@PH */
1193 pTrackInfo->ptlMinTrackSize.x = max(pTrackInfo->ptlMinTrackSize.x, 200);
1194 pTrackInfo->ptlMinTrackSize.y = max(pTrackInfo->ptlMinTrackSize.y, 100);
1195 pTrackInfo->ptlMaxTrackSize.x = min(pTrackInfo->ptlMaxTrackSize.x, ConsoleGlobals.coordMaxWindowPels.X);
1196 pTrackInfo->ptlMaxTrackSize.y = min(pTrackInfo->ptlMaxTrackSize.y, ConsoleGlobals.coordMaxWindowPels.Y);
1197
1198 return (mr); /* deliver result */
1199 }
1200 }
1201
1202 /* call original frame window procedure code */
1203 return (ConsoleGlobals.pfnwpFrameOriginal(hwnd,
1204 msg,
1205 mp1,
1206 mp2));
1207}
1208
1209
1210/*****************************************************************************
1211 * Name : static void ConsoleBufferMap
1212 * Purpose : draw a whole consolebuffer into the VIO space
1213 * Parameters: PCONSOLEBUFFER pConsoleBuffer
1214 * Variables :
1215 * Result : none
1216 * Remark :
1217 * Status :
1218 *
1219 * Author : Patrick Haller [Tue, 1998/02/17 12:57]
1220 *****************************************************************************/
1221
1222void iConsoleBufferMap(PCONSOLEBUFFER pConsoleBuffer)
1223{
1224 ULONG ulLine;
1225
1226 ULONG ulSizeX; /* blitting length and height */
1227 ULONG ulSizeY;
1228
1229 ulSizeX = 2 * min(ConsoleGlobals.coordWindowSize.X,
1230 pConsoleBuffer->coordBufferSize.X -
1231 ConsoleGlobals.coordWindowPos.X);
1232
1233 ulSizeY = min(ConsoleGlobals.coordWindowSize.Y,
1234 pConsoleBuffer->coordBufferSize.Y -
1235 ConsoleGlobals.coordWindowPos.Y);
1236
1237 /* check if we're called with non-existing line buffer */
1238 if (pConsoleBuffer->ppszLine == NULL)
1239 return;
1240
1241 for (ulLine = ConsoleGlobals.coordWindowPos.Y;
1242 ulLine < ulSizeY;
1243 ulLine++)
1244 VioWrtCellStr(pConsoleBuffer->ppszLine[ulLine] +
1245 ConsoleGlobals.coordWindowPos.X,
1246 ulSizeX,
1247 ulLine,
1248 0,
1249 ConsoleGlobals.hvpsConsole);
1250}
1251
1252
1253/*****************************************************************************
1254 * Name : static void ConsoleBufferFillLine
1255 * Purpose : fills a line with a certain output pattern
1256 * Parameters: ULONG ulPattern, PUSHORT pusTarget, ULONG ulSize
1257 * Variables :
1258 * Result : none
1259 * Remark :
1260 * Status :
1261 *
1262 * Author : Patrick Haller [Tue, 1998/02/17 12:57]
1263 *****************************************************************************/
1264
1265void iConsoleBufferFillLine(ULONG ulPattern,
1266 PUSHORT pusTarget,
1267 ULONG ulSize)
1268{
1269 ULONG ulCounter;
1270
1271 for (ulCounter = 0;
1272 ulCounter < (ulSize >> 1);
1273 ulCounter++,
1274 pusTarget+=2)
1275 *(PULONG)pusTarget = ulPattern;
1276
1277 if (ulSize & 0x00000001)
1278 *pusTarget = (USHORT)ulPattern;
1279}
1280
1281
1282/*****************************************************************************
1283 * Name : static void ConsoleBufferScrollUp
1284 * Purpose : scroll whole buffer n lines up,
1285 * fill new lines with default attribute
1286 * Parameters: PCONSOLEBUFFER pConsoleBuffer
1287 * ULONG ulLines
1288 * Variables :
1289 * Result : none
1290 * Remark :
1291 * Status :
1292 *
1293 * Author : Patrick Haller [Tue, 1998/02/17 12:57]
1294 *****************************************************************************/
1295
1296void iConsoleBufferScrollUp(PCONSOLEBUFFER pConsoleBuffer,
1297 ULONG ulLines)
1298{
1299 ULONG ulLine;
1300 ULONG ulPosition;
1301 ULONG ulScrollLine;
1302
1303 static ULONG ulUpdateCounter; /* counter for jump-scrolling */
1304
1305 /* calculate new line offset to the first line */
1306 pConsoleBuffer->ulScrollLineOffset += ulLines;
1307 pConsoleBuffer->ulScrollLineOffset %= pConsoleBuffer->coordBufferSize.Y;
1308
1309 /* do we have to scroll ? */
1310 if (ulLines < pConsoleBuffer->coordBufferSize.Y)
1311 {
1312 for (ulLine = 0; /* do the scrolling */
1313 ulLine < ConsoleGlobals.coordWindowSize.Y;
1314 ulLine++)
1315 {
1316 ulScrollLine = (ulLine + pConsoleBuffer->ulScrollLineOffset)
1317 % pConsoleBuffer->coordBufferSize.Y;
1318
1319 ulPosition = (ULONG)pConsoleBuffer->ppszLine
1320 + (pConsoleBuffer->coordBufferSize.Y * sizeof (PSZ) )
1321 + (pConsoleBuffer->coordBufferSize.X * 2 * ulScrollLine);
1322
1323 pConsoleBuffer->ppszLine[ulLine] = (PSZ)ulPosition;
1324 }
1325 }
1326
1327 /* enforce the upper limit */
1328 if (ulLines > pConsoleBuffer->coordBufferSize.Y)
1329 ulLines = pConsoleBuffer->coordBufferSize.Y;
1330
1331 ulPosition = ( ((ULONG)(pConsoleBuffer->ucDefaultAttribute) << 8) +
1332 ((ULONG)' ') +
1333 ((ULONG)(pConsoleBuffer->ucDefaultAttribute) << 24) +
1334 ((ULONG)' ' << 16) );
1335
1336 /* scroll the line index */
1337 for (ulLine = pConsoleBuffer->coordBufferSize.Y - ulLines;
1338 ulLine < pConsoleBuffer->coordBufferSize.Y;
1339 ulLine++)
1340 iConsoleBufferFillLine(ulPosition,
1341 (PUSHORT)(pConsoleBuffer->ppszLine[ulLine]),
1342 pConsoleBuffer->coordBufferSize.X);
1343
1344 /* this code ensures frequent screen updating, even if the timer prooves */
1345 /* to be to slow */
1346 ulUpdateCounter++;
1347 if (ulUpdateCounter > ConsoleGlobals.Options.ulUpdateLimit)
1348 {
1349 ulUpdateCounter = 0; /* reset the counter */
1350 iConsoleBufferMap(pConsoleBuffer);
1351 VioShowPS(ConsoleGlobals.coordWindowSize.Y,
1352 ConsoleGlobals.coordWindowSize.X,
1353 0,
1354 ConsoleGlobals.hvpsConsole);
1355
1356 ConsoleGlobals.fUpdateRequired = FALSE; /* no more required ... */
1357 }
1358}
1359
1360
1361/*****************************************************************************
1362 * Name : static APIRET ConsoleInputEventPush
1363 * Purpose : add an element to the console input queue
1364 * Parameters: PINPUT_RECORD pInputRecord
1365 * Variables :
1366 * Result : API returncode
1367 * Remark :
1368 * Status :
1369 *
1370 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
1371 *****************************************************************************/
1372
1373APIRET iConsoleInputEventPush(PINPUT_RECORD pInputRecord)
1374{
1375 PINPUT_RECORD pirFree; /* pointer to free record */
1376 APIRET rc; /* API-returncode */
1377
1378#ifdef DEBUG_LOCAL2
1379 dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPush(%08x).\n",
1380 pInputRecord));
1381#endif
1382
1383 iConsoleInputQueueLock();
1384 /* get free event */
1385 pirFree = &ConsoleInput.arrInputRecord[ConsoleInput.ulIndexFree];
1386 if (pirFree->EventType != 0x0000)
1387 {
1388 iConsoleInputQueueUnlock();
1389 return (ERROR_QUE_NO_MEMORY); /* queue is full ! */
1390 }
1391 /* put event in queue */
1392
1393 ConsoleInput.ulIndexFree++; /* update index counter */
1394 if (ConsoleInput.ulIndexFree >= CONSOLE_INPUTQUEUESIZE)
1395 ConsoleInput.ulIndexFree = 0;
1396
1397 ConsoleInput.ulEvents++; /* increate queue event counter */
1398
1399 iConsoleInputQueueUnlock();
1400
1401 memcpy(pirFree, /* copy data */
1402 pInputRecord,
1403 sizeof (INPUT_RECORD) );
1404 /* unblock reading threads */
1405 rc = DosPostEventSem(ConsoleInput.hevInputQueue);
1406 return (rc); /* OK */
1407}
1408
1409
1410/*****************************************************************************
1411 * Name : static APIRET ConsoleInputEventPop
1412 * Purpose : read first element from the console input queue
1413 * Parameters: PINPUT_RECORD pInputRecord
1414 * Variables :
1415 * Result : API returncode
1416 * Remark :
1417 * Status :
1418 *
1419 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
1420 *****************************************************************************/
1421
1422APIRET iConsoleInputEventPop(PINPUT_RECORD pInputRecord)
1423{
1424 PINPUT_RECORD pirEvent; /* pointer to event record */
1425 APIRET rc; /* API-returncode */
1426
1427#ifdef DEBUG_LOCAL2
1428 dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPop(%08x).\n",
1429 pInputRecord));
1430#endif
1431
1432 if (ConsoleInput.ulEvents == 0) /* empty console ? */
1433 return (ERROR_QUE_EMPTY); /* queue is empty ! */
1434
1435 iConsoleInputQueueLock();
1436 /* get first event */
1437 pirEvent = &ConsoleInput.arrInputRecord[ConsoleInput.ulIndexEvent];
1438 if (pirEvent->EventType == 0x0000)
1439 {
1440 iConsoleInputQueueUnlock();
1441 return (ERROR_QUE_EMPTY); /* queue is empty ! */
1442 }
1443
1444 if (ConsoleInput.ulEvents >= 0) /* decrease number of console events */
1445 ConsoleInput.ulEvents--;
1446
1447 ConsoleInput.ulIndexEvent++; /* update index counter */
1448 if (ConsoleInput.ulIndexEvent >= CONSOLE_INPUTQUEUESIZE)
1449 ConsoleInput.ulIndexEvent = 0;
1450
1451 /* put event in queue */
1452 memcpy(pInputRecord, /* copy data */
1453 pirEvent,
1454 sizeof (INPUT_RECORD) );
1455
1456 pirEvent->EventType = 0x0000; /* mark event as read = free */
1457
1458 iConsoleInputQueueUnlock();
1459
1460 return (NO_ERROR); /* OK */
1461}
1462
1463
1464/*****************************************************************************
1465 * Name : static APIRET ConsoleInputEventPushKey
1466 * Purpose : push key event into the queue
1467 * Parameters: MPARAM mp1, MPARAM mp2 from WM_CHAR processing
1468 * Variables :
1469 * Result : API returncode
1470 * Remark : @@@PH: 2nd table that learns codes automatically from "down"
1471 * messages from PM. With Alt-a, etc. it is 0 for "up" ?
1472 * Status :
1473 *
1474 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
1475 *****************************************************************************/
1476
1477#define TABVIRTUALKEYCODES 0x6D
1478static tabVirtualKeyCodes[TABVIRTUALKEYCODES] =
1479{
1480/* --- PM key -- NT key --- */
1481 /* 0x00 */ 0,
1482 /* VK_BUTTON1 0x01 */ 0x01, /* WIN_VK_LBUTTON ??? */
1483 /* VK_BUTTON2 0x02 */ 0x02, /* WIN_VK_RBUTTON ??? */
1484 /* VK_BUTTON3 0x03 */ 0x04, /* WIN_VK_MBUTTON ??? */
1485 /* VK_BREAK 0x04 */ 0x03, /* WIN_VK_CANCEL ??? */
1486 /* VK_BACKSPACE 0x05 */ 0x08, /* WIN_VK_BACK */
1487 /* VK_TAB 0x06 */ 0x09, /* WIN_VK_TAB */
1488 /* VK_BACKTAB 0x07 */ 0,
1489 /* VK_NEWLINE 0x08 */ 0,
1490 /* VK_SHIFT 0x09 */ 0x10, /* WIN_VK_SHIFT */
1491 /* VK_CTRL 0x0A */ 0x11, /* WIN_VK_CONTROL */
1492 /* VK_ALT 0x0B */ 0x12, /* WIN_VK_MENU */
1493 /* VK_ALTGRAF 0x0C */ 0,
1494 /* VK_PAUSE 0x0D */ 0x13, /* WIN_VK_PAUSE */
1495 /* VK_CAPSLOCK 0x0E */ 0x14, /* WIN_VK_CAPITAL ??? */
1496 /* VK_ESC 0x0F */ 0x1b, /* WIN_VK_ESCAPE */
1497 /* VK_SPACE 0x10 */ 0x20, /* WIN_VK_SPACE */
1498 /* VK_PAGEUP 0x11 */ 0x21, /* WIN_VK_PRIOR ??? */
1499 /* VK_PAGEDOWN 0x12 */ 0x22, /* WIN_VK_NEXT ??? */
1500 /* VK_END 0x13 */ 0x23, /* WIN_VK_END */
1501 /* VK_HOME 0x14 */ 0x24, /* WIN_VK_HOME */
1502 /* VK_LEFT 0x15 */ 0x25, /* WIN_VK_LEFT */
1503 /* VK_UP 0x16 */ 0x26, /* WIN_VK_UP */
1504 /* VK_RIGHT 0x17 */ 0x27, /* WIN_VK_RIGHT */
1505 /* VK_DOWN 0x18 */ 0x28, /* WIN_VK_DOWN */
1506 /* VK_PRINTSCRN 0x19 */ 0x2A, /* WIN_VK_PRINT */
1507 /* VK_INSERT 0x1A */ 0x2D, /* WIN_VK_INSERT */
1508 /* VK_DELETE 0x1B */ 0x2E, /* WIN_VK_DELETE */
1509 /* VK_SCRLLOCK 0x1C */ 0x91, /* WIN_VK_SCROLL */
1510 /* VK_NUMLOCK 0x1D */ 0x90, /* WIN_VK_NUMLOCK */
1511 /* VK_ENTER 0x1E */ 0x0D, /* WIN_VK_RETURN */
1512 /* VK_SYSRQ 0x1F */ 0,
1513 /* VK_F1 0x20 */ 0x70, /* WIN_VK_F1 */
1514 /* VK_F2 0x21 */ 0x71, /* WIN_VK_F2 */
1515 /* VK_F3 0x22 */ 0x72, /* WIN_VK_F3 */
1516 /* VK_F4 0x23 */ 0x73, /* WIN_VK_F4 */
1517 /* VK_F5 0x24 */ 0x74, /* WIN_VK_F5 */
1518 /* VK_F6 0x25 */ 0x75, /* WIN_VK_F6 */
1519 /* VK_F7 0x26 */ 0x76, /* WIN_VK_F7 */
1520 /* VK_F8 0x27 */ 0x77, /* WIN_VK_F8 */
1521 /* VK_F9 0x28 */ 0x78, /* WIN_VK_F9 */
1522 /* VK_F10 0x29 */ 0x79, /* WIN_VK_F10 */
1523 /* VK_F11 0x2A */ 0x7A, /* WIN_VK_F11 */
1524 /* VK_F12 0x2B */ 0x7B, /* WIN_VK_F12 */
1525 /* VK_F13 0x2C */ 0x7C, /* WIN_VK_F13 */
1526 /* VK_F14 0x2D */ 0x7D, /* WIN_VK_F14 */
1527 /* VK_F15 0x2E */ 0x7E, /* WIN_VK_F15 */
1528 /* VK_F16 0x2F */ 0x7F, /* WIN_VK_F16 */
1529 /* VK_F17 0x30 */ 0x80, /* WIN_VK_F17 */
1530 /* VK_F18 0x31 */ 0x81, /* WIN_VK_F18 */
1531 /* VK_F19 0x32 */ 0x82, /* WIN_VK_F19 */
1532 /* VK_F20 0x33 */ 0x83, /* WIN_VK_F20 */
1533 /* VK_F21 0x34 */ 0x84, /* WIN_VK_F21 */
1534 /* VK_F22 0x35 */ 0x85, /* WIN_VK_F22 */
1535 /* VK_F23 0x36 */ 0x86, /* WIN_VK_F23 */
1536 /* VK_F24 0x37 */ 0x87, /* WIN_VK_F24 */
1537 /* VK_ENDDRAG 0x38 */ 0,
1538 /* VK_CLEAR 0x39 */ 0x0C, /* WIN_VK_CLEAR */
1539 /* VK_EREOF 0x3A */ 0xF9, /* WIN_VK_EREOF */
1540 /* VK_PA1 0x3B */ 0xFD, /* WIN_VK_PA1 */
1541 /* VK_ATTN 0x3C */ 0xF6, /* WIN_VK_ATTN */
1542 /* VK_CRSEL 0x3D */ 0xF7, /* WIN_VK_CRSEL */
1543 /* VK_EXSEL 0x3E */ 0xF8, /* WIN_VK_EXSEL */
1544 /* VK_COPY 0x3F */ 0,
1545 /* VK_BLK1 0x40 */ 0,
1546 /* VK_BLK2 0x41 */ 0,
1547 /* 0x42 */ 0,
1548 /* 0x43 */ 0,
1549 /* 0x44 */ 0,
1550 /* 0x45 */ 0,
1551 /* 0x46 */ 0,
1552 /* 0x47 */ 0,
1553 /* 0x48 */ 0,
1554 /* 0x49 */ 0,
1555 /* 0x4A */ 0,
1556 /* 0x4B */ 0,
1557 /* 0x4C */ 0,
1558 /* 0x4D */ 0,
1559 /* 0x4E */ 0,
1560 /* 0x4F */ 0,
1561 /* from UNIKBD.H: */
1562 /* VK_PA2 0x0050 */ 0,
1563 /* VK_PA3 0x0051 */ 0,
1564 /* VK_GROUP 0x0052 */ 0,
1565 /* VK_GROUPLOCK 0x0053 */ 0,
1566 /* VK_APPL 0x0054 */ 0x5D, /* WIN_VK_APPS ??? */
1567 /* VK_WINLEFT 0x0055 */ 0x5B, /* WIN_VK_LWIN */
1568 /* VK_WINRIGHT 0x0056 */ 0x5C, /* WIN_VK_RWIN */
1569 /* 0x0057 */ 0,
1570 /* 0x0058 */ 0,
1571 /* 0x0059 */ 0,
1572 /* 0x005A */ 0,
1573 /* 0x005B */ 0,
1574 /* 0x005C */ 0,
1575 /* 0x005D */ 0,
1576 /* 0x005E */ 0,
1577 /* 0x005F */ 0,
1578 /* 0x0060 */ 0,
1579 /* VK_M_DOWNLEFT 0x0061 */ 0,
1580 /* VK_M_DOWN 0x0062 */ 0,
1581 /* VK_M_DOWNRIGHT 0x0063 */ 0,
1582 /* VK_M_LEFT 0x0064 */ 0,
1583 /* VK_M_CENTER 0x0065 */ 0,
1584 /* VK_M_RIGHT 0x0066 */ 0,
1585 /* VK_M_UPLEFT 0x0067 */ 0,
1586 /* VK_M_UP 0x0068 */ 0,
1587 /* VK_M_UPRIGHT 0x0069 */ 0,
1588 /* VK_M_BUTTONLOCK 0x006A */ 0,
1589 /* VK_M_BUTTONRELEASE 0x006B */ 0,
1590 /* VK_M_DOUBLECLICK 0x006C */ 0,
1591
1592#if 0
15930xA4, /* WIN_VK_LMENU ??? */
15940xA5, /* WIN_VK_RMENU ??? */
1595#define VK_SELECT 0x29
1596#define VK_EXECUTE 0x2B
1597#define VK_SNAPSHOT 0x2C
1598#define VK_HELP 0x2F
1599#define VK_NUMPAD0 0x60
1600#define VK_NUMPAD1 0x61
1601#define VK_NUMPAD2 0x62
1602#define VK_NUMPAD3 0x63
1603#define VK_NUMPAD4 0x64
1604#define VK_NUMPAD5 0x65
1605#define VK_NUMPAD6 0x66
1606#define VK_NUMPAD7 0x67
1607#define VK_NUMPAD8 0x68
1608#define VK_NUMPAD9 0x69
1609#define VK_MULTIPLY 0x6A
1610#define VK_ADD 0x6B
1611#define VK_SEPARATOR 0x6C
1612#define VK_SUBTRACT 0x6D
1613#define VK_DECIMAL 0x6E
1614#define VK_DIVIDE 0x6F
1615#define VK_LSHIFT 0xA0
1616#define VK_RSHIFT 0xA1
1617#define VK_LCONTROL 0xA2
1618#define VK_RCONTROL 0xA3
1619#define VK_PROCESSKEY 0xE5
1620#define VK_PLAY 0xFA
1621#define VK_ZOOM 0xFB
1622#define VK_NONAME 0xFC
1623#define VK_OEM_CLEAR 0xFE
1624#endif
1625
1626};
1627
1628
1629APIRET iConsoleInputEventPushKey(MPARAM mp1,
1630 MPARAM mp2)
1631{
1632 INPUT_RECORD InputRecord; /* the input record structure */
1633 APIRET rc; /* API-returncode */
1634 USHORT fsFlags = ((ULONG)mp1 & 0x0000ffff); /* get key flags */
1635 UCHAR ucRepeat = ((ULONG)mp1 & 0x00ff0000) >> 16;
1636 UCHAR ucScanCode = ((ULONG)mp1 & 0xff000000) >> 24;
1637 UCHAR usCh = ((ULONG)mp2 & 0x0000ffff);
1638 USHORT usVk = ((ULONG)mp2 & 0xffff0000) >> 16;
1639 UCHAR ucChar = usCh & 0x00ff;
1640
1641#ifdef DEBUG_LOCAL2
1642 dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushKey(%08x,%08x).\n",
1643 mp1,
1644 mp2));
1645#endif
1646
1647
1648 InputRecord.EventType = KEY_EVENT; /* fill event structure */
1649 InputRecord.Event.KeyEvent.dwControlKeyState = 0;
1650
1651 if (fsFlags & KC_SHIFT) InputRecord.Event.KeyEvent.dwControlKeyState |= SHIFT_PRESSED;
1652 if (fsFlags & KC_ALT) InputRecord.Event.KeyEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
1653 if (fsFlags & KC_CTRL) InputRecord.Event.KeyEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
1654
1655 /* @@@PH no support for RIGHT_ALT_PRESSED,
1656 RIGHT_CTRL_PRESSED,
1657 NUMLOCK_ON,
1658 SCROLLLOCK_ON,
1659 CAPSLOCK_ON,
1660 ENHANCED_KEY
1661 */
1662
1663 InputRecord.Event.KeyEvent.bKeyDown = !(fsFlags & KC_KEYUP);
1664 InputRecord.Event.KeyEvent.wRepeatCount = ucRepeat;
1665 InputRecord.Event.KeyEvent.wVirtualKeyCode = usVk;
1666 InputRecord.Event.KeyEvent.wVirtualScanCode = ucScanCode;
1667
1668 /* check if ascii is valid, if so then wVirtualKeyCode = ascii, */
1669 /* else go through the table */
1670 if (fsFlags & KC_CHAR) /* usCh valid ? */
1671 {
1672 /* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
1673 /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
1674 if ( ( (usCh >= 'a') && (usCh <= 'z') ) || /* lowercase ? */
1675 ( (usCh >= '0') && (usCh <= '9') )
1676 )
1677 InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh & 0xDF;
1678 else
1679 InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh;
1680 }
1681 else
1682 if (fsFlags & KC_VIRTUALKEY) /* translate OS/2 virtual key code */
1683 {
1684 if (usVk < TABVIRTUALKEYCODES) /* limit to table size */
1685 InputRecord.Event.KeyEvent.wVirtualKeyCode =
1686 tabVirtualKeyCodes[usVk]; /* translate keycode */
1687 }
1688
1689 /* this is a workaround for empty / invalid wVirtualKeyCodes */
1690 if (InputRecord.Event.KeyEvent.wVirtualKeyCode == 0x0000)
1691 {
1692 if ( ( (usCh >= 'a') && (usCh <= 'z') ) || /* lowercase ? */
1693 ( (usCh >= '0') && (usCh <= '9') )
1694 )
1695 InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh & 0xDF;
1696 else
1697 InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh;
1698 }
1699
1700
1701 /* @@@PH handle special keys */
1702 if ( (ucChar != 0xe0) && (ucChar != 0x00) )
1703 InputRecord.Event.KeyEvent.uChar.AsciiChar = ucChar;
1704 else
1705 {
1706 /* extended key ! */
1707 InputRecord.Event.KeyEvent.dwControlKeyState |= ENHANCED_KEY;
1708 InputRecord.Event.KeyEvent.uChar.AsciiChar = (ucChar >> 8);
1709 }
1710
1711 /* further processing according the current input console mode */
1712 if (ConsoleInput.dwConsoleMode & ENABLE_PROCESSED_INPUT)
1713 {
1714 /* filter ctrl-c, etc. */
1715 }
1716
1717#if 0
1718 /* DEBUG */
1719 dprintf(("DEBUG: mp1=%08x mp2=%08x\n",
1720 mp1,
1721 mp2));
1722 dprintf(("DEBUG: fsFlags = %04x repeat=%u hwscan=%2x",
1723 fsFlags,
1724 ucRepeat,
1725 ucScanCode ));
1726 dprintf((" uscc=%04x usvk=%04x\n",
1727 SHORT1FROMMP(mp2),
1728 SHORT2FROMMP(mp2)));
1729
1730 dprintf(("DEBUG: ascii=[%c] (%02x)",
1731 InputRecord.Event.KeyEvent.uChar.AsciiChar,
1732 InputRecord.Event.KeyEvent.uChar.AsciiChar));
1733#endif
1734
1735 rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
1736 return (rc); /* OK */
1737}
1738
1739
1740/*****************************************************************************
1741 * Name : static APIRET ConsoleInputEventPushMouse
1742 * Purpose : push mouse event into the queue
1743 * Parameters: MPARAM mp1, MPARAM mp2 from WM_MOUSEMOVE processing
1744 * Variables :
1745 * Result : API returncode
1746 * Remark :
1747 * Status :
1748 *
1749 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
1750 *****************************************************************************/
1751
1752APIRET iConsoleInputEventPushMouse(ULONG ulMessage,
1753 MPARAM mp1,
1754 MPARAM mp2)
1755{
1756 INPUT_RECORD InputRecord; /* the input record structure */
1757 APIRET rc; /* API-returncode */
1758 USHORT fsFlags = SHORT2FROMMP(mp2); /* get key flags */
1759 static USHORT usButtonState; /* keeps track of mouse button state */
1760
1761 /* do we have to process mouse input ? */
1762 if ( !(ConsoleInput.dwConsoleMode & ENABLE_MOUSE_INPUT))
1763 return (NO_ERROR); /* return immediately */
1764
1765 dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushMouse(%08x,%08x,%08x).\n",
1766 ulMessage,
1767 mp1,
1768 mp2));
1769
1770 memset(&InputRecord, /* zero the structure */
1771 0,
1772 sizeof (INPUT_RECORD) );
1773
1774 InputRecord.EventType = MOUSE_EVENT; /* fill event structure */
1775
1776 switch (ulMessage)
1777 {
1778 case WM_MOUSEMOVE:
1779 InputRecord.Event.MouseEvent.dwEventFlags = MOUSE_MOVED;
1780 InputRecord.Event.MouseEvent.dwMousePosition.X = SHORT1FROMMP(mp1);
1781 InputRecord.Event.MouseEvent.dwMousePosition.Y = SHORT2FROMMP(mp1);
1782
1783 InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
1784
1785 if (fsFlags & KC_SHIFT) InputRecord.Event.MouseEvent.dwControlKeyState |= SHIFT_PRESSED;
1786 if (fsFlags & KC_ALT) InputRecord.Event.MouseEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
1787 if (fsFlags & KC_CTRL) InputRecord.Event.MouseEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
1788
1789 /* @@@PH no support for RIGHT_ALT_PRESSED,
1790 RIGHT_CTRL_PRESSED,
1791 NUMLOCK_ON,
1792 SCROLLLOCK_ON,
1793 CAPSLOCK_ON,
1794 ENHANCED_KEY
1795 */
1796 break;
1797
1798 case WM_BUTTON1UP:
1799 usButtonState &= ~FROM_LEFT_1ST_BUTTON_PRESSED;
1800 InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
1801 break;
1802
1803 case WM_BUTTON1DOWN:
1804 usButtonState |= FROM_LEFT_1ST_BUTTON_PRESSED;
1805 InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
1806 break;
1807
1808 case WM_BUTTON2UP:
1809 usButtonState &= ~FROM_LEFT_2ND_BUTTON_PRESSED;
1810 InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
1811 break;
1812
1813 case WM_BUTTON2DOWN:
1814 usButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
1815 InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
1816 break;
1817
1818 case WM_BUTTON3UP:
1819 usButtonState &= ~FROM_LEFT_3RD_BUTTON_PRESSED;
1820 InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
1821 break;
1822
1823 case WM_BUTTON3DOWN:
1824 usButtonState |= FROM_LEFT_3RD_BUTTON_PRESSED;
1825 InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
1826 break;
1827
1828 case WM_BUTTON1DBLCLK:
1829 InputRecord.Event.MouseEvent.dwEventFlags = DOUBLE_CLICK;
1830 InputRecord.Event.MouseEvent.dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1831 usButtonState &= ~FROM_LEFT_1ST_BUTTON_PRESSED;
1832 break;
1833
1834 case WM_BUTTON2DBLCLK:
1835 InputRecord.Event.MouseEvent.dwEventFlags = DOUBLE_CLICK;
1836 InputRecord.Event.MouseEvent.dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1837 usButtonState &= ~FROM_LEFT_2ND_BUTTON_PRESSED;
1838 break;
1839
1840 case WM_BUTTON3DBLCLK:
1841 InputRecord.Event.MouseEvent.dwEventFlags = DOUBLE_CLICK;
1842 InputRecord.Event.MouseEvent.dwButtonState = FROM_LEFT_3RD_BUTTON_PRESSED;
1843 usButtonState &= ~FROM_LEFT_3RD_BUTTON_PRESSED;
1844 break;
1845 }
1846
1847 /* @@@PH pseudo-support for RIGHTMOST_BUTTON_PRESSED */
1848 if (InputRecord.Event.MouseEvent.dwButtonState & FROM_LEFT_3RD_BUTTON_PRESSED)
1849 InputRecord.Event.MouseEvent.dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
1850
1851 rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
1852 return (rc); /* OK */
1853}
1854
1855
1856/*****************************************************************************
1857 * Name : static APIRET ConsoleInputEventPushWindow
1858 * Purpose : push menu event into the queue
1859 * Parameters: DWORD dwCommandId
1860 * Variables :
1861 * Result : API returncode
1862 * Remark :
1863 * Status :
1864 *
1865 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
1866 *****************************************************************************/
1867
1868APIRET iConsoleInputEventPushWindow(COORD coordWindowSize)
1869{
1870 INPUT_RECORD InputRecord; /* the input record structure */
1871 APIRET rc; /* API-returncode */
1872
1873 /* do we have to process window input ? */
1874 if ( !(ConsoleInput.dwConsoleMode & ENABLE_WINDOW_INPUT))
1875 return (NO_ERROR); /* return immediately */
1876
1877 dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushWindow(x = %u, y = %u).\n",
1878 coordWindowSize.X,
1879 coordWindowSize.Y));
1880
1881 InputRecord.EventType = WINDOW_BUFFER_SIZE_EVENT; /* fill event structure */
1882
1883 InputRecord.Event.WindowBufferSizeEvent.dwSize = coordWindowSize;
1884
1885 rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
1886 return (rc); /* OK */
1887}
1888
1889
1890/*****************************************************************************
1891 * Name : static APIRET ConsoleInputEventPushMenu
1892 * Purpose : push window event into the queue
1893 * Parameters: COORD coordWindowSize
1894 * Variables :
1895 * Result : API returncode
1896 * Remark :
1897 * Status :
1898 *
1899 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
1900 *****************************************************************************/
1901
1902APIRET iConsoleInputEventPushMenu(DWORD dwCommandId)
1903{
1904 INPUT_RECORD InputRecord; /* the input record structure */
1905 APIRET rc; /* API-returncode */
1906
1907 /* @@@PH this is unknown to me - there's no separate bit for menu events ? */
1908 /* do we have to process window input ? */
1909 if ( !(ConsoleInput.dwConsoleMode & ENABLE_WINDOW_INPUT))
1910 return (NO_ERROR); /* return immediately */
1911
1912 dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushMenu(%08x).\n",
1913 dwCommandId));
1914
1915 InputRecord.EventType = MENU_EVENT; /* fill event structure */
1916
1917 InputRecord.Event.MenuEvent.dwCommandId = dwCommandId;
1918
1919 rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
1920 return (rc); /* OK */
1921}
1922
1923
1924/*****************************************************************************
1925 * Name : static APIRET ConsoleInputEventPushFocus
1926 * Purpose : push focus event into the queue
1927 * Parameters: BOOL bSetFocus
1928 * Variables :
1929 * Result : API returncode
1930 * Remark :
1931 * Status :
1932 *
1933 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
1934 *****************************************************************************/
1935
1936APIRET iConsoleInputEventPushFocus(BOOL bSetFocus)
1937{
1938 INPUT_RECORD InputRecord; /* the input record structure */
1939 APIRET rc; /* API-returncode */
1940
1941 /* @@@PH this is unknown to me - there's no separate bit for menu events ? */
1942 /* do we have to process window input ? */
1943 if ( !(ConsoleInput.dwConsoleMode & ENABLE_WINDOW_INPUT))
1944 return (NO_ERROR); /* return immediately */
1945
1946 dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushFocus(%08x).\n",
1947 bSetFocus));
1948
1949 InputRecord.EventType = FOCUS_EVENT; /* fill event structure */
1950
1951 InputRecord.Event.FocusEvent.bSetFocus = bSetFocus;
1952
1953 rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
1954 return (rc); /* OK */
1955}
1956
1957
1958/*****************************************************************************
1959 * Name : static ULONG ConsoleInputQueueEvents
1960 * Purpose : query number of events in the queue
1961 * Parameters:
1962 * Variables :
1963 * Result : number of events
1964 * Remark :
1965 * Status :
1966 *
1967 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
1968 *****************************************************************************/
1969
1970ULONG iConsoleInputQueryEvents (void)
1971{
1972 return (ConsoleInput.ulEvents); /* return number of events in queue */
1973}
1974
1975
1976/*****************************************************************************
1977 * Name : static void ConsoleCursorShow
1978 * Purpose : query number of events in the queue
1979 * Parameters:
1980 * Variables :
1981 * Result : number of events
1982 * Remark :
1983 * Status :
1984 *
1985 * Author : Patrick Haller [Tue, 1998/03/07 16:55]
1986 *****************************************************************************/
1987
1988void iConsoleCursorShow (PCONSOLEBUFFER pConsoleBuffer,
1989 ULONG ulCursorMode)
1990{
1991 HPS hps; /* presentation space handle */
1992 RECTL rclCursor; /* the cursor rectangle */
1993 static BOOL fState; /* current cursor state */
1994 RECTL rclWindow; /* current window size */
1995
1996#ifdef DEBUG_LOCAL2
1997 dprintf(("KERNEL32:Console:ConsoleCursorShow(%u)\n",
1998 ulCursorMode));
1999#endif
2000
2001 if (pConsoleBuffer->CursorInfo.bVisible == FALSE)/* cursor is switched off */
2002 return; /* return immediately */
2003
2004 switch (ulCursorMode)
2005 {
2006 case CONSOLECURSOR_HIDE:
2007 if (fState == FALSE) /* cursor currently shown ? */
2008 return; /* no, abort immediately */
2009 else
2010 fState = FALSE; /* set to invisible and invert our cursor rect */
2011 break;
2012
2013 case CONSOLECURSOR_SHOW:
2014 if (fState == TRUE) /* cursor currently shown ? */
2015 return; /* yes,abort immediately */
2016 else
2017 fState = TRUE; /* set to visible and invert our cursor rect */
2018 break;
2019
2020 case CONSOLECURSOR_BLINK:
2021 fState = !fState; /* let there be on off on off on off on off ... */
2022 break;
2023
2024 case CONSOLECURSOR_OVERWRITTEN: /* our cursor has been overwritten */
2025 fState = TRUE; /* so show the cursor immediately */
2026 break;
2027 }
2028
2029
2030 /* query current window's size */
2031 WinQueryWindowRect(ConsoleGlobals.hwndClient,
2032 &rclWindow);
2033
2034 /* calculate coordinates of the cursor */
2035 rclCursor.xLeft = ConsoleGlobals.sCellCX * pConsoleBuffer->coordCursorPosition.X;
2036 rclCursor.xRight = rclCursor.xLeft + ConsoleGlobals.sCellCX;
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.