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

Last change on this file since 1444 was 1182, checked in by sandervl, 26 years ago

EB's accelerator fixes/changes

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