| 1 | /* $Id: console.cpp,v 1.1 1999-09-15 23:32:50 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 |
|
|---|
| 93 | extern "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 |
|
|---|
| 102 | inline void SetLastError(DWORD a)
|
|---|
| 103 | {
|
|---|
| 104 | USHORT sel = GetFS();
|
|---|
| 105 |
|
|---|
| 106 | _O32_SetLastError(a);
|
|---|
| 107 | SetFS(sel);
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | inline DWORD GetLastError()
|
|---|
| 111 | {
|
|---|
| 112 | DWORD yyrc;
|
|---|
| 113 | USHORT sel = GetFS();
|
|---|
| 114 |
|
|---|
| 115 | yyrc = _O32_GetLastError();
|
|---|
| 116 | SetFS(sel);
|
|---|
| 117 |
|
|---|
| 118 | return yyrc;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | inline LPSTR GetCommandLine()
|
|---|
| 122 | {
|
|---|
| 123 | LPSTR yyrc;
|
|---|
| 124 | USHORT sel = GetFS();
|
|---|
| 125 |
|
|---|
| 126 | yyrc = _O32_GetCommandLine();
|
|---|
| 127 | SetFS(sel);
|
|---|
| 128 |
|
|---|
| 129 | return yyrc;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | inline void ExitProcess(UINT a)
|
|---|
| 133 | {
|
|---|
| 134 | USHORT sel = GetFS();
|
|---|
| 135 |
|
|---|
| 136 | _O32_ExitProcess(a);
|
|---|
| 137 | SetFS(sel);
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | inline 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 |
|
|---|
| 151 | inline 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 |
|
|---|
| 177 | static ICONSOLEGLOBALS ConsoleGlobals;
|
|---|
| 178 | static 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 |
|
|---|
| 198 | void 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 |
|
|---|
| 222 | void 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 |
|
|---|
| 245 | APIRET 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 |
|
|---|
| 359 | APIRET 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 |
|
|---|
| 559 | ULONG 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 |
|
|---|
| 596 | void 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 |
|
|---|
| 639 | BOOL 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 |
|
|---|
| 657 | VOID 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 |
|
|---|
| 767 | MRESULT 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 |
|
|---|
| 1189 | MRESULT 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 |
|
|---|
| 1242 | void 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 |
|
|---|
| 1285 | void 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 |
|
|---|
| 1316 | void 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 |
|
|---|
| 1393 | APIRET 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 |
|
|---|
| 1442 | APIRET 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 |
|
|---|
| 1497 | #define TABVIRTUALKEYCODES 0x6D
|
|---|
| 1498 | static tabVirtualKeyCodes[TABVIRTUALKEYCODES] =
|
|---|
| 1499 | {
|
|---|
| 1500 | /* --- PM key -- NT key --- */
|
|---|
| 1501 | /* 0x00 */ 0,
|
|---|
| 1502 | /* VK_BUTTON1 0x01 */ 0x01, /* WIN_VK_LBUTTON ??? */
|
|---|
| 1503 | /* VK_BUTTON2 0x02 */ 0x02, /* WIN_VK_RBUTTON ??? */
|
|---|
| 1504 | /* VK_BUTTON3 0x03 */ 0x04, /* WIN_VK_MBUTTON ??? */
|
|---|
| 1505 | /* VK_BREAK 0x04 */ 0x03, /* WIN_VK_CANCEL ??? */
|
|---|
| 1506 | /* VK_BACKSPACE 0x05 */ 0x08, /* WIN_VK_BACK */
|
|---|
| 1507 | /* VK_TAB 0x06 */ 0x09, /* WIN_VK_TAB */
|
|---|
| 1508 | /* VK_BACKTAB 0x07 */ 0,
|
|---|
| 1509 | /* VK_NEWLINE 0x08 */ 0,
|
|---|
| 1510 | /* VK_SHIFT 0x09 */ 0x10, /* WIN_VK_SHIFT */
|
|---|
| 1511 | /* VK_CTRL 0x0A */ 0x11, /* WIN_VK_CONTROL */
|
|---|
| 1512 | /* VK_ALT 0x0B */ 0x12, /* WIN_VK_MENU */
|
|---|
| 1513 | /* VK_ALTGRAF 0x0C */ 0,
|
|---|
| 1514 | /* VK_PAUSE 0x0D */ 0x13, /* WIN_VK_PAUSE */
|
|---|
| 1515 | /* VK_CAPSLOCK 0x0E */ 0x14, /* WIN_VK_CAPITAL ??? */
|
|---|
| 1516 | /* VK_ESC 0x0F */ 0x1b, /* WIN_VK_ESCAPE */
|
|---|
| 1517 | /* VK_SPACE 0x10 */ 0x20, /* WIN_VK_SPACE */
|
|---|
| 1518 | /* VK_PAGEUP 0x11 */ 0x21, /* WIN_VK_PRIOR ??? */
|
|---|
| 1519 | /* VK_PAGEDOWN 0x12 */ 0x22, /* WIN_VK_NEXT ??? */
|
|---|
| 1520 | /* VK_END 0x13 */ 0x23, /* WIN_VK_END */
|
|---|
| 1521 | /* VK_HOME 0x14 */ 0x24, /* WIN_VK_HOME */
|
|---|
| 1522 | /* VK_LEFT 0x15 */ 0x25, /* WIN_VK_LEFT */
|
|---|
| 1523 | /* VK_UP 0x16 */ 0x26, /* WIN_VK_UP */
|
|---|
| 1524 | /* VK_RIGHT 0x17 */ 0x27, /* WIN_VK_RIGHT */
|
|---|
| 1525 | /* VK_DOWN 0x18 */ 0x28, /* WIN_VK_DOWN */
|
|---|
| 1526 | /* VK_PRINTSCRN 0x19 */ 0x2A, /* WIN_VK_PRINT */
|
|---|
| 1527 | /* VK_INSERT 0x1A */ 0x2D, /* WIN_VK_INSERT */
|
|---|
| 1528 | /* VK_DELETE 0x1B */ 0x2E, /* WIN_VK_DELETE */
|
|---|
| 1529 | /* VK_SCRLLOCK 0x1C */ 0x91, /* WIN_VK_SCROLL */
|
|---|
| 1530 | /* VK_NUMLOCK 0x1D */ 0x90, /* WIN_VK_NUMLOCK */
|
|---|
| 1531 | /* VK_ENTER 0x1E */ 0x0D, /* WIN_VK_RETURN */
|
|---|
| 1532 | /* VK_SYSRQ 0x1F */ 0,
|
|---|
| 1533 | /* VK_F1 0x20 */ 0x70, /* WIN_VK_F1 */
|
|---|
| 1534 | /* VK_F2 0x21 */ 0x71, /* WIN_VK_F2 */
|
|---|
| 1535 | /* VK_F3 0x22 */ 0x72, /* WIN_VK_F3 */
|
|---|
| 1536 | /* VK_F4 0x23 */ 0x73, /* WIN_VK_F4 */
|
|---|
| 1537 | /* VK_F5 0x24 */ 0x74, /* WIN_VK_F5 */
|
|---|
| 1538 | /* VK_F6 0x25 */ 0x75, /* WIN_VK_F6 */
|
|---|
| 1539 | /* VK_F7 0x26 */ 0x76, /* WIN_VK_F7 */
|
|---|
| 1540 | /* VK_F8 0x27 */ 0x77, /* WIN_VK_F8 */
|
|---|
| 1541 | /* VK_F9 0x28 */ 0x78, /* WIN_VK_F9 */
|
|---|
| 1542 | /* VK_F10 0x29 */ 0x79, /* WIN_VK_F10 */
|
|---|
| 1543 | /* VK_F11 0x2A */ 0x7A, /* WIN_VK_F11 */
|
|---|
| 1544 | /* VK_F12 0x2B */ 0x7B, /* WIN_VK_F12 */
|
|---|
| 1545 | /* VK_F13 0x2C */ 0x7C, /* WIN_VK_F13 */
|
|---|
| 1546 | /* VK_F14 0x2D */ 0x7D, /* WIN_VK_F14 */
|
|---|
| 1547 | /* VK_F15 0x2E */ 0x7E, /* WIN_VK_F15 */
|
|---|
| 1548 | /* VK_F16 0x2F */ 0x7F, /* WIN_VK_F16 */
|
|---|
| 1549 | /* VK_F17 0x30 */ 0x80, /* WIN_VK_F17 */
|
|---|
| 1550 | /* VK_F18 0x31 */ 0x81, /* WIN_VK_F18 */
|
|---|
| 1551 | /* VK_F19 0x32 */ 0x82, /* WIN_VK_F19 */
|
|---|
| 1552 | /* VK_F20 0x33 */ 0x83, /* WIN_VK_F20 */
|
|---|
| 1553 | /* VK_F21 0x34 */ 0x84, /* WIN_VK_F21 */
|
|---|
| 1554 | /* VK_F22 0x35 */ 0x85, /* WIN_VK_F22 */
|
|---|
| 1555 | /* VK_F23 0x36 */ 0x86, /* WIN_VK_F23 */
|
|---|
| 1556 | /* VK_F24 0x37 */ 0x87, /* WIN_VK_F24 */
|
|---|
| 1557 | /* VK_ENDDRAG 0x38 */ 0,
|
|---|
| 1558 | /* VK_CLEAR 0x39 */ 0x0C, /* WIN_VK_CLEAR */
|
|---|
| 1559 | /* VK_EREOF 0x3A */ 0xF9, /* WIN_VK_EREOF */
|
|---|
| 1560 | /* VK_PA1 0x3B */ 0xFD, /* WIN_VK_PA1 */
|
|---|
| 1561 | /* VK_ATTN 0x3C */ 0xF6, /* WIN_VK_ATTN */
|
|---|
| 1562 | /* VK_CRSEL 0x3D */ 0xF7, /* WIN_VK_CRSEL */
|
|---|
| 1563 | /* VK_EXSEL 0x3E */ 0xF8, /* WIN_VK_EXSEL */
|
|---|
| 1564 | /* VK_COPY 0x3F */ 0,
|
|---|
| 1565 | /* VK_BLK1 0x40 */ 0,
|
|---|
| 1566 | /* VK_BLK2 0x41 */ 0,
|
|---|
| 1567 | /* 0x42 */ 0,
|
|---|
| 1568 | /* 0x43 */ 0,
|
|---|
| 1569 | /* 0x44 */ 0,
|
|---|
| 1570 | /* 0x45 */ 0,
|
|---|
| 1571 | /* 0x46 */ 0,
|
|---|
| 1572 | /* 0x47 */ 0,
|
|---|
| 1573 | /* 0x48 */ 0,
|
|---|
| 1574 | /* 0x49 */ 0,
|
|---|
| 1575 | /* 0x4A */ 0,
|
|---|
| 1576 | /* 0x4B */ 0,
|
|---|
| 1577 | /* 0x4C */ 0,
|
|---|
| 1578 | /* 0x4D */ 0,
|
|---|
| 1579 | /* 0x4E */ 0,
|
|---|
| 1580 | /* 0x4F */ 0,
|
|---|
| 1581 | /* from UNIKBD.H: */
|
|---|
| 1582 | /* VK_PA2 0x0050 */ 0,
|
|---|
| 1583 | /* VK_PA3 0x0051 */ 0,
|
|---|
| 1584 | /* VK_GROUP 0x0052 */ 0,
|
|---|
| 1585 | /* VK_GROUPLOCK 0x0053 */ 0,
|
|---|
| 1586 | /* VK_APPL 0x0054 */ 0x5D, /* WIN_VK_APPS ??? */
|
|---|
| 1587 | /* VK_WINLEFT 0x0055 */ 0x5B, /* WIN_VK_LWIN */
|
|---|
| 1588 | /* VK_WINRIGHT 0x0056 */ 0x5C, /* WIN_VK_RWIN */
|
|---|
| 1589 | /* 0x0057 */ 0,
|
|---|
| 1590 | /* 0x0058 */ 0,
|
|---|
| 1591 | /* 0x0059 */ 0,
|
|---|
| 1592 | /* 0x005A */ 0,
|
|---|
| 1593 | /* 0x005B */ 0,
|
|---|
| 1594 | /* 0x005C */ 0,
|
|---|
| 1595 | /* 0x005D */ 0,
|
|---|
| 1596 | /* 0x005E */ 0,
|
|---|
| 1597 | /* 0x005F */ 0,
|
|---|
| 1598 | /* 0x0060 */ 0,
|
|---|
| 1599 | /* VK_M_DOWNLEFT 0x0061 */ 0,
|
|---|
| 1600 | /* VK_M_DOWN 0x0062 */ 0,
|
|---|
| 1601 | /* VK_M_DOWNRIGHT 0x0063 */ 0,
|
|---|
| 1602 | /* VK_M_LEFT 0x0064 */ 0,
|
|---|
| 1603 | /* VK_M_CENTER 0x0065 */ 0,
|
|---|
| 1604 | /* VK_M_RIGHT 0x0066 */ 0,
|
|---|
| 1605 | /* VK_M_UPLEFT 0x0067 */ 0,
|
|---|
| 1606 | /* VK_M_UP 0x0068 */ 0,
|
|---|
| 1607 | /* VK_M_UPRIGHT 0x0069 */ 0,
|
|---|
| 1608 | /* VK_M_BUTTONLOCK 0x006A */ 0,
|
|---|
| 1609 | /* VK_M_BUTTONRELEASE 0x006B */ 0,
|
|---|
| 1610 | /* VK_M_DOUBLECLICK 0x006C */ 0,
|
|---|
| 1611 |
|
|---|
| 1612 | #if 0
|
|---|
| 1613 | 0xA4, /* WIN_VK_LMENU ??? */
|
|---|
| 1614 | 0xA5, /* WIN_VK_RMENU ??? */
|
|---|
| 1615 | #define VK_SELECT 0x29
|
|---|
| 1616 | #define VK_EXECUTE 0x2B
|
|---|
| 1617 | #define VK_SNAPSHOT 0x2C
|
|---|
| 1618 | #define VK_HELP 0x2F
|
|---|
| 1619 | #define VK_NUMPAD0 0x60
|
|---|
| 1620 | #define VK_NUMPAD1 0x61
|
|---|
| 1621 | #define VK_NUMPAD2 0x62
|
|---|
| 1622 | #define VK_NUMPAD3 0x63
|
|---|
| 1623 | #define VK_NUMPAD4 0x64
|
|---|
| 1624 | #define VK_NUMPAD5 0x65
|
|---|
| 1625 | #define VK_NUMPAD6 0x66
|
|---|
| 1626 | #define VK_NUMPAD7 0x67
|
|---|
| 1627 | #define VK_NUMPAD8 0x68
|
|---|
| 1628 | #define VK_NUMPAD9 0x69
|
|---|
| 1629 | #define VK_MULTIPLY 0x6A
|
|---|
| 1630 | #define VK_ADD 0x6B
|
|---|
| 1631 | #define VK_SEPARATOR 0x6C
|
|---|
| 1632 | #define VK_SUBTRACT 0x6D
|
|---|
| 1633 | #define VK_DECIMAL 0x6E
|
|---|
| 1634 | #define VK_DIVIDE 0x6F
|
|---|
| 1635 | #define VK_LSHIFT 0xA0
|
|---|
| 1636 | #define VK_RSHIFT 0xA1
|
|---|
| 1637 | #define VK_LCONTROL 0xA2
|
|---|
| 1638 | #define VK_RCONTROL 0xA3
|
|---|
| 1639 | #define VK_PROCESSKEY 0xE5
|
|---|
| 1640 | #define VK_PLAY 0xFA
|
|---|
| 1641 | #define VK_ZOOM 0xFB
|
|---|
| 1642 | #define VK_NONAME 0xFC
|
|---|
| 1643 | #define VK_OEM_CLEAR 0xFE
|
|---|
| 1644 | #endif
|
|---|
| 1645 |
|
|---|
| 1646 | };
|
|---|
| 1647 |
|
|---|
| 1648 |
|
|---|
| 1649 | APIRET iConsoleInputEventPushKey(MPARAM mp1,
|
|---|
| 1650 | MPARAM mp2)
|
|---|
| 1651 | {
|
|---|
| 1652 | INPUT_RECORD InputRecord; /* the input record structure */
|
|---|
| 1653 | APIRET rc; /* API-returncode */
|
|---|
| 1654 | USHORT fsFlags = ((ULONG)mp1 & 0x0000ffff); /* get key flags */
|
|---|
| 1655 | UCHAR ucRepeat = ((ULONG)mp1 & 0x00ff0000) >> 16;
|
|---|
| 1656 | UCHAR ucScanCode = ((ULONG)mp1 & 0xff000000) >> 24;
|
|---|
| 1657 | UCHAR usCh = ((ULONG)mp2 & 0x0000ffff);
|
|---|
| 1658 | USHORT usVk = ((ULONG)mp2 & 0xffff0000) >> 16;
|
|---|
| 1659 | UCHAR ucChar = usCh & 0x00ff;
|
|---|
| 1660 |
|
|---|
| 1661 | #ifdef DEBUG_LOCAL2
|
|---|
| 1662 | dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushKey(%08x,%08x).\n",
|
|---|
| 1663 | mp1,
|
|---|
| 1664 | mp2));
|
|---|
| 1665 | #endif
|
|---|
| 1666 |
|
|---|
| 1667 |
|
|---|
| 1668 | InputRecord.EventType = KEY_EVENT; /* fill event structure */
|
|---|
| 1669 | InputRecord.Event.KeyEvent.dwControlKeyState = 0;
|
|---|
| 1670 |
|
|---|
| 1671 | if (fsFlags & KC_SHIFT) InputRecord.Event.KeyEvent.dwControlKeyState |= SHIFT_PRESSED;
|
|---|
| 1672 | if (fsFlags & KC_ALT) InputRecord.Event.KeyEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
|
|---|
| 1673 | if (fsFlags & KC_CTRL) InputRecord.Event.KeyEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
|
|---|
| 1674 |
|
|---|
| 1675 | /* @@@PH no support for RIGHT_ALT_PRESSED,
|
|---|
| 1676 | RIGHT_CTRL_PRESSED,
|
|---|
| 1677 | NUMLOCK_ON,
|
|---|
| 1678 | SCROLLLOCK_ON,
|
|---|
| 1679 | CAPSLOCK_ON,
|
|---|
| 1680 | ENHANCED_KEY
|
|---|
| 1681 | */
|
|---|
| 1682 |
|
|---|
| 1683 | InputRecord.Event.KeyEvent.bKeyDown = !(fsFlags & KC_KEYUP);
|
|---|
| 1684 | InputRecord.Event.KeyEvent.wRepeatCount = ucRepeat;
|
|---|
| 1685 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usVk;
|
|---|
| 1686 | InputRecord.Event.KeyEvent.wVirtualScanCode = ucScanCode;
|
|---|
| 1687 |
|
|---|
| 1688 | /* check if ascii is valid, if so then wVirtualKeyCode = ascii, */
|
|---|
| 1689 | /* else go through the table */
|
|---|
| 1690 | if (fsFlags & KC_CHAR) /* usCh valid ? */
|
|---|
| 1691 | {
|
|---|
| 1692 | /* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
|
|---|
| 1693 | /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
|
|---|
| 1694 | if ( ( (usCh >= 'a') && (usCh <= 'z') ) || /* lowercase ? */
|
|---|
| 1695 | ( (usCh >= '0') && (usCh <= '9') )
|
|---|
| 1696 | )
|
|---|
| 1697 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh & 0xDF;
|
|---|
| 1698 | else
|
|---|
| 1699 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh;
|
|---|
| 1700 | }
|
|---|
| 1701 | else
|
|---|
| 1702 | if (fsFlags & KC_VIRTUALKEY) /* translate OS/2 virtual key code */
|
|---|
| 1703 | {
|
|---|
| 1704 | if (usVk < TABVIRTUALKEYCODES) /* limit to table size */
|
|---|
| 1705 | InputRecord.Event.KeyEvent.wVirtualKeyCode =
|
|---|
| 1706 | tabVirtualKeyCodes[usVk]; /* translate keycode */
|
|---|
| 1707 | }
|
|---|
| 1708 |
|
|---|
| 1709 | /* this is a workaround for empty / invalid wVirtualKeyCodes */
|
|---|
| 1710 | if (InputRecord.Event.KeyEvent.wVirtualKeyCode == 0x0000)
|
|---|
| 1711 | {
|
|---|
| 1712 | if ( ( (usCh >= 'a') && (usCh <= 'z') ) || /* lowercase ? */
|
|---|
| 1713 | ( (usCh >= '0') && (usCh <= '9') )
|
|---|
| 1714 | )
|
|---|
| 1715 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh & 0xDF;
|
|---|
| 1716 | else
|
|---|
| 1717 | InputRecord.Event.KeyEvent.wVirtualKeyCode = usCh;
|
|---|
| 1718 | }
|
|---|
| 1719 |
|
|---|
| 1720 |
|
|---|
| 1721 | /* @@@PH handle special keys */
|
|---|
| 1722 | if ( (ucChar != 0xe0) && (ucChar != 0x00) )
|
|---|
| 1723 | InputRecord.Event.KeyEvent.uChar.AsciiChar = ucChar;
|
|---|
| 1724 | else
|
|---|
| 1725 | {
|
|---|
| 1726 | /* extended key ! */
|
|---|
| 1727 | InputRecord.Event.KeyEvent.dwControlKeyState |= ENHANCED_KEY;
|
|---|
| 1728 | InputRecord.Event.KeyEvent.uChar.AsciiChar = (ucChar >> 8);
|
|---|
| 1729 | }
|
|---|
| 1730 |
|
|---|
| 1731 | /* further processing according the current input console mode */
|
|---|
| 1732 | if (ConsoleInput.dwConsoleMode & ENABLE_PROCESSED_INPUT)
|
|---|
| 1733 | {
|
|---|
| 1734 | /* filter ctrl-c, etc. */
|
|---|
| 1735 | }
|
|---|
| 1736 |
|
|---|
| 1737 | #if 0
|
|---|
| 1738 | /* DEBUG */
|
|---|
| 1739 | dprintf(("DEBUG: mp1=%08x mp2=%08x\n",
|
|---|
| 1740 | mp1,
|
|---|
| 1741 | mp2));
|
|---|
| 1742 | dprintf(("DEBUG: fsFlags = %04x repeat=%u hwscan=%2x",
|
|---|
| 1743 | fsFlags,
|
|---|
| 1744 | ucRepeat,
|
|---|
| 1745 | ucScanCode ));
|
|---|
| 1746 | dprintf((" uscc=%04x usvk=%04x\n",
|
|---|
| 1747 | SHORT1FROMMP(mp2),
|
|---|
| 1748 | SHORT2FROMMP(mp2)));
|
|---|
| 1749 |
|
|---|
| 1750 | dprintf(("DEBUG: ascii=[%c] (%02x)",
|
|---|
| 1751 | InputRecord.Event.KeyEvent.uChar.AsciiChar,
|
|---|
| 1752 | InputRecord.Event.KeyEvent.uChar.AsciiChar));
|
|---|
| 1753 | #endif
|
|---|
| 1754 |
|
|---|
| 1755 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
|---|
| 1756 | return (rc); /* OK */
|
|---|
| 1757 | }
|
|---|
| 1758 |
|
|---|
| 1759 |
|
|---|
| 1760 | /*****************************************************************************
|
|---|
| 1761 | * Name : static APIRET ConsoleInputEventPushMouse
|
|---|
| 1762 | * Purpose : push mouse event into the queue
|
|---|
| 1763 | * Parameters: MPARAM mp1, MPARAM mp2 from WM_MOUSEMOVE processing
|
|---|
| 1764 | * Variables :
|
|---|
| 1765 | * Result : API returncode
|
|---|
| 1766 | * Remark :
|
|---|
| 1767 | * Status :
|
|---|
| 1768 | *
|
|---|
| 1769 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 1770 | *****************************************************************************/
|
|---|
| 1771 |
|
|---|
| 1772 | APIRET iConsoleInputEventPushMouse(ULONG ulMessage,
|
|---|
| 1773 | MPARAM mp1,
|
|---|
| 1774 | MPARAM mp2)
|
|---|
| 1775 | {
|
|---|
| 1776 | INPUT_RECORD InputRecord; /* the input record structure */
|
|---|
| 1777 | APIRET rc; /* API-returncode */
|
|---|
| 1778 | USHORT fsFlags = SHORT2FROMMP(mp2); /* get key flags */
|
|---|
| 1779 | static USHORT usButtonState; /* keeps track of mouse button state */
|
|---|
| 1780 |
|
|---|
| 1781 | /* do we have to process mouse input ? */
|
|---|
| 1782 | if ( !(ConsoleInput.dwConsoleMode & ENABLE_MOUSE_INPUT))
|
|---|
| 1783 | return (NO_ERROR); /* return immediately */
|
|---|
| 1784 |
|
|---|
| 1785 | dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushMouse(%08x,%08x,%08x).\n",
|
|---|
| 1786 | ulMessage,
|
|---|
| 1787 | mp1,
|
|---|
| 1788 | mp2));
|
|---|
| 1789 |
|
|---|
| 1790 | memset(&InputRecord, /* zero the structure */
|
|---|
| 1791 | 0,
|
|---|
| 1792 | sizeof (INPUT_RECORD) );
|
|---|
| 1793 |
|
|---|
| 1794 | InputRecord.EventType = MOUSE_EVENT; /* fill event structure */
|
|---|
| 1795 |
|
|---|
| 1796 | switch (ulMessage)
|
|---|
| 1797 | {
|
|---|
| 1798 | case WM_MOUSEMOVE:
|
|---|
| 1799 | InputRecord.Event.MouseEvent.dwEventFlags = MOUSE_MOVED;
|
|---|
| 1800 | InputRecord.Event.MouseEvent.dwMousePosition.X = SHORT1FROMMP(mp1);
|
|---|
| 1801 | InputRecord.Event.MouseEvent.dwMousePosition.Y = SHORT2FROMMP(mp1);
|
|---|
| 1802 |
|
|---|
| 1803 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
|---|
| 1804 |
|
|---|
| 1805 | if (fsFlags & KC_SHIFT) InputRecord.Event.MouseEvent.dwControlKeyState |= SHIFT_PRESSED;
|
|---|
| 1806 | if (fsFlags & KC_ALT) InputRecord.Event.MouseEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
|
|---|
| 1807 | if (fsFlags & KC_CTRL) InputRecord.Event.MouseEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
|
|---|
| 1808 |
|
|---|
| 1809 | /* @@@PH no support for RIGHT_ALT_PRESSED,
|
|---|
| 1810 | RIGHT_CTRL_PRESSED,
|
|---|
| 1811 | NUMLOCK_ON,
|
|---|
| 1812 | SCROLLLOCK_ON,
|
|---|
| 1813 | CAPSLOCK_ON,
|
|---|
| 1814 | ENHANCED_KEY
|
|---|
| 1815 | */
|
|---|
| 1816 | break;
|
|---|
| 1817 |
|
|---|
| 1818 | case WM_BUTTON1UP:
|
|---|
| 1819 | usButtonState &= ~FROM_LEFT_1ST_BUTTON_PRESSED;
|
|---|
| 1820 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
|---|
| 1821 | break;
|
|---|
| 1822 |
|
|---|
| 1823 | case WM_BUTTON1DOWN:
|
|---|
| 1824 | usButtonState |= FROM_LEFT_1ST_BUTTON_PRESSED;
|
|---|
| 1825 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
|---|
| 1826 | break;
|
|---|
| 1827 |
|
|---|
| 1828 | case WM_BUTTON2UP:
|
|---|
| 1829 | usButtonState &= ~FROM_LEFT_2ND_BUTTON_PRESSED;
|
|---|
| 1830 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
|---|
| 1831 | break;
|
|---|
| 1832 |
|
|---|
| 1833 | case WM_BUTTON2DOWN:
|
|---|
| 1834 | usButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
|
|---|
| 1835 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
|---|
| 1836 | break;
|
|---|
| 1837 |
|
|---|
| 1838 | case WM_BUTTON3UP:
|
|---|
| 1839 | usButtonState &= ~FROM_LEFT_3RD_BUTTON_PRESSED;
|
|---|
| 1840 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
|---|
| 1841 | break;
|
|---|
| 1842 |
|
|---|
| 1843 | case WM_BUTTON3DOWN:
|
|---|
| 1844 | usButtonState |= FROM_LEFT_3RD_BUTTON_PRESSED;
|
|---|
| 1845 | InputRecord.Event.MouseEvent.dwButtonState = usButtonState;
|
|---|
| 1846 | break;
|
|---|
| 1847 |
|
|---|
| 1848 | case WM_BUTTON1DBLCLK:
|
|---|
| 1849 | InputRecord.Event.MouseEvent.dwEventFlags = DOUBLE_CLICK;
|
|---|
| 1850 | InputRecord.Event.MouseEvent.dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
|
|---|
| 1851 | usButtonState &= ~FROM_LEFT_1ST_BUTTON_PRESSED;
|
|---|
| 1852 | break;
|
|---|
| 1853 |
|
|---|
| 1854 | case WM_BUTTON2DBLCLK:
|
|---|
| 1855 | InputRecord.Event.MouseEvent.dwEventFlags = DOUBLE_CLICK;
|
|---|
| 1856 | InputRecord.Event.MouseEvent.dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
|
|---|
| 1857 | usButtonState &= ~FROM_LEFT_2ND_BUTTON_PRESSED;
|
|---|
| 1858 | break;
|
|---|
| 1859 |
|
|---|
| 1860 | case WM_BUTTON3DBLCLK:
|
|---|
| 1861 | InputRecord.Event.MouseEvent.dwEventFlags = DOUBLE_CLICK;
|
|---|
| 1862 | InputRecord.Event.MouseEvent.dwButtonState = FROM_LEFT_3RD_BUTTON_PRESSED;
|
|---|
| 1863 | usButtonState &= ~FROM_LEFT_3RD_BUTTON_PRESSED;
|
|---|
| 1864 | break;
|
|---|
| 1865 | }
|
|---|
| 1866 |
|
|---|
| 1867 | /* @@@PH pseudo-support for RIGHTMOST_BUTTON_PRESSED */
|
|---|
| 1868 | if (InputRecord.Event.MouseEvent.dwButtonState & FROM_LEFT_3RD_BUTTON_PRESSED)
|
|---|
| 1869 | InputRecord.Event.MouseEvent.dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
|
|---|
| 1870 |
|
|---|
| 1871 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
|---|
| 1872 | return (rc); /* OK */
|
|---|
| 1873 | }
|
|---|
| 1874 |
|
|---|
| 1875 |
|
|---|
| 1876 | /*****************************************************************************
|
|---|
| 1877 | * Name : static APIRET ConsoleInputEventPushWindow
|
|---|
| 1878 | * Purpose : push menu event into the queue
|
|---|
| 1879 | * Parameters: DWORD dwCommandId
|
|---|
| 1880 | * Variables :
|
|---|
| 1881 | * Result : API returncode
|
|---|
| 1882 | * Remark :
|
|---|
| 1883 | * Status :
|
|---|
| 1884 | *
|
|---|
| 1885 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 1886 | *****************************************************************************/
|
|---|
| 1887 |
|
|---|
| 1888 | APIRET iConsoleInputEventPushWindow(COORD coordWindowSize)
|
|---|
| 1889 | {
|
|---|
| 1890 | INPUT_RECORD InputRecord; /* the input record structure */
|
|---|
| 1891 | APIRET rc; /* API-returncode */
|
|---|
| 1892 |
|
|---|
| 1893 | /* do we have to process window input ? */
|
|---|
| 1894 | if ( !(ConsoleInput.dwConsoleMode & ENABLE_WINDOW_INPUT))
|
|---|
| 1895 | return (NO_ERROR); /* return immediately */
|
|---|
| 1896 |
|
|---|
| 1897 | dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushWindow(x = %u, y = %u).\n",
|
|---|
| 1898 | coordWindowSize.X,
|
|---|
| 1899 | coordWindowSize.Y));
|
|---|
| 1900 |
|
|---|
| 1901 | InputRecord.EventType = WINDOW_BUFFER_SIZE_EVENT; /* fill event structure */
|
|---|
| 1902 |
|
|---|
| 1903 | InputRecord.Event.WindowBufferSizeEvent.dwSize = coordWindowSize;
|
|---|
| 1904 |
|
|---|
| 1905 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
|---|
| 1906 | return (rc); /* OK */
|
|---|
| 1907 | }
|
|---|
| 1908 |
|
|---|
| 1909 |
|
|---|
| 1910 | /*****************************************************************************
|
|---|
| 1911 | * Name : static APIRET ConsoleInputEventPushMenu
|
|---|
| 1912 | * Purpose : push window event into the queue
|
|---|
| 1913 | * Parameters: COORD coordWindowSize
|
|---|
| 1914 | * Variables :
|
|---|
| 1915 | * Result : API returncode
|
|---|
| 1916 | * Remark :
|
|---|
| 1917 | * Status :
|
|---|
| 1918 | *
|
|---|
| 1919 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 1920 | *****************************************************************************/
|
|---|
| 1921 |
|
|---|
| 1922 | APIRET iConsoleInputEventPushMenu(DWORD dwCommandId)
|
|---|
| 1923 | {
|
|---|
| 1924 | INPUT_RECORD InputRecord; /* the input record structure */
|
|---|
| 1925 | APIRET rc; /* API-returncode */
|
|---|
| 1926 |
|
|---|
| 1927 | /* @@@PH this is unknown to me - there's no separate bit for menu events ? */
|
|---|
| 1928 | /* do we have to process window input ? */
|
|---|
| 1929 | if ( !(ConsoleInput.dwConsoleMode & ENABLE_WINDOW_INPUT))
|
|---|
| 1930 | return (NO_ERROR); /* return immediately */
|
|---|
| 1931 |
|
|---|
| 1932 | dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushMenu(%08x).\n",
|
|---|
| 1933 | dwCommandId));
|
|---|
| 1934 |
|
|---|
| 1935 | InputRecord.EventType = MENU_EVENT; /* fill event structure */
|
|---|
| 1936 |
|
|---|
| 1937 | InputRecord.Event.MenuEvent.dwCommandId = dwCommandId;
|
|---|
| 1938 |
|
|---|
| 1939 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
|---|
| 1940 | return (rc); /* OK */
|
|---|
| 1941 | }
|
|---|
| 1942 |
|
|---|
| 1943 |
|
|---|
| 1944 | /*****************************************************************************
|
|---|
| 1945 | * Name : static APIRET ConsoleInputEventPushFocus
|
|---|
| 1946 | * Purpose : push focus event into the queue
|
|---|
| 1947 | * Parameters: BOOL bSetFocus
|
|---|
| 1948 | * Variables :
|
|---|
| 1949 | * Result : API returncode
|
|---|
| 1950 | * Remark :
|
|---|
| 1951 | * Status :
|
|---|
| 1952 | *
|
|---|
| 1953 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 1954 | *****************************************************************************/
|
|---|
| 1955 |
|
|---|
| 1956 | APIRET iConsoleInputEventPushFocus(BOOL bSetFocus)
|
|---|
| 1957 | {
|
|---|
| 1958 | INPUT_RECORD InputRecord; /* the input record structure */
|
|---|
| 1959 | APIRET rc; /* API-returncode */
|
|---|
| 1960 |
|
|---|
| 1961 | /* @@@PH this is unknown to me - there's no separate bit for menu events ? */
|
|---|
| 1962 | /* do we have to process window input ? */
|
|---|
| 1963 | if ( !(ConsoleInput.dwConsoleMode & ENABLE_WINDOW_INPUT))
|
|---|
| 1964 | return (NO_ERROR); /* return immediately */
|
|---|
| 1965 |
|
|---|
| 1966 | dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPushFocus(%08x).\n",
|
|---|
| 1967 | bSetFocus));
|
|---|
| 1968 |
|
|---|
| 1969 | InputRecord.EventType = FOCUS_EVENT; /* fill event structure */
|
|---|
| 1970 |
|
|---|
| 1971 | InputRecord.Event.FocusEvent.bSetFocus = bSetFocus;
|
|---|
| 1972 |
|
|---|
| 1973 | rc = iConsoleInputEventPush(&InputRecord); /* add it to the queue */
|
|---|
| 1974 | return (rc); /* OK */
|
|---|
| 1975 | }
|
|---|
| 1976 |
|
|---|
| 1977 |
|
|---|
| 1978 | /*****************************************************************************
|
|---|
| 1979 | * Name : static ULONG ConsoleInputQueueEvents
|
|---|
| 1980 | * Purpose : query number of events in the queue
|
|---|
| 1981 | * Parameters:
|
|---|
| 1982 | * Variables :
|
|---|
| 1983 | * Result : number of events
|
|---|
| 1984 | * Remark :
|
|---|
| 1985 | * Status :
|
|---|
| 1986 | *
|
|---|
| 1987 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 1988 | *****************************************************************************/
|
|---|
| 1989 |
|
|---|
| 1990 | ULONG iConsoleInputQueryEvents (void)
|
|---|
| 1991 | {
|
|---|
| 1992 | return (ConsoleInput.ulEvents); /* return number of events in queue */
|
|---|
| 1993 | }
|
|---|
| 1994 |
|
|---|
| 1995 |
|
|---|
| 1996 | /*****************************************************************************
|
|---|
| 1997 | * Name : static void ConsoleCursorShow
|
|---|
| 1998 | * Purpose : query number of events in the queue
|
|---|
| 1999 | * Parameters:
|
|---|
| 2000 | * Variables :
|
|---|
| 2001 | * Result : number of events
|
|---|
| 2002 | * Remark :
|
|---|
| 2003 | * Status :
|
|---|
| 2004 | *
|
|---|
| 2005 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 2006 | *****************************************************************************/
|
|---|
| 2007 |
|
|---|
| 2008 | void iConsoleCursorShow (PCONSOLEBUFFER pConsoleBuffer,
|
|---|
| 2009 | ULONG ulCursorMode)
|
|---|
| 2010 | {
|
|---|
| 2011 | HPS hps; /* presentation space handle */
|
|---|
| 2012 | RECTL rclCursor; /* the cursor rectangle */
|
|---|
| 2013 | static BOOL fState; /* current cursor state */
|
|---|
| 2014 | RECTL rclWindow; /* current window size */
|
|---|
| 2015 |
|
|---|
| 2016 | #ifdef DEBUG_LOCAL2
|
|---|
| 2017 | dprintf(("KERNEL32:Console:ConsoleCursorShow(%u)\n",
|
|---|
| 2018 | ulCursorMode));
|
|---|
| 2019 | #endif
|
|---|
| 2020 |
|
|---|
| 2021 | if (pConsoleBuffer->CursorInfo.bVisible == FALSE)/* cursor is switched off */
|
|---|
| 2022 | return; /* return immediately */
|
|---|
| 2023 |
|
|---|
| 2024 | switch (ulCursorMode)
|
|---|
| 2025 | {
|
|---|
| 2026 | case CONSOLECURSOR_HIDE:
|
|---|
| 2027 | if (fState == FALSE) /* cursor currently shown ? */
|
|---|
| 2028 | return; /* no, abort immediately */
|
|---|
| 2029 | else
|
|---|
| 2030 | fState = FALSE; /* set to invisible and invert our cursor rect */
|
|---|
| 2031 | break;
|
|---|
| 2032 |
|
|---|
| 2033 | case CONSOLECURSOR_SHOW:
|
|---|
| 2034 | if (fState == TRUE) /* cursor currently shown ? */
|
|---|
| 2035 | return; /* yes,abort immediately */
|
|---|
| 2036 | else
|
|---|
| 2037 | fState = TRUE; /* set to visible and invert our cursor rect */
|
|---|
| 2038 | break;
|
|---|
| 2039 |
|
|---|
| 2040 | case CONSOLECURSOR_BLINK:
|
|---|
| 2041 | fState = !fState; /* let there be on off on off on off on off ... */
|
|---|
| 2042 | break;
|
|---|
| 2043 |
|
|---|
| 2044 | case CONSOLECURSOR_OVERWRITTEN: /* our cursor has been overwritten */
|
|---|
| 2045 | fState = TRUE; /* so show the cursor immediately */
|
|---|
| 2046 | break;
|
|---|
| 2047 | }
|
|---|
| 2048 |
|
|---|
| 2049 |
|
|---|
| 2050 | /* query current window's size */
|
|---|
| 2051 | WinQueryWindowRect(ConsoleGlobals.hwndClient,
|
|---|
| 2052 | &rclWindow);
|
|---|
| 2053 |
|
|---|
| 2054 | /* calculate coordinates of the cursor */
|
|---|
| 2055 | rclCursor.xLeft = ConsoleGlobals.sCellCX * pConsoleBuffer->coordCursorPosition.X;
|
|---|
| 2056 | rclCursor.xRight = rclCursor.xLeft + ConsoleGlobals.sCellCX;
|
|---|
| 2057 | rclCursor.yBottom = rclWindow.yTop
|
|---|
| 2058 | - ConsoleGlobals.sCellCY * (pConsoleBuffer->coordCursorPosition.Y + 1);
|
|---|
| 2059 | rclCursor.yTop = rclCursor.yBottom + /* cursor height in percent */
|
|---|
| 2060 | (ConsoleGlobals.sCellCY *
|
|---|
| 2061 | pConsoleBuffer->CursorInfo.dwSize /
|
|---|
| 2062 | 100);
|
|---|
| 2063 |
|
|---|
| 2064 | hps = WinGetPS(ConsoleGlobals.hwndClient); /* get HPS */
|
|---|
| 2065 |
|
|---|
| 2066 | /* @@@PH invert coordinates here ... */
|
|---|
| 2067 | WinInvertRect(hps, /* our cursor is an inverted rectangle */
|
|---|
| 2068 | &rclCursor);
|
|---|
| 2069 |
|
|---|
| 2070 | WinReleasePS(hps); /* release the hps again */
|
|---|
| 2071 | }
|
|---|
| 2072 |
|
|---|
| 2073 |
|
|---|
| 2074 | /*****************************************************************************
|
|---|
| 2075 | * Name : static APIRET ConsoleFontQuery
|
|---|
| 2076 | * Purpose : queries the current font cell sizes
|
|---|
| 2077 | * Parameters:
|
|---|
| 2078 | * Variables :
|
|---|
| 2079 | * Result : API returncode
|
|---|
| 2080 | * Remark :
|
|---|
| 2081 | * Status :
|
|---|
| 2082 | *
|
|---|
| 2083 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 2084 | *****************************************************************************/
|
|---|
| 2085 |
|
|---|
| 2086 | APIRET iConsoleFontQuery (void)
|
|---|
| 2087 | {
|
|---|
| 2088 | return(VioGetDeviceCellSize(&ConsoleGlobals.sCellCY, /* query VIO manager */
|
|---|
| 2089 | &ConsoleGlobals.sCellCX,
|
|---|
| 2090 | ConsoleGlobals.hvpsConsole));
|
|---|
| 2091 | }
|
|---|
| 2092 |
|
|---|
| 2093 |
|
|---|
| 2094 | /*****************************************************************************
|
|---|
| 2095 | * Name : static void ConsoleCursorShow
|
|---|
| 2096 | * Purpose : query number of events in the queue
|
|---|
| 2097 | * Parameters:
|
|---|
| 2098 | * Variables :
|
|---|
| 2099 | * Result : number of events
|
|---|
| 2100 | * Remark : called during INIT, FONTCHANGE, RESIZE, BUFFERCHANGE
|
|---|
| 2101 | * Status :
|
|---|
| 2102 | *
|
|---|
| 2103 | * Author : Patrick Haller [Wed, 1998/04/29 16:55]
|
|---|
| 2104 | *****************************************************************************/
|
|---|
| 2105 |
|
|---|
| 2106 | void iConsoleAdjustWindow (PCONSOLEBUFFER pConsoleBuffer)
|
|---|
| 2107 | {
|
|---|
| 2108 | LONG lX, lY; /* temporary long values */
|
|---|
| 2109 | RECTL rcl;
|
|---|
| 2110 | PRECTL pRcl = &rcl;
|
|---|
| 2111 | ULONG flStyle; /* window frame control style */
|
|---|
| 2112 |
|
|---|
| 2113 | BOOL fNeedVertScroll; /* indicates need of scrollbars */
|
|---|
| 2114 | BOOL fNeedHorzScroll;
|
|---|
| 2115 |
|
|---|
| 2116 | LONG lScrollX; /* width and height of scrollbars */
|
|---|
| 2117 | LONG lScrollY;
|
|---|
| 2118 |
|
|---|
| 2119 | /* now calculate actual window size */
|
|---|
| 2120 | lX = ConsoleGlobals.sCellCX * ConsoleGlobals.coordWindowSize.X;
|
|---|
| 2121 | lY = ConsoleGlobals.sCellCY * ConsoleGlobals.coordWindowSize.Y;
|
|---|
| 2122 |
|
|---|
| 2123 | if ( (ConsoleGlobals.sCellCX == 0) || /* prevent division by zero */
|
|---|
| 2124 | (ConsoleGlobals.sCellCY == 0) )
|
|---|
| 2125 | return;
|
|---|
| 2126 |
|
|---|
| 2127 | /* calculate maximum console window size in pixels for the tracking */
|
|---|
| 2128 | ConsoleGlobals.coordMaxWindowPels.X = ConsoleGlobals.sCellCX * pConsoleBuffer->coordWindowSize.X
|
|---|
| 2129 | + WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER) * 2;
|
|---|
| 2130 |
|
|---|
| 2131 | ConsoleGlobals.coordMaxWindowPels.Y = ConsoleGlobals.sCellCY * pConsoleBuffer->coordWindowSize.Y
|
|---|
| 2132 | + WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER) * 2
|
|---|
| 2133 | + WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);
|
|---|
| 2134 |
|
|---|
| 2135 | /***************************/
|
|---|
| 2136 | /* @@@PH broken code below */
|
|---|
| 2137 | /***************************/
|
|---|
| 2138 | return;
|
|---|
| 2139 |
|
|---|
| 2140 | /* add the window border height and width, etc. */
|
|---|
| 2141 | WinQueryWindowRect (ConsoleGlobals.hwndClient,
|
|---|
| 2142 | pRcl);
|
|---|
| 2143 |
|
|---|
| 2144 | /* calculate visible area */
|
|---|
| 2145 | /* calculate real client window rectangle and take care of the scrollbars */
|
|---|
| 2146 | lScrollX = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
|
|---|
| 2147 | lScrollY = WinQuerySysValue(HWND_DESKTOP, SV_CYHSCROLL);
|
|---|
| 2148 | if (ConsoleGlobals.fHasHorzScroll)
|
|---|
| 2149 | {
|
|---|
| 2150 | lY += lScrollY;
|
|---|
| 2151 | ConsoleGlobals.coordMaxWindowPels.Y += lScrollY;
|
|---|
| 2152 | }
|
|---|
| 2153 |
|
|---|
| 2154 | if (ConsoleGlobals.fHasVertScroll)
|
|---|
| 2155 | {
|
|---|
| 2156 | lX += lScrollX;
|
|---|
| 2157 | ConsoleGlobals.coordMaxWindowPels.X += lScrollX;
|
|---|
| 2158 | }
|
|---|
| 2159 |
|
|---|
| 2160 | /* @@@PH might NOT exceed maximum VioPS size ! */
|
|---|
| 2161 | ConsoleGlobals.coordWindowSize.X = (pRcl->xRight - pRcl->xLeft)
|
|---|
| 2162 | / ConsoleGlobals.sCellCX;
|
|---|
| 2163 |
|
|---|
| 2164 | ConsoleGlobals.coordWindowSize.Y = (pRcl->yTop - pRcl->yBottom)
|
|---|
| 2165 | / ConsoleGlobals.sCellCY;
|
|---|
| 2166 |
|
|---|
| 2167 | /* do we have to enable the scrollbars ? */
|
|---|
| 2168 | fNeedHorzScroll = lX < pConsoleBuffer->coordWindowSize.X * ConsoleGlobals.sCellCX;
|
|---|
| 2169 | fNeedVertScroll = lY < pConsoleBuffer->coordWindowSize.Y * ConsoleGlobals.sCellCY;
|
|---|
| 2170 |
|
|---|
| 2171 |
|
|---|
| 2172 | if ( (ConsoleGlobals.fHasVertScroll != fNeedVertScroll) ||
|
|---|
| 2173 | (ConsoleGlobals.fHasHorzScroll != fNeedHorzScroll) )
|
|---|
| 2174 | {
|
|---|
| 2175 | flStyle = WinQueryWindowULong(ConsoleGlobals.hwndFrame,
|
|---|
| 2176 | QWL_STYLE);
|
|---|
| 2177 |
|
|---|
| 2178 | /* now set or remove the controls */
|
|---|
| 2179 | if (ConsoleGlobals.fHasHorzScroll != fNeedHorzScroll)
|
|---|
| 2180 | if (fNeedHorzScroll)
|
|---|
| 2181 | {
|
|---|
| 2182 | flStyle |= FCF_HORZSCROLL;
|
|---|
| 2183 | WinSetParent(ConsoleGlobals.hwndHorzScroll, /* attach control */
|
|---|
| 2184 | ConsoleGlobals.hwndFrame,
|
|---|
| 2185 | FALSE);
|
|---|
| 2186 | }
|
|---|
| 2187 | else
|
|---|
| 2188 | {
|
|---|
| 2189 | flStyle &= ~FCF_HORZSCROLL;
|
|---|
| 2190 | WinSetParent(ConsoleGlobals.hwndHorzScroll, /* detach control */
|
|---|
| 2191 | HWND_OBJECT,
|
|---|
| 2192 | FALSE);
|
|---|
| 2193 | ConsoleGlobals.coordWindowPos.X = 0; /* we can see the whole buffer */
|
|---|
| 2194 | }
|
|---|
| 2195 |
|
|---|
| 2196 | if (ConsoleGlobals.fHasVertScroll != fNeedVertScroll)
|
|---|
| 2197 | if (fNeedVertScroll)
|
|---|
| 2198 | {
|
|---|
| 2199 | flStyle |= FCF_VERTSCROLL;
|
|---|
| 2200 | WinSetParent(ConsoleGlobals.hwndVertScroll, /* attach control */
|
|---|
| 2201 | ConsoleGlobals.hwndFrame,
|
|---|
| 2202 | FALSE);
|
|---|
| 2203 | }
|
|---|
| 2204 | else
|
|---|
| 2205 | {
|
|---|
| 2206 | flStyle &= ~FCF_VERTSCROLL;
|
|---|
| 2207 | WinSetParent(ConsoleGlobals.hwndVertScroll, /* detach control */
|
|---|
| 2208 | HWND_OBJECT,
|
|---|
| 2209 | FALSE);
|
|---|
| 2210 | ConsoleGlobals.coordWindowPos.Y = 0; /* we can see the whole buffer */
|
|---|
| 2211 | }
|
|---|
| 2212 |
|
|---|
| 2213 |
|
|---|
| 2214 | WinSendMsg(ConsoleGlobals.hwndFrame, /* update frame */
|
|---|
| 2215 | WM_UPDATEFRAME,
|
|---|
| 2216 | MPFROMLONG(flStyle),
|
|---|
| 2217 | MPVOID);
|
|---|
| 2218 |
|
|---|
| 2219 | WinInvalidateRect(ConsoleGlobals.hwndFrame, /* redraw frame window */
|
|---|
| 2220 | NULL,
|
|---|
| 2221 | TRUE);
|
|---|
| 2222 |
|
|---|
| 2223 | ConsoleGlobals.fHasVertScroll = fNeedVertScroll; /* update globals */
|
|---|
| 2224 | ConsoleGlobals.fHasHorzScroll = fNeedHorzScroll; /* update globals */
|
|---|
| 2225 | }
|
|---|
| 2226 |
|
|---|
| 2227 |
|
|---|
| 2228 | /* setup the scrollbars and scrollranges */
|
|---|
| 2229 | if (ConsoleGlobals.fHasVertScroll)
|
|---|
| 2230 | {
|
|---|
| 2231 | /* setup vertical scrollbar */
|
|---|
| 2232 | }
|
|---|
| 2233 |
|
|---|
| 2234 |
|
|---|
| 2235 | if (ConsoleGlobals.fHasHorzScroll)
|
|---|
| 2236 | {
|
|---|
| 2237 | /* setup horizonal scrollbar */
|
|---|
| 2238 | }
|
|---|
| 2239 |
|
|---|
| 2240 |
|
|---|
| 2241 | WinCalcFrameRect(ConsoleGlobals.hwndFrame, /* calculate frame rectangle */
|
|---|
| 2242 | pRcl,
|
|---|
| 2243 | FALSE);
|
|---|
| 2244 |
|
|---|
| 2245 | /* @@@PH client may not overlap frame ! */
|
|---|
| 2246 | /* @@@PH write values to TRACKINFO */
|
|---|
| 2247 |
|
|---|
| 2248 | #if 0
|
|---|
| 2249 | /* @@@PH this results in recursion */
|
|---|
| 2250 | WinSetWindowPos (ConsoleGlobals.hwndClient, /* adjust client window size */
|
|---|
| 2251 | ConsoleGlobals.hwndFrame,
|
|---|
| 2252 | 0,
|
|---|
| 2253 | 0,
|
|---|
| 2254 | lX,
|
|---|
| 2255 | lY,
|
|---|
| 2256 | SWP_SIZE);
|
|---|
| 2257 |
|
|---|
| 2258 | WinSetWindowPos (ConsoleGlobals.hwndFrame, /* adjust client window size */
|
|---|
| 2259 | HWND_DESKTOP,
|
|---|
| 2260 | pRcl->xLeft,
|
|---|
| 2261 | pRcl->yBottom,
|
|---|
| 2262 | pRcl->xRight,
|
|---|
| 2263 | pRcl->yTop,
|
|---|
| 2264 | SWP_SIZE);
|
|---|
| 2265 | #endif
|
|---|
| 2266 | }
|
|---|
| 2267 |
|
|---|
| 2268 |
|
|---|
| 2269 | /*****************************************************************************
|
|---|
| 2270 | * Name : BOOL WIN32API AllocConsole
|
|---|
| 2271 | * Purpose : The AllocConsole function allocates a new console
|
|---|
| 2272 | * for the calling process
|
|---|
| 2273 | * Parameters: VOID
|
|---|
| 2274 | * Variables :
|
|---|
| 2275 | * Result : BOOL: TRUE - function succeeded
|
|---|
| 2276 | * FALSE - function failed. Extended error information
|
|---|
| 2277 | * obtainable via GetLastError
|
|---|
| 2278 | * Remark :
|
|---|
| 2279 | * Status : REWRITTEN UNTESTED
|
|---|
| 2280 | *
|
|---|
| 2281 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2282 | *****************************************************************************/
|
|---|
| 2283 |
|
|---|
| 2284 | BOOL WIN32API AllocConsole(VOID)
|
|---|
| 2285 | {
|
|---|
| 2286 | APIRET rc; /* API returncode */
|
|---|
| 2287 |
|
|---|
| 2288 | #ifdef DEBUG_LOCAL2
|
|---|
| 2289 | WriteLog("KERNEL32/CONSOLE: OS2AllocConsole() called.\n");
|
|---|
| 2290 | #endif
|
|---|
| 2291 |
|
|---|
| 2292 | rc = iConsoleInit(); /* initialize subsystem if required */
|
|---|
| 2293 | if (rc != NO_ERROR) /* check for errors */
|
|---|
| 2294 | {
|
|---|
| 2295 | SetLastError(rc); /* pass thru the error code */
|
|---|
| 2296 | return FALSE; /* signal failure */
|
|---|
| 2297 | }
|
|---|
| 2298 | else
|
|---|
| 2299 | return TRUE; /* Fine ! :) */
|
|---|
| 2300 | }
|
|---|
| 2301 |
|
|---|
| 2302 |
|
|---|
| 2303 | /*****************************************************************************
|
|---|
| 2304 | * Name : HANDLE WIN32API CreateConsoleScreenBuffer
|
|---|
| 2305 | * Purpose : The CreateConsoleScreenBuffer function creates a console
|
|---|
| 2306 | * screen buffer and returns a handle of it.
|
|---|
| 2307 | * Parameters: DWORD dwDesiredAccess - access flag
|
|---|
| 2308 | * DWORD dwShareMode - buffer share more
|
|---|
| 2309 | * PVOID pIgnored - LPSECURITY_ATTRIBUTES -> NT
|
|---|
| 2310 | * DWORD dwFlags - type of buffer to create
|
|---|
| 2311 | * LPVOID lpScreenBufferData - reserved
|
|---|
| 2312 | * Variables :
|
|---|
| 2313 | * Result :
|
|---|
| 2314 | * Remark : a console buffer is a kernel heap object equipped with
|
|---|
| 2315 | * share modes, access rights, etc.
|
|---|
| 2316 | * we can't really map this to OS/2 unless we build a
|
|---|
| 2317 | * console device driver for it ... maybe this turns out to
|
|---|
| 2318 | * be necessary since we've got to handle CONIN$ and CONOUT$, too.
|
|---|
| 2319 | * Status :
|
|---|
| 2320 | *
|
|---|
| 2321 | * Author : Patrick Haller [Tue, 1998/02/10 03:55]
|
|---|
| 2322 | *****************************************************************************/
|
|---|
| 2323 |
|
|---|
| 2324 | HANDLE WIN32API CreateConsoleScreenBuffer(DWORD dwDesiredAccess,
|
|---|
| 2325 | DWORD dwShareMode,
|
|---|
| 2326 | LPVOID lpSecurityAttributes,
|
|---|
| 2327 | DWORD dwFlags,
|
|---|
| 2328 | LPVOID lpScreenBufferData)
|
|---|
| 2329 | {
|
|---|
| 2330 | HANDLE hResult;
|
|---|
| 2331 |
|
|---|
| 2332 | #ifdef DEBUG_LOCAL2
|
|---|
| 2333 | WriteLog("KERNEL32/CONSOLE:OS2CreateConsoleScreenBuffer(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 2334 | dwDesiredAccess,
|
|---|
| 2335 | dwShareMode,
|
|---|
| 2336 | lpSecurityAttributes,
|
|---|
| 2337 | dwFlags,
|
|---|
| 2338 | lpScreenBufferData);
|
|---|
| 2339 | #endif
|
|---|
| 2340 |
|
|---|
| 2341 | hResult = HMCreateFile("CONBUFFER$", /* create a new buffer handle */
|
|---|
| 2342 | dwDesiredAccess,
|
|---|
| 2343 | dwShareMode,
|
|---|
| 2344 | (LPSECURITY_ATTRIBUTES)lpSecurityAttributes,
|
|---|
| 2345 | 0,
|
|---|
| 2346 | dwFlags,
|
|---|
| 2347 | INVALID_HANDLE_VALUE);
|
|---|
| 2348 |
|
|---|
| 2349 | return hResult;
|
|---|
| 2350 | }
|
|---|
| 2351 |
|
|---|
| 2352 |
|
|---|
| 2353 | /*****************************************************************************
|
|---|
| 2354 | * Name :
|
|---|
| 2355 | * Purpose :
|
|---|
| 2356 | * Parameters:
|
|---|
| 2357 | * Variables :
|
|---|
| 2358 | * Result :
|
|---|
| 2359 | * Remark :
|
|---|
| 2360 | * Status :
|
|---|
| 2361 | *
|
|---|
| 2362 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2363 | *****************************************************************************/
|
|---|
| 2364 |
|
|---|
| 2365 | BOOL WIN32API FillConsoleOutputAttribute(HANDLE hConsoleOutput,
|
|---|
| 2366 | WORD wAttribute,
|
|---|
| 2367 | DWORD nLength,
|
|---|
| 2368 | COORD dwWriteCoord,
|
|---|
| 2369 | LPDWORD lpNumberOfAttrsWritten)
|
|---|
| 2370 | {
|
|---|
| 2371 | BOOL fResult;
|
|---|
| 2372 |
|
|---|
| 2373 | #ifdef DEBUG_LOCAL2
|
|---|
| 2374 | WriteLog("KERNEL32/CONSOLE: OS2FillConsoleOutputAttribute(%08x,%04x,%08x,%08x,%08x).\n",
|
|---|
| 2375 | hConsoleOutput,
|
|---|
| 2376 | wAttribute,
|
|---|
| 2377 | nLength,
|
|---|
| 2378 | dwWriteCoord,
|
|---|
| 2379 | lpNumberOfAttrsWritten);
|
|---|
| 2380 | #endif
|
|---|
| 2381 |
|
|---|
| 2382 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2383 | DRQ_FILLCONSOLEOUTPUTATTRIBUTE,
|
|---|
| 2384 | (ULONG)wAttribute,
|
|---|
| 2385 | (ULONG)nLength,
|
|---|
| 2386 | COORD2ULONG(dwWriteCoord),
|
|---|
| 2387 | (ULONG)lpNumberOfAttrsWritten);
|
|---|
| 2388 |
|
|---|
| 2389 | return fResult;
|
|---|
| 2390 | }
|
|---|
| 2391 |
|
|---|
| 2392 |
|
|---|
| 2393 | /*****************************************************************************
|
|---|
| 2394 | * Name :
|
|---|
| 2395 | * Purpose :
|
|---|
| 2396 | * Parameters:
|
|---|
| 2397 | * Variables :
|
|---|
| 2398 | * Result :
|
|---|
| 2399 | * Remark :
|
|---|
| 2400 | * Status :
|
|---|
| 2401 | *
|
|---|
| 2402 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2403 | *****************************************************************************/
|
|---|
| 2404 |
|
|---|
| 2405 | BOOL WIN32API FillConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
|---|
| 2406 | UCHAR cCharacter,
|
|---|
| 2407 | DWORD nLength,
|
|---|
| 2408 | COORD dwWriteCoord,
|
|---|
| 2409 | LPDWORD lpNumberOfCharsWritten )
|
|---|
| 2410 | {
|
|---|
| 2411 | BOOL fResult;
|
|---|
| 2412 |
|
|---|
| 2413 | #ifdef DEBUG_LOCAL2
|
|---|
| 2414 | WriteLog("KERNEL32/CONSOLE: OS2FillConsoleOutputCharacterA(%08x,%c,%08x,%08x,%08x).\n",
|
|---|
| 2415 | hConsoleOutput,
|
|---|
| 2416 | cCharacter,
|
|---|
| 2417 | nLength,
|
|---|
| 2418 | dwWriteCoord,
|
|---|
| 2419 | lpNumberOfCharsWritten);
|
|---|
| 2420 | #endif
|
|---|
| 2421 |
|
|---|
| 2422 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2423 | DRQ_FILLCONSOLEOUTPUTCHARACTERA,
|
|---|
| 2424 | (ULONG)cCharacter,
|
|---|
| 2425 | (ULONG)nLength,
|
|---|
| 2426 | COORD2ULONG(dwWriteCoord),
|
|---|
| 2427 | (ULONG)lpNumberOfCharsWritten);
|
|---|
| 2428 |
|
|---|
| 2429 | return fResult;
|
|---|
| 2430 | }
|
|---|
| 2431 |
|
|---|
| 2432 |
|
|---|
| 2433 | /*****************************************************************************
|
|---|
| 2434 | * Name :
|
|---|
| 2435 | * Purpose :
|
|---|
| 2436 | * Parameters:
|
|---|
| 2437 | * Variables :
|
|---|
| 2438 | * Result :
|
|---|
| 2439 | * Remark :
|
|---|
| 2440 | * Status :
|
|---|
| 2441 | *
|
|---|
| 2442 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2443 | *****************************************************************************/
|
|---|
| 2444 |
|
|---|
| 2445 | BOOL WIN32API FillConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
|---|
| 2446 | WCHAR cCharacter,
|
|---|
| 2447 | DWORD nLength,
|
|---|
| 2448 | COORD dwWriteCoord,
|
|---|
| 2449 | LPDWORD lpNumberOfCharsWritten )
|
|---|
| 2450 | {
|
|---|
| 2451 | BOOL fResult;
|
|---|
| 2452 |
|
|---|
| 2453 | #ifdef DEBUG_LOCAL2
|
|---|
| 2454 | WriteLog("KERNEL32/CONSOLE: OS2FillConsoleOutputCharacterW(%08x,%c,%08x,%08x,%08x) .\n",
|
|---|
| 2455 | hConsoleOutput,
|
|---|
| 2456 | cCharacter,
|
|---|
| 2457 | nLength,
|
|---|
| 2458 | dwWriteCoord,
|
|---|
| 2459 | lpNumberOfCharsWritten);
|
|---|
| 2460 | #endif
|
|---|
| 2461 |
|
|---|
| 2462 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2463 | DRQ_FILLCONSOLEOUTPUTCHARACTERW,
|
|---|
| 2464 | (ULONG)cCharacter,
|
|---|
| 2465 | (ULONG)nLength,
|
|---|
| 2466 | COORD2ULONG(dwWriteCoord),
|
|---|
| 2467 | (ULONG)lpNumberOfCharsWritten);
|
|---|
| 2468 |
|
|---|
| 2469 | return fResult;
|
|---|
| 2470 | }
|
|---|
| 2471 |
|
|---|
| 2472 |
|
|---|
| 2473 | /*****************************************************************************
|
|---|
| 2474 | * Name :
|
|---|
| 2475 | * Purpose :
|
|---|
| 2476 | * Parameters:
|
|---|
| 2477 | * Variables :
|
|---|
| 2478 | * Result :
|
|---|
| 2479 | * Remark :
|
|---|
| 2480 | * Status :
|
|---|
| 2481 | *
|
|---|
| 2482 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2483 | *****************************************************************************/
|
|---|
| 2484 |
|
|---|
| 2485 | BOOL WIN32API FlushConsoleInputBuffer( HANDLE hConsoleInput )
|
|---|
| 2486 | {
|
|---|
| 2487 | BOOL fResult;
|
|---|
| 2488 |
|
|---|
| 2489 | #ifdef DEBUG_LOCAL2
|
|---|
| 2490 | WriteLog("KERNEL32/CONSOLE: OS2FlushConsoleInputBuffer(%08x).\n",
|
|---|
| 2491 | hConsoleInput);
|
|---|
| 2492 | #endif
|
|---|
| 2493 |
|
|---|
| 2494 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2495 | DRQ_FLUSHCONSOLEINPUTBUFFER,
|
|---|
| 2496 | 0,
|
|---|
| 2497 | 0,
|
|---|
| 2498 | 0,
|
|---|
| 2499 | 0);
|
|---|
| 2500 |
|
|---|
| 2501 | return fResult;
|
|---|
| 2502 | }
|
|---|
| 2503 |
|
|---|
| 2504 |
|
|---|
| 2505 | /*****************************************************************************
|
|---|
| 2506 | * Name : BOOL WIN32API FreeConsole
|
|---|
| 2507 | * Purpose : The FreeConsole function detaches the calling process
|
|---|
| 2508 | * from its console.
|
|---|
| 2509 | * Parameters: VOID
|
|---|
| 2510 | * Variables :
|
|---|
| 2511 | * Result : BOOL: TRUE - function succeeded
|
|---|
| 2512 | * FALSE - function failed. Extended error information
|
|---|
| 2513 | * obtainable via GetLastError
|
|---|
| 2514 | * Remark :
|
|---|
| 2515 | * Status : REWRITTEN UNTESTED
|
|---|
| 2516 | *
|
|---|
| 2517 | * Author : Patrick Haller [Tue, 1998/02/10 03:35]
|
|---|
| 2518 | *****************************************************************************/
|
|---|
| 2519 |
|
|---|
| 2520 | BOOL WIN32API FreeConsole( VOID )
|
|---|
| 2521 | {
|
|---|
| 2522 | APIRET rc; /* API returncode */
|
|---|
| 2523 |
|
|---|
| 2524 | #ifdef DEBUG_LOCAL2
|
|---|
| 2525 | WriteLog("KERNEL32/CONSOLE: OS2FreeConsole() called.\n");
|
|---|
| 2526 | #endif
|
|---|
| 2527 |
|
|---|
| 2528 | rc = iConsoleTerminate(); /* terminate subsystem if required */
|
|---|
| 2529 | if (rc != NO_ERROR) /* check for errors */
|
|---|
| 2530 | {
|
|---|
| 2531 | SetLastError(rc); /* pass thru the error code */
|
|---|
| 2532 | return FALSE; /* signal failure */
|
|---|
| 2533 | }
|
|---|
| 2534 | else
|
|---|
| 2535 | return TRUE; /* Fine ! :) */
|
|---|
| 2536 |
|
|---|
| 2537 | return TRUE;
|
|---|
| 2538 | }
|
|---|
| 2539 |
|
|---|
| 2540 |
|
|---|
| 2541 | /*****************************************************************************
|
|---|
| 2542 | * Name :
|
|---|
| 2543 | * Purpose :
|
|---|
| 2544 | * Parameters:
|
|---|
| 2545 | * Variables :
|
|---|
| 2546 | * Result :
|
|---|
| 2547 | * Remark :
|
|---|
| 2548 | * Status :
|
|---|
| 2549 | *
|
|---|
| 2550 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2551 | *****************************************************************************/
|
|---|
| 2552 |
|
|---|
| 2553 | BOOL WIN32API GenerateConsoleCtrlEvent(DWORD dwCtrlEvent,
|
|---|
| 2554 | DWORD dwProcessGroupId)
|
|---|
| 2555 | {
|
|---|
| 2556 | #ifdef DEBUG_LOCAL2
|
|---|
| 2557 | WriteLog("KERNEL32/CONSOLE: OS2GenerateConsoleCtrlEvent(%08x,%08x) not implemented.\n",
|
|---|
| 2558 | dwCtrlEvent,
|
|---|
| 2559 | dwProcessGroupId);
|
|---|
| 2560 | #endif
|
|---|
| 2561 |
|
|---|
| 2562 | return TRUE;
|
|---|
| 2563 | }
|
|---|
| 2564 |
|
|---|
| 2565 |
|
|---|
| 2566 | /*****************************************************************************
|
|---|
| 2567 | * Name :
|
|---|
| 2568 | * Purpose :
|
|---|
| 2569 | * Parameters:
|
|---|
| 2570 | * Variables :
|
|---|
| 2571 | * Result :
|
|---|
| 2572 | * Remark :
|
|---|
| 2573 | * Status :
|
|---|
| 2574 | *
|
|---|
| 2575 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2576 | *****************************************************************************/
|
|---|
| 2577 |
|
|---|
| 2578 | UINT WIN32API GetConsoleCP(VOID)
|
|---|
| 2579 | {
|
|---|
| 2580 | #ifdef DEBUG_LOCAL2
|
|---|
| 2581 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleCP not implemented.\n");
|
|---|
| 2582 | #endif
|
|---|
| 2583 |
|
|---|
| 2584 | return 1;
|
|---|
| 2585 | }
|
|---|
| 2586 |
|
|---|
| 2587 |
|
|---|
| 2588 | /*****************************************************************************
|
|---|
| 2589 | * Name :
|
|---|
| 2590 | * Purpose :
|
|---|
| 2591 | * Parameters:
|
|---|
| 2592 | * Variables :
|
|---|
| 2593 | * Result :
|
|---|
| 2594 | * Remark :
|
|---|
| 2595 | * Status :
|
|---|
| 2596 | *
|
|---|
| 2597 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2598 | *****************************************************************************/
|
|---|
| 2599 |
|
|---|
| 2600 | BOOL WIN32API GetConsoleCursorInfo(HANDLE hConsoleOutput,
|
|---|
| 2601 | PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
|
|---|
| 2602 | {
|
|---|
| 2603 | BOOL fResult;
|
|---|
| 2604 |
|
|---|
| 2605 | #ifdef DEBUG_LOCAL2
|
|---|
| 2606 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleCursorInfo(%08x,%08x).\n",
|
|---|
| 2607 | hConsoleOutput,
|
|---|
| 2608 | lpConsoleCursorInfo);
|
|---|
| 2609 | #endif
|
|---|
| 2610 |
|
|---|
| 2611 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2612 | DRQ_GETCONSOLECURSORINFO,
|
|---|
| 2613 | (ULONG)lpConsoleCursorInfo,
|
|---|
| 2614 | 0,
|
|---|
| 2615 | 0,
|
|---|
| 2616 | 0);
|
|---|
| 2617 |
|
|---|
| 2618 | return fResult;
|
|---|
| 2619 | }
|
|---|
| 2620 |
|
|---|
| 2621 |
|
|---|
| 2622 | /*****************************************************************************
|
|---|
| 2623 | * Name :
|
|---|
| 2624 | * Purpose :
|
|---|
| 2625 | * Parameters:
|
|---|
| 2626 | * Variables :
|
|---|
| 2627 | * Result :
|
|---|
| 2628 | * Remark :
|
|---|
| 2629 | * Status :
|
|---|
| 2630 | *
|
|---|
| 2631 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2632 | *****************************************************************************/
|
|---|
| 2633 |
|
|---|
| 2634 | BOOL WIN32API GetConsoleMode(HANDLE hConsole,
|
|---|
| 2635 | LPDWORD lpMode)
|
|---|
| 2636 | {
|
|---|
| 2637 | BOOL fResult;
|
|---|
| 2638 |
|
|---|
| 2639 | #ifdef DEBUG_LOCAL2
|
|---|
| 2640 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleMode(%08x,%08x).\n",
|
|---|
| 2641 | hConsole,
|
|---|
| 2642 | lpMode);
|
|---|
| 2643 | #endif
|
|---|
| 2644 |
|
|---|
| 2645 | fResult = (BOOL)HMDeviceRequest(hConsole,
|
|---|
| 2646 | DRQ_GETCONSOLEMODE,
|
|---|
| 2647 | (ULONG) lpMode,
|
|---|
| 2648 | 0,
|
|---|
| 2649 | 0,
|
|---|
| 2650 | 0);
|
|---|
| 2651 |
|
|---|
| 2652 | return fResult;
|
|---|
| 2653 | }
|
|---|
| 2654 |
|
|---|
| 2655 |
|
|---|
| 2656 | /*****************************************************************************
|
|---|
| 2657 | * Name :
|
|---|
| 2658 | * Purpose :
|
|---|
| 2659 | * Parameters:
|
|---|
| 2660 | * Variables :
|
|---|
| 2661 | * Result :
|
|---|
| 2662 | * Remark :
|
|---|
| 2663 | * Status :
|
|---|
| 2664 | *
|
|---|
| 2665 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2666 | *****************************************************************************/
|
|---|
| 2667 |
|
|---|
| 2668 | UINT WIN32API GetConsoleOutputCP(VOID)
|
|---|
| 2669 | {
|
|---|
| 2670 | #ifdef DEBUG_LOCAL2
|
|---|
| 2671 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleOutputCP not implemented.\n");
|
|---|
| 2672 | #endif
|
|---|
| 2673 |
|
|---|
| 2674 | return 1;
|
|---|
| 2675 | }
|
|---|
| 2676 |
|
|---|
| 2677 |
|
|---|
| 2678 | /*****************************************************************************
|
|---|
| 2679 | * Name :
|
|---|
| 2680 | * Purpose :
|
|---|
| 2681 | * Parameters:
|
|---|
| 2682 | * Variables :
|
|---|
| 2683 | * Result :
|
|---|
| 2684 | * Remark :
|
|---|
| 2685 | * Status :
|
|---|
| 2686 | *
|
|---|
| 2687 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2688 | *****************************************************************************/
|
|---|
| 2689 |
|
|---|
| 2690 | BOOL WIN32API GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
|
|---|
| 2691 | PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
|
|---|
| 2692 | {
|
|---|
| 2693 | BOOL fResult;
|
|---|
| 2694 |
|
|---|
| 2695 | #ifdef DEBUG_LOCAL2
|
|---|
| 2696 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleScreenBufferInfo(%08x,%08x).\n",
|
|---|
| 2697 | hConsoleOutput,
|
|---|
| 2698 | lpConsoleScreenBufferInfo);
|
|---|
| 2699 | #endif
|
|---|
| 2700 |
|
|---|
| 2701 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2702 | DRQ_GETCONSOLESCREENBUFFERINFO,
|
|---|
| 2703 | (ULONG)lpConsoleScreenBufferInfo,
|
|---|
| 2704 | 0,
|
|---|
| 2705 | 0,
|
|---|
| 2706 | 0);
|
|---|
| 2707 |
|
|---|
| 2708 | return fResult;
|
|---|
| 2709 | }
|
|---|
| 2710 |
|
|---|
| 2711 |
|
|---|
| 2712 | /*****************************************************************************
|
|---|
| 2713 | * Name : DWORD WIN32API GetConsoleTitle
|
|---|
| 2714 | * Purpose : Query the current console window title
|
|---|
| 2715 | * Parameters: LPTSTR lpConsoleTitle
|
|---|
| 2716 | * DWORD nSize
|
|---|
| 2717 | * Variables :
|
|---|
| 2718 | * Result : number of copied bytes
|
|---|
| 2719 | * Remark :
|
|---|
| 2720 | * Status : REWRITTEN UNTESTED
|
|---|
| 2721 | *
|
|---|
| 2722 | * Author : Patrick Haller [Thu, 1998/02/12 23:31]
|
|---|
| 2723 | *****************************************************************************/
|
|---|
| 2724 |
|
|---|
| 2725 | DWORD WIN32API GetConsoleTitleA(LPTSTR lpConsoleTitle,
|
|---|
| 2726 | DWORD nSize)
|
|---|
| 2727 | {
|
|---|
| 2728 | ULONG ulLength; /* length of text */
|
|---|
| 2729 |
|
|---|
| 2730 | #ifdef DEBUG_LOCAL2
|
|---|
| 2731 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleTitleA(%08x,%08x).\n",
|
|---|
| 2732 | lpConsoleTitle,
|
|---|
| 2733 | nSize);
|
|---|
| 2734 | #endif
|
|---|
| 2735 |
|
|---|
| 2736 | if (ConsoleGlobals.pszWindowTitle == NULL) /* is there a window title ? */
|
|---|
| 2737 | return 0; /* abort immediately */
|
|---|
| 2738 |
|
|---|
| 2739 | ulLength = strlen(ConsoleGlobals.pszWindowTitle); /* length of text */
|
|---|
| 2740 |
|
|---|
| 2741 | strncpy(lpConsoleTitle,
|
|---|
| 2742 | ConsoleGlobals.pszWindowTitle,
|
|---|
| 2743 | nSize);
|
|---|
| 2744 |
|
|---|
| 2745 | return (nSize < ulLength) ? nSize : ulLength;
|
|---|
| 2746 | }
|
|---|
| 2747 |
|
|---|
| 2748 |
|
|---|
| 2749 | /*****************************************************************************
|
|---|
| 2750 | * Name : DWORD WIN32API GetConsoleTitle
|
|---|
| 2751 | * Purpose : Query the current console window title
|
|---|
| 2752 | * Parameters: LPTSTR lpConsoleTitle
|
|---|
| 2753 | * DWORD nSize
|
|---|
| 2754 | * Variables :
|
|---|
| 2755 | * Result : number of copied bytes
|
|---|
| 2756 | * Remark :
|
|---|
| 2757 | * Status : REWRITTEN UNTESTED
|
|---|
| 2758 | *
|
|---|
| 2759 | * Author : Patrick Haller [Thu, 1998/02/12 23:31]
|
|---|
| 2760 | *****************************************************************************/
|
|---|
| 2761 |
|
|---|
| 2762 | DWORD WIN32API GetConsoleTitleW(LPTSTR lpConsoleTitle,
|
|---|
| 2763 | DWORD nSize)
|
|---|
| 2764 | {
|
|---|
| 2765 | ULONG ulLength; /* length of text */
|
|---|
| 2766 |
|
|---|
| 2767 | #ifdef DEBUG_LOCAL2
|
|---|
| 2768 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleTitleW(%08x,%08x).\n",
|
|---|
| 2769 | lpConsoleTitle,
|
|---|
| 2770 | nSize);
|
|---|
| 2771 | #endif
|
|---|
| 2772 |
|
|---|
| 2773 | if (ConsoleGlobals.pszWindowTitle == NULL) /* is there a window title ? */
|
|---|
| 2774 | return 0; /* abort immediately */
|
|---|
| 2775 |
|
|---|
| 2776 | ulLength = strlen(ConsoleGlobals.pszWindowTitle); /* length of text */
|
|---|
| 2777 |
|
|---|
| 2778 | strncpy(lpConsoleTitle,
|
|---|
| 2779 | ConsoleGlobals.pszWindowTitle,
|
|---|
| 2780 | nSize);
|
|---|
| 2781 |
|
|---|
| 2782 | /* @@@PH Ascii2Unicode */
|
|---|
| 2783 |
|
|---|
| 2784 | return (nSize < ulLength) ? nSize : ulLength;
|
|---|
| 2785 | }
|
|---|
| 2786 |
|
|---|
| 2787 |
|
|---|
| 2788 | /*****************************************************************************
|
|---|
| 2789 | * Name : COORD WIN32API GetLargestConsoleWindowSize
|
|---|
| 2790 | * Purpose : Determine maximum AVIO size
|
|---|
| 2791 | * Parameters:
|
|---|
| 2792 | * Variables :
|
|---|
| 2793 | * Result :
|
|---|
| 2794 | * Remark :
|
|---|
| 2795 | * Status :
|
|---|
| 2796 | *
|
|---|
| 2797 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2798 | *****************************************************************************/
|
|---|
| 2799 |
|
|---|
| 2800 | COORD WIN32API GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
|
|---|
| 2801 | {
|
|---|
| 2802 | DWORD dwResult;
|
|---|
| 2803 | COORD coordResult;
|
|---|
| 2804 |
|
|---|
| 2805 | #ifdef DEBUG_LOCAL2
|
|---|
| 2806 | WriteLog("KERNEL32/CONSOLE: OS2GetLargestConsoleWindowSize(%08x).\n",
|
|---|
| 2807 | hConsoleOutput);
|
|---|
| 2808 | #endif
|
|---|
| 2809 |
|
|---|
| 2810 | dwResult = HMDeviceRequest(hConsoleOutput,
|
|---|
| 2811 | DRQ_GETLARGESTCONSOLEWINDOWSIZE,
|
|---|
| 2812 | 0,
|
|---|
| 2813 | 0,
|
|---|
| 2814 | 0,
|
|---|
| 2815 | 0);
|
|---|
| 2816 |
|
|---|
| 2817 | ULONG2COORD(coordResult,dwResult)
|
|---|
| 2818 | return ( coordResult );
|
|---|
| 2819 | }
|
|---|
| 2820 |
|
|---|
| 2821 |
|
|---|
| 2822 | /*****************************************************************************
|
|---|
| 2823 | * Name :
|
|---|
| 2824 | * Purpose :
|
|---|
| 2825 | * Parameters:
|
|---|
| 2826 | * Variables :
|
|---|
| 2827 | * Result :
|
|---|
| 2828 | * Remark :
|
|---|
| 2829 | * Status :
|
|---|
| 2830 | *
|
|---|
| 2831 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2832 | *****************************************************************************/
|
|---|
| 2833 |
|
|---|
| 2834 | BOOL WIN32API GetNumberOfConsoleInputEvents(HANDLE hConsoleInput,
|
|---|
| 2835 | LPDWORD lpNumberOfEvents)
|
|---|
| 2836 | {
|
|---|
| 2837 | BOOL fResult;
|
|---|
| 2838 |
|
|---|
| 2839 | #ifdef DEBUG_LOCAL2
|
|---|
| 2840 | WriteLog("KERNEL32/CONSOLE: OS2GetNumberOfConsoleInputEvents(%08x,%08x).\n",
|
|---|
| 2841 | hConsoleInput,
|
|---|
| 2842 | lpNumberOfEvents);
|
|---|
| 2843 | #endif
|
|---|
| 2844 |
|
|---|
| 2845 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2846 | DRQ_GETNUMBEROFCONSOLEINPUTEVENTS,
|
|---|
| 2847 | (ULONG)lpNumberOfEvents,
|
|---|
| 2848 | 0,
|
|---|
| 2849 | 0,
|
|---|
| 2850 | 0);
|
|---|
| 2851 |
|
|---|
| 2852 | return fResult;
|
|---|
| 2853 | }
|
|---|
| 2854 |
|
|---|
| 2855 |
|
|---|
| 2856 | /*****************************************************************************
|
|---|
| 2857 | * Name :
|
|---|
| 2858 | * Purpose :
|
|---|
| 2859 | * Parameters:
|
|---|
| 2860 | * Variables :
|
|---|
| 2861 | * Result :
|
|---|
| 2862 | * Remark :
|
|---|
| 2863 | * Status :
|
|---|
| 2864 | *
|
|---|
| 2865 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2866 | *****************************************************************************/
|
|---|
| 2867 |
|
|---|
| 2868 | BOOL WIN32API GetNumberOfConsoleMouseButtons(LPDWORD lpcNumberOfMouseButtons)
|
|---|
| 2869 | {
|
|---|
| 2870 | LONG lMouseButtons;
|
|---|
| 2871 |
|
|---|
| 2872 | #ifdef DEBUG_LOCAL2
|
|---|
| 2873 | WriteLog("KERNEL32/CONSOLE: OS2GetNumberOfConsoleMouseButtons(%08x).\n",
|
|---|
| 2874 | lpcNumberOfMouseButtons);
|
|---|
| 2875 | #endif
|
|---|
| 2876 |
|
|---|
| 2877 | lMouseButtons = WinQuerySysValue(HWND_DESKTOP, /* query PM for that */
|
|---|
| 2878 | SV_CMOUSEBUTTONS);
|
|---|
| 2879 |
|
|---|
| 2880 | *lpcNumberOfMouseButtons = (DWORD)lMouseButtons;
|
|---|
| 2881 |
|
|---|
| 2882 | return TRUE;
|
|---|
| 2883 | }
|
|---|
| 2884 |
|
|---|
| 2885 |
|
|---|
| 2886 | /*****************************************************************************
|
|---|
| 2887 | * Name :
|
|---|
| 2888 | * Purpose :
|
|---|
| 2889 | * Parameters:
|
|---|
| 2890 | * Variables :
|
|---|
| 2891 | * Result :
|
|---|
| 2892 | * Remark :
|
|---|
| 2893 | * Status :
|
|---|
| 2894 | *
|
|---|
| 2895 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2896 | *****************************************************************************/
|
|---|
| 2897 |
|
|---|
| 2898 | BOOL WIN32API PeekConsoleInputW(HANDLE hConsoleInput,
|
|---|
| 2899 | PINPUT_RECORD pirBuffer,
|
|---|
| 2900 | DWORD cInRecords,
|
|---|
| 2901 | LPDWORD lpcRead)
|
|---|
| 2902 | {
|
|---|
| 2903 | BOOL fResult;
|
|---|
| 2904 |
|
|---|
| 2905 | #ifdef DEBUG_LOCAL2
|
|---|
| 2906 | WriteLog("KERNEL32/CONSOLE: OS2PeekConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
|---|
| 2907 | hConsoleInput,
|
|---|
| 2908 | pirBuffer,
|
|---|
| 2909 | cInRecords,
|
|---|
| 2910 | lpcRead);
|
|---|
| 2911 | #endif
|
|---|
| 2912 |
|
|---|
| 2913 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2914 | DRQ_PEEKCONSOLEINPUTW,
|
|---|
| 2915 | (ULONG)pirBuffer,
|
|---|
| 2916 | (ULONG)cInRecords,
|
|---|
| 2917 | (ULONG)lpcRead,
|
|---|
| 2918 | 0);
|
|---|
| 2919 |
|
|---|
| 2920 | return fResult;
|
|---|
| 2921 | }
|
|---|
| 2922 |
|
|---|
| 2923 |
|
|---|
| 2924 | /*****************************************************************************
|
|---|
| 2925 | * Name :
|
|---|
| 2926 | * Purpose :
|
|---|
| 2927 | * Parameters:
|
|---|
| 2928 | * Variables :
|
|---|
| 2929 | * Result :
|
|---|
| 2930 | * Remark :
|
|---|
| 2931 | * Status :
|
|---|
| 2932 | *
|
|---|
| 2933 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2934 | *****************************************************************************/
|
|---|
| 2935 |
|
|---|
| 2936 | BOOL WIN32API PeekConsoleInputA(HANDLE hConsoleInput,
|
|---|
| 2937 | PINPUT_RECORD pirBuffer,
|
|---|
| 2938 | DWORD cInRecords,
|
|---|
| 2939 | LPDWORD lpcRead)
|
|---|
| 2940 | {
|
|---|
| 2941 | BOOL fResult;
|
|---|
| 2942 |
|
|---|
| 2943 | #ifdef DEBUG_LOCAL2
|
|---|
| 2944 | WriteLog("KERNEL32/CONSOLE: OS2PeekConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
|---|
| 2945 | hConsoleInput,
|
|---|
| 2946 | pirBuffer,
|
|---|
| 2947 | cInRecords,
|
|---|
| 2948 | lpcRead);
|
|---|
| 2949 | #endif
|
|---|
| 2950 |
|
|---|
| 2951 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2952 | DRQ_PEEKCONSOLEINPUTA,
|
|---|
| 2953 | (ULONG)pirBuffer,
|
|---|
| 2954 | (ULONG)cInRecords,
|
|---|
| 2955 | (ULONG)lpcRead,
|
|---|
| 2956 | 0);
|
|---|
| 2957 |
|
|---|
| 2958 | return fResult;
|
|---|
| 2959 | }
|
|---|
| 2960 |
|
|---|
| 2961 |
|
|---|
| 2962 | /*****************************************************************************
|
|---|
| 2963 | * Name :
|
|---|
| 2964 | * Purpose :
|
|---|
| 2965 | * Parameters:
|
|---|
| 2966 | * Variables :
|
|---|
| 2967 | * Result :
|
|---|
| 2968 | * Remark :
|
|---|
| 2969 | * Status :
|
|---|
| 2970 | *
|
|---|
| 2971 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2972 | *****************************************************************************/
|
|---|
| 2973 |
|
|---|
| 2974 | BOOL WIN32API ReadConsoleA(HANDLE hConsoleInput,
|
|---|
| 2975 | LPVOID lpvBuffer,
|
|---|
| 2976 | DWORD cchToRead,
|
|---|
| 2977 | LPDWORD lpcchRead,
|
|---|
| 2978 | LPVOID lpvReserved)
|
|---|
| 2979 | {
|
|---|
| 2980 | BOOL fResult;
|
|---|
| 2981 |
|
|---|
| 2982 | #ifdef DEBUG_LOCAL2
|
|---|
| 2983 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 2984 | hConsoleInput,
|
|---|
| 2985 | lpvBuffer,
|
|---|
| 2986 | cchToRead,
|
|---|
| 2987 | lpcchRead,
|
|---|
| 2988 | lpvReserved);
|
|---|
| 2989 | #endif
|
|---|
| 2990 |
|
|---|
| 2991 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2992 | DRQ_READCONSOLEA,
|
|---|
| 2993 | (ULONG)lpvBuffer,
|
|---|
| 2994 | (ULONG)cchToRead,
|
|---|
| 2995 | (ULONG)lpcchRead,
|
|---|
| 2996 | (ULONG)lpvReserved);
|
|---|
| 2997 |
|
|---|
| 2998 | return fResult;
|
|---|
| 2999 | }
|
|---|
| 3000 |
|
|---|
| 3001 |
|
|---|
| 3002 | /*****************************************************************************
|
|---|
| 3003 | * Name :
|
|---|
| 3004 | * Purpose :
|
|---|
| 3005 | * Parameters:
|
|---|
| 3006 | * Variables :
|
|---|
| 3007 | * Result :
|
|---|
| 3008 | * Remark :
|
|---|
| 3009 | * Status :
|
|---|
| 3010 | *
|
|---|
| 3011 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3012 | *****************************************************************************/
|
|---|
| 3013 |
|
|---|
| 3014 | BOOL WIN32API ReadConsoleW(HANDLE hConsoleInput,
|
|---|
| 3015 | LPVOID lpvBuffer,
|
|---|
| 3016 | DWORD cchToRead,
|
|---|
| 3017 | LPDWORD lpcchRead,
|
|---|
| 3018 | LPVOID lpvReserved)
|
|---|
| 3019 | {
|
|---|
| 3020 | BOOL fResult;
|
|---|
| 3021 |
|
|---|
| 3022 | #ifdef DEBUG_LOCAL2
|
|---|
| 3023 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3024 | hConsoleInput,
|
|---|
| 3025 | lpvBuffer,
|
|---|
| 3026 | cchToRead,
|
|---|
| 3027 | lpcchRead,
|
|---|
| 3028 | lpvReserved);
|
|---|
| 3029 | #endif
|
|---|
| 3030 |
|
|---|
| 3031 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3032 | DRQ_READCONSOLEW,
|
|---|
| 3033 | (ULONG)lpvBuffer,
|
|---|
| 3034 | (ULONG)cchToRead,
|
|---|
| 3035 | (ULONG)lpcchRead,
|
|---|
| 3036 | (ULONG)lpvReserved);
|
|---|
| 3037 |
|
|---|
| 3038 | return fResult;
|
|---|
| 3039 | }
|
|---|
| 3040 |
|
|---|
| 3041 |
|
|---|
| 3042 | /*****************************************************************************
|
|---|
| 3043 | * Name :
|
|---|
| 3044 | * Purpose :
|
|---|
| 3045 | * Parameters:
|
|---|
| 3046 | * Variables :
|
|---|
| 3047 | * Result :
|
|---|
| 3048 | * Remark :
|
|---|
| 3049 | * Status :
|
|---|
| 3050 | *
|
|---|
| 3051 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3052 | *****************************************************************************/
|
|---|
| 3053 |
|
|---|
| 3054 | BOOL WIN32API ReadConsoleInputA(HANDLE hConsoleInput,
|
|---|
| 3055 | PINPUT_RECORD pirBuffer,
|
|---|
| 3056 | DWORD cInRecords,
|
|---|
| 3057 | LPDWORD lpcRead)
|
|---|
| 3058 | {
|
|---|
| 3059 | BOOL fResult;
|
|---|
| 3060 |
|
|---|
| 3061 | #ifdef DEBUG_LOCAL2
|
|---|
| 3062 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
|---|
| 3063 | hConsoleInput,
|
|---|
| 3064 | pirBuffer,
|
|---|
| 3065 | cInRecords,
|
|---|
| 3066 | lpcRead);
|
|---|
| 3067 | #endif
|
|---|
| 3068 |
|
|---|
| 3069 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3070 | DRQ_READCONSOLEINPUTA,
|
|---|
| 3071 | (ULONG)pirBuffer,
|
|---|
| 3072 | (ULONG)cInRecords,
|
|---|
| 3073 | (ULONG)lpcRead,
|
|---|
| 3074 | 0);
|
|---|
| 3075 |
|
|---|
| 3076 | return fResult;
|
|---|
| 3077 | }
|
|---|
| 3078 |
|
|---|
| 3079 |
|
|---|
| 3080 | /*****************************************************************************
|
|---|
| 3081 | * Name :
|
|---|
| 3082 | * Purpose :
|
|---|
| 3083 | * Parameters:
|
|---|
| 3084 | * Variables :
|
|---|
| 3085 | * Result :
|
|---|
| 3086 | * Remark :
|
|---|
| 3087 | * Status :
|
|---|
| 3088 | *
|
|---|
| 3089 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3090 | *****************************************************************************/
|
|---|
| 3091 |
|
|---|
| 3092 | BOOL WIN32API ReadConsoleInputW(HANDLE hConsoleInput,
|
|---|
| 3093 | PINPUT_RECORD pirBuffer,
|
|---|
| 3094 | DWORD cInRecords,
|
|---|
| 3095 | LPDWORD lpcRead)
|
|---|
| 3096 | {
|
|---|
| 3097 | BOOL fResult;
|
|---|
| 3098 |
|
|---|
| 3099 | #ifdef DEBUG_LOCAL2
|
|---|
| 3100 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
|---|
| 3101 | hConsoleInput,
|
|---|
| 3102 | pirBuffer,
|
|---|
| 3103 | cInRecords,
|
|---|
| 3104 | lpcRead);
|
|---|
| 3105 | #endif
|
|---|
| 3106 |
|
|---|
| 3107 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3108 | DRQ_READCONSOLEINPUTW,
|
|---|
| 3109 | (ULONG)pirBuffer,
|
|---|
| 3110 | (ULONG)cInRecords,
|
|---|
| 3111 | (ULONG)lpcRead,
|
|---|
| 3112 | 0);
|
|---|
| 3113 |
|
|---|
| 3114 | return fResult;
|
|---|
| 3115 | }
|
|---|
| 3116 |
|
|---|
| 3117 |
|
|---|
| 3118 | /*****************************************************************************
|
|---|
| 3119 | * Name :
|
|---|
| 3120 | * Purpose :
|
|---|
| 3121 | * Parameters:
|
|---|
| 3122 | * Variables :
|
|---|
| 3123 | * Result :
|
|---|
| 3124 | * Remark :
|
|---|
| 3125 | * Status :
|
|---|
| 3126 | *
|
|---|
| 3127 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3128 | *****************************************************************************/
|
|---|
| 3129 |
|
|---|
| 3130 | BOOL WIN32API ReadConsoleOutputA(HANDLE hConsoleOutput,
|
|---|
| 3131 | PCHAR_INFO pchiDestBuffer,
|
|---|
| 3132 | COORD coordDestBufferSize,
|
|---|
| 3133 | COORD coordDestBufferCoord,
|
|---|
| 3134 | PSMALL_RECT psrctSourceRect)
|
|---|
| 3135 | {
|
|---|
| 3136 | BOOL fResult;
|
|---|
| 3137 |
|
|---|
| 3138 | #ifdef DEBUG_LOCAL2
|
|---|
| 3139 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3140 | hConsoleOutput,
|
|---|
| 3141 | pchiDestBuffer,
|
|---|
| 3142 | coordDestBufferSize,
|
|---|
| 3143 | coordDestBufferCoord,
|
|---|
| 3144 | psrctSourceRect);
|
|---|
| 3145 | #endif
|
|---|
| 3146 |
|
|---|
| 3147 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3148 | DRQ_READCONSOLEOUTPUTA,
|
|---|
| 3149 | (ULONG)pchiDestBuffer,
|
|---|
| 3150 | COORD2ULONG(coordDestBufferSize),
|
|---|
| 3151 | COORD2ULONG(coordDestBufferCoord),
|
|---|
| 3152 | (ULONG)psrctSourceRect);
|
|---|
| 3153 |
|
|---|
| 3154 | return fResult;
|
|---|
| 3155 | }
|
|---|
| 3156 |
|
|---|
| 3157 |
|
|---|
| 3158 | /*****************************************************************************
|
|---|
| 3159 | * Name :
|
|---|
| 3160 | * Purpose :
|
|---|
| 3161 | * Parameters:
|
|---|
| 3162 | * Variables :
|
|---|
| 3163 | * Result :
|
|---|
| 3164 | * Remark :
|
|---|
| 3165 | * Status :
|
|---|
| 3166 | *
|
|---|
| 3167 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3168 | *****************************************************************************/
|
|---|
| 3169 |
|
|---|
| 3170 | BOOL WIN32API ReadConsoleOutputW(HANDLE hConsoleOutput,
|
|---|
| 3171 | PCHAR_INFO pchiDestBuffer,
|
|---|
| 3172 | COORD coordDestBufferSize,
|
|---|
| 3173 | COORD coordDestBufferCoord,
|
|---|
| 3174 | PSMALL_RECT psrctSourceRect)
|
|---|
| 3175 | {
|
|---|
| 3176 | BOOL fResult;
|
|---|
| 3177 |
|
|---|
| 3178 | #ifdef DEBUG_LOCAL2
|
|---|
| 3179 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3180 | hConsoleOutput,
|
|---|
| 3181 | pchiDestBuffer,
|
|---|
| 3182 | coordDestBufferSize,
|
|---|
| 3183 | coordDestBufferCoord,
|
|---|
| 3184 | psrctSourceRect);
|
|---|
| 3185 | #endif
|
|---|
| 3186 |
|
|---|
| 3187 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3188 | DRQ_READCONSOLEOUTPUTW,
|
|---|
| 3189 | (ULONG)pchiDestBuffer,
|
|---|
| 3190 | COORD2ULONG(coordDestBufferSize),
|
|---|
| 3191 | COORD2ULONG(coordDestBufferCoord),
|
|---|
| 3192 | (ULONG)psrctSourceRect);
|
|---|
| 3193 |
|
|---|
| 3194 | return fResult;
|
|---|
| 3195 | }
|
|---|
| 3196 |
|
|---|
| 3197 |
|
|---|
| 3198 | /*****************************************************************************
|
|---|
| 3199 | * Name :
|
|---|
| 3200 | * Purpose :
|
|---|
| 3201 | * Parameters:
|
|---|
| 3202 | * Variables :
|
|---|
| 3203 | * Result :
|
|---|
| 3204 | * Remark :
|
|---|
| 3205 | * Status :
|
|---|
| 3206 | *
|
|---|
| 3207 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3208 | *****************************************************************************/
|
|---|
| 3209 |
|
|---|
| 3210 | BOOL WIN32API ReadConsoleOutputAttribute(HANDLE hConsoleOutput,
|
|---|
| 3211 | LPWORD lpwAttribute,
|
|---|
| 3212 | DWORD cReadCells,
|
|---|
| 3213 | COORD coordReadCoord,
|
|---|
| 3214 | LPDWORD lpcNumberRead)
|
|---|
| 3215 | {
|
|---|
| 3216 | BOOL fResult;
|
|---|
| 3217 |
|
|---|
| 3218 | #ifdef DEBUG_LOCAL2
|
|---|
| 3219 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputAttribute(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3220 | hConsoleOutput,
|
|---|
| 3221 | lpwAttribute,
|
|---|
| 3222 | cReadCells,
|
|---|
| 3223 | coordReadCoord,
|
|---|
| 3224 | lpcNumberRead);
|
|---|
| 3225 | #endif
|
|---|
| 3226 |
|
|---|
| 3227 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3228 | DRQ_READCONSOLEOUTPUTATTRIBUTE,
|
|---|
| 3229 | (ULONG)lpwAttribute,
|
|---|
| 3230 | (ULONG)cReadCells,
|
|---|
| 3231 | COORD2ULONG(coordReadCoord),
|
|---|
| 3232 | (ULONG)lpcNumberRead);
|
|---|
| 3233 |
|
|---|
| 3234 | return fResult;
|
|---|
| 3235 | }
|
|---|
| 3236 |
|
|---|
| 3237 |
|
|---|
| 3238 | /*****************************************************************************
|
|---|
| 3239 | * Name :
|
|---|
| 3240 | * Purpose :
|
|---|
| 3241 | * Parameters:
|
|---|
| 3242 | * Variables :
|
|---|
| 3243 | * Result :
|
|---|
| 3244 | * Remark :
|
|---|
| 3245 | * Status :
|
|---|
| 3246 | *
|
|---|
| 3247 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3248 | *****************************************************************************/
|
|---|
| 3249 |
|
|---|
| 3250 | BOOL WIN32API ReadConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
|---|
| 3251 | LPTSTR lpReadBuffer,
|
|---|
| 3252 | DWORD cchRead,
|
|---|
| 3253 | COORD coordReadCoord,
|
|---|
| 3254 | LPDWORD lpcNumberRead)
|
|---|
| 3255 | {
|
|---|
| 3256 | BOOL fResult;
|
|---|
| 3257 |
|
|---|
| 3258 | #ifdef DEBUG_LOCAL2
|
|---|
| 3259 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputCharacterA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3260 | hConsoleOutput,
|
|---|
| 3261 | lpReadBuffer,
|
|---|
| 3262 | cchRead,
|
|---|
| 3263 | coordReadCoord,
|
|---|
| 3264 | lpcNumberRead);
|
|---|
| 3265 | #endif
|
|---|
| 3266 |
|
|---|
| 3267 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3268 | DRQ_READCONSOLEOUTPUTCHARACTERA,
|
|---|
| 3269 | (ULONG)lpReadBuffer,
|
|---|
| 3270 | (ULONG)cchRead,
|
|---|
| 3271 | COORD2ULONG(coordReadCoord),
|
|---|
| 3272 | (ULONG)lpcNumberRead);
|
|---|
| 3273 |
|
|---|
| 3274 | return fResult;
|
|---|
| 3275 | }
|
|---|
| 3276 |
|
|---|
| 3277 |
|
|---|
| 3278 | /*****************************************************************************
|
|---|
| 3279 | * Name :
|
|---|
| 3280 | * Purpose :
|
|---|
| 3281 | * Parameters:
|
|---|
| 3282 | * Variables :
|
|---|
| 3283 | * Result :
|
|---|
| 3284 | * Remark :
|
|---|
| 3285 | * Status :
|
|---|
| 3286 | *
|
|---|
| 3287 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3288 | *****************************************************************************/
|
|---|
| 3289 |
|
|---|
| 3290 | BOOL WIN32API ReadConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
|---|
| 3291 | LPTSTR lpReadBuffer,
|
|---|
| 3292 | DWORD cchRead,
|
|---|
| 3293 | COORD coordReadCoord,
|
|---|
| 3294 | LPDWORD lpcNumberRead)
|
|---|
| 3295 | {
|
|---|
| 3296 | BOOL fResult;
|
|---|
| 3297 |
|
|---|
| 3298 | #ifdef DEBUG_LOCAL2
|
|---|
| 3299 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputCharacterW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3300 | hConsoleOutput,
|
|---|
| 3301 | lpReadBuffer,
|
|---|
| 3302 | cchRead,
|
|---|
| 3303 | coordReadCoord,
|
|---|
| 3304 | lpcNumberRead);
|
|---|
| 3305 | #endif
|
|---|
| 3306 |
|
|---|
| 3307 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3308 | DRQ_READCONSOLEOUTPUTCHARACTERW,
|
|---|
| 3309 | (ULONG)lpReadBuffer,
|
|---|
| 3310 | (ULONG)cchRead,
|
|---|
| 3311 | COORD2ULONG(coordReadCoord),
|
|---|
| 3312 | (ULONG)lpcNumberRead);
|
|---|
| 3313 |
|
|---|
| 3314 | return fResult;
|
|---|
| 3315 | }
|
|---|
| 3316 |
|
|---|
| 3317 |
|
|---|
| 3318 | /*****************************************************************************
|
|---|
| 3319 | * Name :
|
|---|
| 3320 | * Purpose :
|
|---|
| 3321 | * Parameters:
|
|---|
| 3322 | * Variables :
|
|---|
| 3323 | * Result :
|
|---|
| 3324 | * Remark :
|
|---|
| 3325 | * Status :
|
|---|
| 3326 | *
|
|---|
| 3327 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3328 | *****************************************************************************/
|
|---|
| 3329 |
|
|---|
| 3330 | BOOL WIN32API ScrollConsoleScreenBufferA(HANDLE hConsoleOutput,
|
|---|
| 3331 | PSMALL_RECT psrctSourceRect,
|
|---|
| 3332 | PSMALL_RECT psrctClipRect,
|
|---|
| 3333 | COORD coordDestOrigin,
|
|---|
| 3334 | PCHAR_INFO pchiFill)
|
|---|
| 3335 | {
|
|---|
| 3336 | BOOL fResult;
|
|---|
| 3337 |
|
|---|
| 3338 | #ifdef DEBUG_LOCAL2
|
|---|
| 3339 | WriteLog("KERNEL32/CONSOLE: OS2ScrollConsoleScreenBufferA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3340 | hConsoleOutput,
|
|---|
| 3341 | psrctSourceRect,
|
|---|
| 3342 | psrctClipRect,
|
|---|
| 3343 | coordDestOrigin,
|
|---|
| 3344 | pchiFill);
|
|---|
| 3345 | #endif
|
|---|
| 3346 |
|
|---|
| 3347 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3348 | DRQ_SCROLLCONSOLESCREENBUFFERA,
|
|---|
| 3349 | (ULONG)psrctSourceRect,
|
|---|
| 3350 | (ULONG)psrctClipRect,
|
|---|
| 3351 | COORD2ULONG(coordDestOrigin),
|
|---|
| 3352 | (ULONG)pchiFill);
|
|---|
| 3353 |
|
|---|
| 3354 | return fResult;
|
|---|
| 3355 | }
|
|---|
| 3356 |
|
|---|
| 3357 |
|
|---|
| 3358 | /*****************************************************************************
|
|---|
| 3359 | * Name :
|
|---|
| 3360 | * Purpose :
|
|---|
| 3361 | * Parameters:
|
|---|
| 3362 | * Variables :
|
|---|
| 3363 | * Result :
|
|---|
| 3364 | * Remark :
|
|---|
| 3365 | * Status :
|
|---|
| 3366 | *
|
|---|
| 3367 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3368 | *****************************************************************************/
|
|---|
| 3369 |
|
|---|
| 3370 | BOOL WIN32API ScrollConsoleScreenBufferW(HANDLE hConsoleOutput,
|
|---|
| 3371 | PSMALL_RECT psrctSourceRect,
|
|---|
| 3372 | PSMALL_RECT psrctClipRect,
|
|---|
| 3373 | COORD coordDestOrigin,
|
|---|
| 3374 | PCHAR_INFO pchiFill)
|
|---|
| 3375 | {
|
|---|
| 3376 | BOOL fResult;
|
|---|
| 3377 |
|
|---|
| 3378 | #ifdef DEBUG_LOCAL2
|
|---|
| 3379 | WriteLog("KERNEL32/CONSOLE: OS2ScrollConsoleScreenBufferW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3380 | hConsoleOutput,
|
|---|
| 3381 | psrctSourceRect,
|
|---|
| 3382 | psrctClipRect,
|
|---|
| 3383 | coordDestOrigin,
|
|---|
| 3384 | pchiFill);
|
|---|
| 3385 | #endif
|
|---|
| 3386 |
|
|---|
| 3387 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3388 | DRQ_SCROLLCONSOLESCREENBUFFERW,
|
|---|
| 3389 | (ULONG)psrctSourceRect,
|
|---|
| 3390 | (ULONG)psrctClipRect,
|
|---|
| 3391 | COORD2ULONG(coordDestOrigin),
|
|---|
| 3392 | (ULONG)pchiFill);
|
|---|
| 3393 |
|
|---|
| 3394 | return fResult;
|
|---|
| 3395 | }
|
|---|
| 3396 |
|
|---|
| 3397 | /*****************************************************************************
|
|---|
| 3398 | * Name :
|
|---|
| 3399 | * Purpose :
|
|---|
| 3400 | * Parameters:
|
|---|
| 3401 | * Variables :
|
|---|
| 3402 | * Result :
|
|---|
| 3403 | * Remark :
|
|---|
| 3404 | * Status :
|
|---|
| 3405 | *
|
|---|
| 3406 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3407 | *****************************************************************************/
|
|---|
| 3408 |
|
|---|
| 3409 | BOOL WIN32API SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
|
|---|
| 3410 | {
|
|---|
| 3411 | BOOL fResult;
|
|---|
| 3412 |
|
|---|
| 3413 | #ifdef DEBUG_LOCAL2
|
|---|
| 3414 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleActiveScreenBuffer(%08x).\n",
|
|---|
| 3415 | hConsoleOutput);
|
|---|
| 3416 | #endif
|
|---|
| 3417 |
|
|---|
| 3418 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3419 | DRQ_SETCONSOLEACTIVESCREENBUFFER,
|
|---|
| 3420 | 0,
|
|---|
| 3421 | 0,
|
|---|
| 3422 | 0,
|
|---|
| 3423 | 0);
|
|---|
| 3424 |
|
|---|
| 3425 | return fResult;
|
|---|
| 3426 | }
|
|---|
| 3427 |
|
|---|
| 3428 |
|
|---|
| 3429 | /*****************************************************************************
|
|---|
| 3430 | * Name :
|
|---|
| 3431 | * Purpose :
|
|---|
| 3432 | * Parameters:
|
|---|
| 3433 | * Variables :
|
|---|
| 3434 | * Result :
|
|---|
| 3435 | * Remark :
|
|---|
| 3436 | * Status :
|
|---|
| 3437 | *
|
|---|
| 3438 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3439 | *****************************************************************************/
|
|---|
| 3440 |
|
|---|
| 3441 | BOOL WIN32API SetConsoleCP(UINT IDCodePage)
|
|---|
| 3442 | {
|
|---|
| 3443 | #ifdef DEBUG_LOCAL2
|
|---|
| 3444 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCP(%08x) not implemented.\n",
|
|---|
| 3445 | IDCodePage);
|
|---|
| 3446 | #endif
|
|---|
| 3447 |
|
|---|
| 3448 | return TRUE;
|
|---|
| 3449 | }
|
|---|
| 3450 |
|
|---|
| 3451 |
|
|---|
| 3452 | /*****************************************************************************
|
|---|
| 3453 | * Name :
|
|---|
| 3454 | * Purpose :
|
|---|
| 3455 | * Parameters:
|
|---|
| 3456 | * Variables :
|
|---|
| 3457 | * Result :
|
|---|
| 3458 | * Remark :
|
|---|
| 3459 | * Status :
|
|---|
| 3460 | *
|
|---|
| 3461 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3462 | *****************************************************************************/
|
|---|
| 3463 |
|
|---|
| 3464 | BOOL WIN32API SetConsoleCtrlHandler(PHANDLER_ROUTINE pHandlerRoutine,
|
|---|
| 3465 | BOOL fAdd)
|
|---|
| 3466 | {
|
|---|
| 3467 | #ifdef DEBUG_LOCAL2
|
|---|
| 3468 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCtrlHandler(%08x,%08x) not implemented.\n",
|
|---|
| 3469 | pHandlerRoutine,
|
|---|
| 3470 | fAdd);
|
|---|
| 3471 | #endif
|
|---|
| 3472 |
|
|---|
| 3473 | return TRUE;
|
|---|
| 3474 | }
|
|---|
| 3475 |
|
|---|
| 3476 |
|
|---|
| 3477 | /*****************************************************************************
|
|---|
| 3478 | * Name :
|
|---|
| 3479 | * Purpose :
|
|---|
| 3480 | * Parameters:
|
|---|
| 3481 | * Variables :
|
|---|
| 3482 | * Result :
|
|---|
| 3483 | * Remark :
|
|---|
| 3484 | * Status :
|
|---|
| 3485 | *
|
|---|
| 3486 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3487 | *****************************************************************************/
|
|---|
| 3488 |
|
|---|
| 3489 | BOOL WIN32API SetConsoleCursorInfo(HANDLE hConsoleOutput,
|
|---|
| 3490 | PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
|
|---|
| 3491 | {
|
|---|
| 3492 | BOOL fResult;
|
|---|
| 3493 |
|
|---|
| 3494 | #ifdef DEBUG_LOCAL2
|
|---|
| 3495 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCursorInfo(%08x,%08x).\n",
|
|---|
| 3496 | hConsoleOutput,
|
|---|
| 3497 | lpConsoleCursorInfo);
|
|---|
| 3498 | #endif
|
|---|
| 3499 |
|
|---|
| 3500 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3501 | DRQ_SETCONSOLECURSORINFO,
|
|---|
| 3502 | (ULONG)lpConsoleCursorInfo,
|
|---|
| 3503 | 0,
|
|---|
| 3504 | 0,
|
|---|
| 3505 | 0);
|
|---|
| 3506 |
|
|---|
| 3507 | return fResult;
|
|---|
| 3508 | }
|
|---|
| 3509 |
|
|---|
| 3510 |
|
|---|
| 3511 | /*****************************************************************************
|
|---|
| 3512 | * Name :
|
|---|
| 3513 | * Purpose :
|
|---|
| 3514 | * Parameters:
|
|---|
| 3515 | * Variables :
|
|---|
| 3516 | * Result :
|
|---|
| 3517 | * Remark :
|
|---|
| 3518 | * Status :
|
|---|
| 3519 | *
|
|---|
| 3520 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3521 |
|
|---|
| 3522 | *****************************************************************************/
|
|---|
| 3523 |
|
|---|
| 3524 | BOOL WIN32API SetConsoleCursorPosition(HANDLE hConsoleOutput,
|
|---|
| 3525 | COORD coordCursor)
|
|---|
| 3526 | {
|
|---|
| 3527 | BOOL fResult;
|
|---|
| 3528 |
|
|---|
| 3529 | #ifdef DEBUG_LOCAL2
|
|---|
| 3530 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCursorPosition(%08x,%08x).\n",
|
|---|
| 3531 | hConsoleOutput,
|
|---|
| 3532 | coordCursor);
|
|---|
| 3533 | #endif
|
|---|
| 3534 |
|
|---|
| 3535 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3536 | DRQ_SETCONSOLECURSORPOSITION,
|
|---|
| 3537 | COORD2ULONG(coordCursor),
|
|---|
| 3538 | 0,
|
|---|
| 3539 | 0,
|
|---|
| 3540 | 0);
|
|---|
| 3541 |
|
|---|
| 3542 | return fResult;
|
|---|
| 3543 | }
|
|---|
| 3544 |
|
|---|
| 3545 |
|
|---|
| 3546 | /*****************************************************************************
|
|---|
| 3547 | * Name :
|
|---|
| 3548 | * Purpose :
|
|---|
| 3549 | * Parameters:
|
|---|
| 3550 | * Variables :
|
|---|
| 3551 | * Result :
|
|---|
| 3552 | * Remark :
|
|---|
| 3553 | * Status :
|
|---|
| 3554 | *
|
|---|
| 3555 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3556 | *****************************************************************************/
|
|---|
| 3557 |
|
|---|
| 3558 | BOOL WIN32API SetConsoleMode(HANDLE hConsole,
|
|---|
| 3559 | DWORD fdwMode)
|
|---|
| 3560 | {
|
|---|
| 3561 | BOOL fResult;
|
|---|
| 3562 |
|
|---|
| 3563 | #ifdef DEBUG_LOCAL2
|
|---|
| 3564 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleMode(%08x,%08x).\n",
|
|---|
| 3565 | hConsole,
|
|---|
| 3566 | fdwMode);
|
|---|
| 3567 | #endif
|
|---|
| 3568 |
|
|---|
| 3569 | fResult = (BOOL)HMDeviceRequest(hConsole,
|
|---|
| 3570 | DRQ_SETCONSOLEMODE,
|
|---|
| 3571 | (ULONG)fdwMode,
|
|---|
| 3572 | 0,
|
|---|
| 3573 | 0,
|
|---|
| 3574 | 0);
|
|---|
| 3575 |
|
|---|
| 3576 | return fResult;
|
|---|
| 3577 | }
|
|---|
| 3578 |
|
|---|
| 3579 |
|
|---|
| 3580 | /*****************************************************************************
|
|---|
| 3581 | * Name :
|
|---|
| 3582 | * Purpose :
|
|---|
| 3583 | * Parameters:
|
|---|
| 3584 | * Variables :
|
|---|
| 3585 | * Result :
|
|---|
| 3586 | * Remark :
|
|---|
| 3587 | * Status :
|
|---|
| 3588 | *
|
|---|
| 3589 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3590 | *****************************************************************************/
|
|---|
| 3591 |
|
|---|
| 3592 | BOOL WIN32API SetConsoleOutputCP(UINT IDCodePage)
|
|---|
| 3593 | {
|
|---|
| 3594 | #ifdef DEBUG_LOCAL2
|
|---|
| 3595 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleOutputCP(%08x) not implemented.\n",
|
|---|
| 3596 | IDCodePage);
|
|---|
| 3597 | #endif
|
|---|
| 3598 |
|
|---|
| 3599 | return TRUE;
|
|---|
| 3600 | }
|
|---|
| 3601 |
|
|---|
| 3602 |
|
|---|
| 3603 | /*****************************************************************************
|
|---|
| 3604 | * Name :
|
|---|
| 3605 | * Purpose :
|
|---|
| 3606 | * Parameters:
|
|---|
| 3607 | * Variables :
|
|---|
| 3608 | * Result :
|
|---|
| 3609 | * Remark :
|
|---|
| 3610 | * Status :
|
|---|
| 3611 | *
|
|---|
| 3612 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3613 | *****************************************************************************/
|
|---|
| 3614 |
|
|---|
| 3615 | BOOL WIN32API SetConsoleScreenBufferSize(HANDLE hConsoleOutput,
|
|---|
| 3616 | COORD coordSize)
|
|---|
| 3617 | {
|
|---|
| 3618 | BOOL fResult;
|
|---|
| 3619 |
|
|---|
| 3620 | #ifdef DEBUG_LOCAL2
|
|---|
| 3621 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleScreenBufferSize(%08x,%08x).\n",
|
|---|
| 3622 | hConsoleOutput,
|
|---|
| 3623 | coordSize);
|
|---|
| 3624 | #endif
|
|---|
| 3625 |
|
|---|
| 3626 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3627 | DRQ_SETCONSOLESCREENBUFFERSIZE,
|
|---|
| 3628 | COORD2ULONG(coordSize),
|
|---|
| 3629 | 0,
|
|---|
| 3630 | 0,
|
|---|
| 3631 | 0);
|
|---|
| 3632 |
|
|---|
| 3633 | return fResult;
|
|---|
| 3634 | }
|
|---|
| 3635 |
|
|---|
| 3636 |
|
|---|
| 3637 | /*****************************************************************************
|
|---|
| 3638 | * Name :
|
|---|
| 3639 | * Purpose :
|
|---|
| 3640 | * Parameters:
|
|---|
| 3641 | * Variables :
|
|---|
| 3642 | * Result :
|
|---|
| 3643 | * Remark :
|
|---|
| 3644 | * Status :
|
|---|
| 3645 | *
|
|---|
| 3646 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3647 | *****************************************************************************/
|
|---|
| 3648 |
|
|---|
| 3649 | BOOL WIN32API SetConsoleTextAttribute(HANDLE hConsoleOutput,
|
|---|
| 3650 | WORD wAttr)
|
|---|
| 3651 | {
|
|---|
| 3652 | BOOL fResult;
|
|---|
| 3653 |
|
|---|
| 3654 | #ifdef DEBUG_LOCAL2
|
|---|
| 3655 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleTextAttribute(%08x,%04x).\n",
|
|---|
| 3656 | hConsoleOutput,
|
|---|
| 3657 | wAttr);
|
|---|
| 3658 | #endif
|
|---|
| 3659 |
|
|---|
| 3660 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3661 | DRQ_SETCONSOLETEXTATTRIBUTE,
|
|---|
| 3662 | (ULONG)wAttr,
|
|---|
| 3663 | 0,
|
|---|
| 3664 | 0,
|
|---|
| 3665 | 0);
|
|---|
| 3666 |
|
|---|
| 3667 | return fResult;
|
|---|
| 3668 | }
|
|---|
| 3669 |
|
|---|
| 3670 |
|
|---|
| 3671 | /*****************************************************************************
|
|---|
| 3672 | * Name : BOOL WIN32API SetConsoleTitleA
|
|---|
| 3673 | * Purpose : Set new title text for the console window
|
|---|
| 3674 | * Parameters: LPTSTR lpszTitle
|
|---|
| 3675 | * Variables :
|
|---|
| 3676 | * Result :
|
|---|
| 3677 | * Remark :
|
|---|
| 3678 | * Status : REWRITTEN UNTESTED
|
|---|
| 3679 | *
|
|---|
| 3680 | * Author : Patrick Haller [Tue, 1998/02/12 23:28]
|
|---|
| 3681 | *****************************************************************************/
|
|---|
| 3682 |
|
|---|
| 3683 | BOOL WIN32API SetConsoleTitleA(LPTSTR lpszTitle)
|
|---|
| 3684 | {
|
|---|
| 3685 | #ifdef DEBUG_LOCAL2
|
|---|
| 3686 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleTitleA(%s).\n",
|
|---|
| 3687 | lpszTitle);
|
|---|
| 3688 | #endif
|
|---|
| 3689 |
|
|---|
| 3690 | if (ConsoleGlobals.pszWindowTitle != NULL) /* previously set name */
|
|---|
| 3691 | free (ConsoleGlobals.pszWindowTitle); /* then free it */
|
|---|
| 3692 |
|
|---|
| 3693 | ConsoleGlobals.pszWindowTitle = strdup(lpszTitle); /* copy the new name */
|
|---|
| 3694 |
|
|---|
| 3695 | WinSetWindowText(ConsoleGlobals.hwndFrame, /* set new title text */
|
|---|
| 3696 | ConsoleGlobals.pszWindowTitle);
|
|---|
| 3697 |
|
|---|
| 3698 | return TRUE;
|
|---|
| 3699 | }
|
|---|
| 3700 |
|
|---|
| 3701 |
|
|---|
| 3702 | /*****************************************************************************
|
|---|
| 3703 | * Name : BOOL WIN32API SetConsoleTitleW
|
|---|
| 3704 | * Purpose : Set new title text for the console window
|
|---|
| 3705 | * Parameters: LPTSTR lpszTitle
|
|---|
| 3706 | * Variables :
|
|---|
| 3707 | * Result :
|
|---|
| 3708 | * Remark :
|
|---|
| 3709 | * Status : REWRITTEN UNTESTED
|
|---|
| 3710 | *
|
|---|
| 3711 | * Author : Patrick Haller [Tue, 1998/02/12 23:28]
|
|---|
| 3712 | *****************************************************************************/
|
|---|
| 3713 |
|
|---|
| 3714 | BOOL WIN32API SetConsoleTitleW(LPTSTR lpszTitle)
|
|---|
| 3715 | {
|
|---|
| 3716 | #ifdef DEBUG_LOCAL2
|
|---|
| 3717 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleTitleW(%s) not implemented.\n",
|
|---|
| 3718 | lpszTitle);
|
|---|
| 3719 | #endif
|
|---|
| 3720 |
|
|---|
| 3721 | /* @@@PH Unicode2Ascii */
|
|---|
| 3722 |
|
|---|
| 3723 | if (ConsoleGlobals.pszWindowTitle != NULL) /* previously set name */
|
|---|
| 3724 | free (ConsoleGlobals.pszWindowTitle); /* then free it */
|
|---|
| 3725 |
|
|---|
| 3726 | ConsoleGlobals.pszWindowTitle = strdup(lpszTitle); /* copy the new name */
|
|---|
| 3727 |
|
|---|
| 3728 | WinSetWindowText(ConsoleGlobals.hwndFrame, /* set new title text */
|
|---|
| 3729 | ConsoleGlobals.pszWindowTitle);
|
|---|
| 3730 |
|
|---|
| 3731 | return TRUE;
|
|---|
| 3732 | }
|
|---|
| 3733 |
|
|---|
| 3734 |
|
|---|
| 3735 | /*****************************************************************************
|
|---|
| 3736 | * Name :
|
|---|
| 3737 | * Purpose :
|
|---|
| 3738 | * Parameters:
|
|---|
| 3739 | * Variables :
|
|---|
| 3740 | * Result :
|
|---|
| 3741 | * Remark :
|
|---|
| 3742 | * Status :
|
|---|
| 3743 | *
|
|---|
| 3744 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3745 | *****************************************************************************/
|
|---|
| 3746 |
|
|---|
| 3747 | BOOL WIN32API SetConsoleWindowInfo(HANDLE hConsoleOutput,
|
|---|
| 3748 | BOOL fAbsolute,
|
|---|
| 3749 | PSMALL_RECT psrctWindowRect)
|
|---|
| 3750 | {
|
|---|
| 3751 | BOOL fResult;
|
|---|
| 3752 |
|
|---|
| 3753 | #ifdef DEBUG_LOCAL2
|
|---|
| 3754 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleWindowInfo(%08x,%08x,%08x).\n",
|
|---|
| 3755 | hConsoleOutput,
|
|---|
| 3756 | fAbsolute,
|
|---|
| 3757 | psrctWindowRect);
|
|---|
| 3758 | #endif
|
|---|
| 3759 |
|
|---|
| 3760 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3761 | DRQ_SETCONSOLEWINDOWINFO,
|
|---|
| 3762 | (ULONG)fAbsolute,
|
|---|
| 3763 | (ULONG)psrctWindowRect,
|
|---|
| 3764 | 0,
|
|---|
| 3765 | 0);
|
|---|
| 3766 |
|
|---|
| 3767 | return fResult;
|
|---|
| 3768 | }
|
|---|
| 3769 |
|
|---|
| 3770 |
|
|---|
| 3771 | /*****************************************************************************
|
|---|
| 3772 | * Name :
|
|---|
| 3773 | * Purpose :
|
|---|
| 3774 | * Parameters:
|
|---|
| 3775 | * Variables :
|
|---|
| 3776 | * Result :
|
|---|
| 3777 | * Remark :
|
|---|
| 3778 | * Status :
|
|---|
| 3779 | *
|
|---|
| 3780 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3781 | *****************************************************************************/
|
|---|
| 3782 |
|
|---|
| 3783 | BOOL WIN32API WriteConsoleA(HANDLE hConsoleOutput,
|
|---|
| 3784 | CONST VOID* lpvBuffer,
|
|---|
| 3785 | DWORD cchToWrite,
|
|---|
| 3786 | LPDWORD lpcchWritten,
|
|---|
| 3787 | LPVOID lpvReserved)
|
|---|
| 3788 | {
|
|---|
| 3789 | BOOL fResult;
|
|---|
| 3790 |
|
|---|
| 3791 | #ifdef DEBUG_LOCAL2
|
|---|
| 3792 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3793 | hConsoleOutput,
|
|---|
| 3794 | lpvBuffer,
|
|---|
| 3795 | cchToWrite,
|
|---|
| 3796 | lpcchWritten,
|
|---|
| 3797 | lpvReserved);
|
|---|
| 3798 | #endif
|
|---|
| 3799 |
|
|---|
| 3800 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3801 | DRQ_WRITECONSOLEA,
|
|---|
| 3802 | (ULONG)lpvBuffer,
|
|---|
| 3803 | (ULONG)cchToWrite,
|
|---|
| 3804 | (ULONG)lpcchWritten,
|
|---|
| 3805 | (ULONG)lpvReserved);
|
|---|
| 3806 |
|
|---|
| 3807 | return fResult;
|
|---|
| 3808 | }
|
|---|
| 3809 |
|
|---|
| 3810 |
|
|---|
| 3811 | /*****************************************************************************
|
|---|
| 3812 | * Name :
|
|---|
| 3813 | * Purpose :
|
|---|
| 3814 | * Parameters:
|
|---|
| 3815 | * Variables :
|
|---|
| 3816 | * Result :
|
|---|
| 3817 | * Remark :
|
|---|
| 3818 | * Status :
|
|---|
| 3819 | *
|
|---|
| 3820 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3821 | *****************************************************************************/
|
|---|
| 3822 |
|
|---|
| 3823 | BOOL WIN32API WriteConsoleW(HANDLE hConsoleOutput,
|
|---|
| 3824 | CONST VOID* lpvBuffer,
|
|---|
| 3825 | DWORD cchToWrite,
|
|---|
| 3826 | LPDWORD lpcchWritten,
|
|---|
| 3827 | LPVOID lpvReserved)
|
|---|
| 3828 | {
|
|---|
| 3829 | BOOL fResult;
|
|---|
| 3830 |
|
|---|
| 3831 | #ifdef DEBUG_LOCAL2
|
|---|
| 3832 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3833 | hConsoleOutput,
|
|---|
| 3834 | lpvBuffer,
|
|---|
| 3835 | cchToWrite,
|
|---|
| 3836 | lpcchWritten,
|
|---|
| 3837 | lpvReserved);
|
|---|
| 3838 | #endif
|
|---|
| 3839 |
|
|---|
| 3840 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3841 | DRQ_WRITECONSOLEW,
|
|---|
| 3842 | (ULONG)lpvBuffer,
|
|---|
| 3843 | (ULONG)cchToWrite,
|
|---|
| 3844 | (ULONG)lpcchWritten,
|
|---|
| 3845 | (ULONG)lpvReserved);
|
|---|
| 3846 |
|
|---|
| 3847 | return fResult;
|
|---|
| 3848 | }
|
|---|
| 3849 |
|
|---|
| 3850 |
|
|---|
| 3851 | /*****************************************************************************
|
|---|
| 3852 | * Name :
|
|---|
| 3853 | * Purpose :
|
|---|
| 3854 | * Parameters:
|
|---|
| 3855 | * Variables :
|
|---|
| 3856 | * Result :
|
|---|
| 3857 | * Remark :
|
|---|
| 3858 | * Status :
|
|---|
| 3859 | *
|
|---|
| 3860 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3861 | *****************************************************************************/
|
|---|
| 3862 |
|
|---|
| 3863 | BOOL WIN32API WriteConsoleInputA(HANDLE hConsoleInput,
|
|---|
| 3864 | PINPUT_RECORD pirBuffer,
|
|---|
| 3865 | DWORD cInRecords,
|
|---|
| 3866 | LPDWORD lpcWritten)
|
|---|
| 3867 | {
|
|---|
| 3868 | BOOL fResult;
|
|---|
| 3869 |
|
|---|
| 3870 | #ifdef DEBUG_LOCAL2
|
|---|
| 3871 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
|---|
| 3872 | hConsoleInput,
|
|---|
| 3873 | pirBuffer,
|
|---|
| 3874 | cInRecords,
|
|---|
| 3875 | lpcWritten);
|
|---|
| 3876 | #endif
|
|---|
| 3877 |
|
|---|
| 3878 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3879 | DRQ_WRITECONSOLEINPUTA,
|
|---|
| 3880 | (ULONG)pirBuffer,
|
|---|
| 3881 | (ULONG)cInRecords,
|
|---|
| 3882 | (ULONG)lpcWritten,
|
|---|
| 3883 | 0);
|
|---|
| 3884 |
|
|---|
| 3885 | return fResult;
|
|---|
| 3886 | }
|
|---|
| 3887 |
|
|---|
| 3888 |
|
|---|
| 3889 | /*****************************************************************************
|
|---|
| 3890 | * Name :
|
|---|
| 3891 | * Purpose :
|
|---|
| 3892 | * Parameters:
|
|---|
| 3893 | * Variables :
|
|---|
| 3894 | * Result :
|
|---|
| 3895 | * Remark :
|
|---|
| 3896 | * Status :
|
|---|
| 3897 | *
|
|---|
| 3898 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3899 | *****************************************************************************/
|
|---|
| 3900 |
|
|---|
| 3901 | BOOL WIN32API WriteConsoleInputW(HANDLE hConsoleInput,
|
|---|
| 3902 | PINPUT_RECORD pirBuffer,
|
|---|
| 3903 | DWORD cInRecords,
|
|---|
| 3904 | LPDWORD lpcWritten)
|
|---|
| 3905 | {
|
|---|
| 3906 | BOOL fResult;
|
|---|
| 3907 |
|
|---|
| 3908 | #ifdef DEBUG_LOCAL2
|
|---|
| 3909 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
|---|
| 3910 | hConsoleInput,
|
|---|
| 3911 | pirBuffer,
|
|---|
| 3912 | cInRecords,
|
|---|
| 3913 | lpcWritten);
|
|---|
| 3914 | #endif
|
|---|
| 3915 |
|
|---|
| 3916 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3917 | DRQ_WRITECONSOLEINPUTW,
|
|---|
| 3918 | (ULONG)pirBuffer,
|
|---|
| 3919 | (ULONG)cInRecords,
|
|---|
| 3920 | (ULONG)lpcWritten,
|
|---|
| 3921 | 0);
|
|---|
| 3922 |
|
|---|
| 3923 | return fResult;
|
|---|
| 3924 | }
|
|---|
| 3925 |
|
|---|
| 3926 |
|
|---|
| 3927 | /*****************************************************************************
|
|---|
| 3928 | * Name :
|
|---|
| 3929 | * Purpose :
|
|---|
| 3930 | * Parameters:
|
|---|
| 3931 | * Variables :
|
|---|
| 3932 | * Result :
|
|---|
| 3933 | * Remark :
|
|---|
| 3934 | * Status :
|
|---|
| 3935 | *
|
|---|
| 3936 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3937 | *****************************************************************************/
|
|---|
| 3938 |
|
|---|
| 3939 | BOOL WIN32API WriteConsoleOutputA(HANDLE hConsoleOutput,
|
|---|
| 3940 | PCHAR_INFO pchiSrcBuffer,
|
|---|
| 3941 | COORD coordSrcBufferSize,
|
|---|
| 3942 | COORD coordSrcBufferCoord,
|
|---|
| 3943 | PSMALL_RECT psrctDestRect)
|
|---|
| 3944 | {
|
|---|
| 3945 | BOOL fResult;
|
|---|
| 3946 |
|
|---|
| 3947 | #ifdef DEBUG_LOCAL2
|
|---|
| 3948 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3949 | hConsoleOutput,
|
|---|
| 3950 | pchiSrcBuffer,
|
|---|
| 3951 | coordSrcBufferSize,
|
|---|
| 3952 | coordSrcBufferCoord,
|
|---|
| 3953 | psrctDestRect);
|
|---|
| 3954 | #endif
|
|---|
| 3955 |
|
|---|
| 3956 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3957 | DRQ_WRITECONSOLEOUTPUTA,
|
|---|
| 3958 | (ULONG)pchiSrcBuffer,
|
|---|
| 3959 | COORD2ULONG(coordSrcBufferSize),
|
|---|
| 3960 | COORD2ULONG(coordSrcBufferCoord),
|
|---|
| 3961 | (ULONG)psrctDestRect);
|
|---|
| 3962 |
|
|---|
| 3963 | return fResult;
|
|---|
| 3964 | }
|
|---|
| 3965 |
|
|---|
| 3966 |
|
|---|
| 3967 | /*****************************************************************************
|
|---|
| 3968 | * Name :
|
|---|
| 3969 | * Purpose :
|
|---|
| 3970 | * Parameters:
|
|---|
| 3971 | * Variables :
|
|---|
| 3972 | * Result :
|
|---|
| 3973 | * Remark :
|
|---|
| 3974 | * Status :
|
|---|
| 3975 | *
|
|---|
| 3976 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3977 | *****************************************************************************/
|
|---|
| 3978 |
|
|---|
| 3979 | BOOL WIN32API WriteConsoleOutputW(HANDLE hConsoleOutput,
|
|---|
| 3980 | PCHAR_INFO pchiSrcBuffer,
|
|---|
| 3981 | COORD coordSrcBufferSize,
|
|---|
| 3982 | COORD coordSrcBufferCoord,
|
|---|
| 3983 | PSMALL_RECT psrctDestRect)
|
|---|
| 3984 | {
|
|---|
| 3985 | BOOL fResult;
|
|---|
| 3986 |
|
|---|
| 3987 | #ifdef DEBUG_LOCAL2
|
|---|
| 3988 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3989 | hConsoleOutput,
|
|---|
| 3990 | pchiSrcBuffer,
|
|---|
| 3991 | coordSrcBufferSize,
|
|---|
| 3992 | coordSrcBufferCoord,
|
|---|
| 3993 | psrctDestRect);
|
|---|
| 3994 | #endif
|
|---|
| 3995 |
|
|---|
| 3996 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3997 | DRQ_WRITECONSOLEOUTPUTW,
|
|---|
| 3998 | (ULONG)pchiSrcBuffer,
|
|---|
| 3999 | COORD2ULONG(coordSrcBufferSize),
|
|---|
| 4000 | COORD2ULONG(coordSrcBufferCoord),
|
|---|
| 4001 | (ULONG)psrctDestRect);
|
|---|
| 4002 |
|
|---|
| 4003 | return fResult;
|
|---|
| 4004 | }
|
|---|
| 4005 |
|
|---|
| 4006 | /*****************************************************************************
|
|---|
| 4007 | * Name :
|
|---|
| 4008 | * Purpose :
|
|---|
| 4009 | * Parameters:
|
|---|
| 4010 | * Variables :
|
|---|
| 4011 | * Result :
|
|---|
| 4012 | * Remark :
|
|---|
| 4013 | * Status :
|
|---|
| 4014 | *
|
|---|
| 4015 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 4016 | *****************************************************************************/
|
|---|
| 4017 |
|
|---|
| 4018 | BOOL WIN32API WriteConsoleOutputAttribute(HANDLE hConsoleOutput,
|
|---|
| 4019 | LPWORD lpwAttribute,
|
|---|
| 4020 | DWORD cWriteCells,
|
|---|
| 4021 | COORD coordWriteCoord,
|
|---|
| 4022 | LPDWORD lpcNumberWritten)
|
|---|
| 4023 | {
|
|---|
| 4024 | BOOL fResult;
|
|---|
| 4025 |
|
|---|
| 4026 | #ifdef DEBUG_LOCAL2
|
|---|
| 4027 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputAttribute(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 4028 | hConsoleOutput,
|
|---|
| 4029 | lpwAttribute,
|
|---|
| 4030 | cWriteCells,
|
|---|
| 4031 | coordWriteCoord,
|
|---|
| 4032 | lpcNumberWritten);
|
|---|
| 4033 | #endif
|
|---|
| 4034 |
|
|---|
| 4035 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 4036 | DRQ_WRITECONSOLEOUTPUTATTRIBUTE,
|
|---|
| 4037 | (ULONG)lpwAttribute,
|
|---|
| 4038 | (ULONG)cWriteCells,
|
|---|
| 4039 | COORD2ULONG(coordWriteCoord),
|
|---|
| 4040 | (ULONG)lpcNumberWritten);
|
|---|
| 4041 |
|
|---|
| 4042 | return fResult;
|
|---|
| 4043 | }
|
|---|
| 4044 |
|
|---|
| 4045 |
|
|---|
| 4046 | /*****************************************************************************
|
|---|
| 4047 | * Name :
|
|---|
| 4048 | * Purpose :
|
|---|
| 4049 | * Parameters:
|
|---|
| 4050 | * Variables :
|
|---|
| 4051 | * Result :
|
|---|
| 4052 | * Remark :
|
|---|
| 4053 | * Status :
|
|---|
| 4054 | *
|
|---|
| 4055 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 4056 | *****************************************************************************/
|
|---|
| 4057 |
|
|---|
| 4058 | BOOL WIN32API WriteConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
|---|
| 4059 | LPTSTR lpWriteBuffer,
|
|---|
| 4060 | DWORD cchWrite,
|
|---|
| 4061 | COORD coordWriteCoord,
|
|---|
| 4062 | LPDWORD lpcWritten)
|
|---|
| 4063 | {
|
|---|
| 4064 | BOOL fResult;
|
|---|
| 4065 |
|
|---|
| 4066 | #ifdef DEBUG_LOCAL2
|
|---|
| 4067 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputCharacterA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 4068 | hConsoleOutput,
|
|---|
| 4069 | lpWriteBuffer,
|
|---|
| 4070 | cchWrite,
|
|---|
| 4071 | coordWriteCoord,
|
|---|
| 4072 | lpcWritten);
|
|---|
| 4073 | #endif
|
|---|
| 4074 |
|
|---|
| 4075 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 4076 | DRQ_WRITECONSOLEOUTPUTCHARACTERA,
|
|---|
| 4077 | (ULONG)lpWriteBuffer,
|
|---|
| 4078 | (ULONG)cchWrite,
|
|---|
| 4079 | COORD2ULONG(coordWriteCoord),
|
|---|
| 4080 | (ULONG)lpcWritten);
|
|---|
| 4081 |
|
|---|
| 4082 | return fResult;
|
|---|
| 4083 | }
|
|---|
| 4084 |
|
|---|
| 4085 |
|
|---|
| 4086 | /*****************************************************************************
|
|---|
| 4087 | * Name :
|
|---|
| 4088 | * Purpose :
|
|---|
| 4089 | * Parameters:
|
|---|
| 4090 | * Variables :
|
|---|
| 4091 | * Result :
|
|---|
| 4092 | * Remark :
|
|---|
| 4093 | * Status :
|
|---|
| 4094 | *
|
|---|
| 4095 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 4096 | *****************************************************************************/
|
|---|
| 4097 |
|
|---|
| 4098 | BOOL WIN32API WriteConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
|---|
| 4099 | LPTSTR lpWriteBuffer,
|
|---|
| 4100 | DWORD cchWrite,
|
|---|
| 4101 | COORD coordWriteCoord,
|
|---|
| 4102 | LPDWORD lpcWritten)
|
|---|
| 4103 | {
|
|---|
| 4104 | BOOL fResult;
|
|---|
| 4105 |
|
|---|
| 4106 | #ifdef DEBUG_LOCAL2
|
|---|
| 4107 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputCharacterW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 4108 | hConsoleOutput,
|
|---|
| 4109 | lpWriteBuffer,
|
|---|
| 4110 | cchWrite,
|
|---|
| 4111 | coordWriteCoord,
|
|---|
| 4112 | lpcWritten);
|
|---|
| 4113 | #endif
|
|---|
| 4114 |
|
|---|
| 4115 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 4116 | DRQ_WRITECONSOLEOUTPUTCHARACTERW,
|
|---|
| 4117 | (ULONG)lpWriteBuffer,
|
|---|
| 4118 | (ULONG)cchWrite,
|
|---|
| 4119 | COORD2ULONG(coordWriteCoord),
|
|---|
| 4120 | (ULONG)lpcWritten);
|
|---|
| 4121 |
|
|---|
| 4122 | return fResult;
|
|---|
| 4123 | }
|
|---|