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