| 1 | /* $Id: console.cpp,v 1.18 2000-02-16 14:25:34 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 | #define DBG_LOCALLOG DBG_console
|
|---|
| 87 | #include "dbglocal.h"
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | /***********************************
|
|---|
| 91 | * PH: fixups for missing os2win.h *
|
|---|
| 92 | ***********************************/
|
|---|
| 93 |
|
|---|
| 94 | #include <os2sel.h>
|
|---|
| 95 |
|
|---|
| 96 | extern "C"
|
|---|
| 97 | {
|
|---|
| 98 | void _System _O32_SetLastError(DWORD dwError);
|
|---|
| 99 | DWORD _System _O32_GetLastError(void);
|
|---|
| 100 | LPSTR _System _O32_GetCommandLine(void);
|
|---|
| 101 | void _System _O32_ExitProcess(UINT exitcode);
|
|---|
| 102 | HANDLE _System _O32_GetStdHandle(DWORD dwDevice);
|
|---|
| 103 | DWORD _System _O32_GetFileType(HANDLE hFile);
|
|---|
| 104 |
|
|---|
| 105 | inline void SetLastError(DWORD a)
|
|---|
| 106 | {
|
|---|
| 107 | USHORT sel = GetFS();
|
|---|
| 108 |
|
|---|
| 109 | _O32_SetLastError(a);
|
|---|
| 110 | SetFS(sel);
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | inline DWORD GetLastError()
|
|---|
| 114 | {
|
|---|
| 115 | DWORD yyrc;
|
|---|
| 116 | USHORT sel = GetFS();
|
|---|
| 117 |
|
|---|
| 118 | yyrc = _O32_GetLastError();
|
|---|
| 119 | SetFS(sel);
|
|---|
| 120 |
|
|---|
| 121 | return yyrc;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | inline LPSTR GetCommandLine()
|
|---|
| 125 | {
|
|---|
| 126 | LPSTR yyrc;
|
|---|
| 127 | USHORT sel = GetFS();
|
|---|
| 128 |
|
|---|
| 129 | yyrc = _O32_GetCommandLine();
|
|---|
| 130 | SetFS(sel);
|
|---|
| 131 |
|
|---|
| 132 | return yyrc;
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | inline void ExitProcess(UINT a)
|
|---|
| 136 | {
|
|---|
| 137 | USHORT sel = GetFS();
|
|---|
| 138 |
|
|---|
| 139 | _O32_ExitProcess(a);
|
|---|
| 140 | SetFS(sel);
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | inline HANDLE GetStdHandle(DWORD a)
|
|---|
| 144 | {
|
|---|
| 145 | HANDLE yyrc;
|
|---|
| 146 | USHORT sel = GetFS();
|
|---|
| 147 |
|
|---|
| 148 | yyrc = _O32_GetStdHandle(a);
|
|---|
| 149 | SetFS(sel);
|
|---|
| 150 |
|
|---|
| 151 | return yyrc;
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | inline DWORD GetFileType(HANDLE a)
|
|---|
| 155 | {
|
|---|
| 156 | DWORD yyrc;
|
|---|
| 157 | USHORT sel = GetFS();
|
|---|
| 158 |
|
|---|
| 159 | yyrc = _O32_GetFileType(a);
|
|---|
| 160 | SetFS(sel);
|
|---|
| 161 |
|
|---|
| 162 | return yyrc;
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | /*****************************************************************************
|
|---|
| 168 | * Defines *
|
|---|
| 169 | *****************************************************************************/
|
|---|
| 170 |
|
|---|
| 171 | /*****************************************************************************
|
|---|
| 172 | * Structures *
|
|---|
| 173 | *****************************************************************************/
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 | /*****************************************************************************
|
|---|
| 177 | * Process Global Structures *
|
|---|
| 178 | *****************************************************************************/
|
|---|
| 179 |
|
|---|
| 180 | static ICONSOLEGLOBALS ConsoleGlobals;
|
|---|
| 181 | static ICONSOLEINPUT ConsoleInput;
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | /*****************************************************************************
|
|---|
| 185 | * Prototypes *
|
|---|
| 186 | *****************************************************************************/
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 | /*****************************************************************************
|
|---|
| 190 | * Name : iConsoleInputQueueLock
|
|---|
| 191 | * Purpose : lock the input queue to ensure correct event sequence
|
|---|
| 192 | * Parameters:
|
|---|
| 193 | * Variables :
|
|---|
| 194 | * Result :
|
|---|
| 195 | * Remark :
|
|---|
| 196 | * Status :
|
|---|
| 197 | *
|
|---|
| 198 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 199 | *****************************************************************************/
|
|---|
| 200 |
|
|---|
| 201 | void static iConsoleInputQueueLock()
|
|---|
| 202 | {
|
|---|
| 203 | APIRET rc;
|
|---|
| 204 |
|
|---|
| 205 | rc = DosRequestMutexSem(ConsoleInput.hmtxInputQueue,
|
|---|
| 206 | SEM_INDEFINITE_WAIT);
|
|---|
| 207 | if (rc != NO_ERROR)
|
|---|
| 208 | dprintf(("KERNEL32: Console:iConsoleInputQueueLock error %08xh\n",
|
|---|
| 209 | rc));
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 | /*****************************************************************************
|
|---|
| 214 | * Name : iConsoleInputQueueUnlock
|
|---|
| 215 | * Purpose : unlock the input queue
|
|---|
| 216 | * Parameters:
|
|---|
| 217 | * Variables :
|
|---|
| 218 | * Result :
|
|---|
| 219 | * Remark :
|
|---|
| 220 | * Status :
|
|---|
| 221 | *
|
|---|
| 222 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 223 | *****************************************************************************/
|
|---|
| 224 |
|
|---|
| 225 | void static iConsoleInputQueueUnlock()
|
|---|
| 226 | {
|
|---|
| 227 | APIRET rc;
|
|---|
| 228 |
|
|---|
| 229 | rc = DosReleaseMutexSem(ConsoleInput.hmtxInputQueue);
|
|---|
| 230 | if (rc != NO_ERROR)
|
|---|
| 231 | dprintf(("KERNEL32: Console:iConsoleInputQueueUnlock error %08xh\n",
|
|---|
| 232 | rc));
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 | /*****************************************************************************
|
|---|
| 237 | * Name :
|
|---|
| 238 | * Purpose :
|
|---|
| 239 | * Parameters:
|
|---|
| 240 | * Variables :
|
|---|
| 241 | * Result :
|
|---|
| 242 | * Remark :
|
|---|
| 243 | * Status :
|
|---|
| 244 | *
|
|---|
| 245 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 246 | *****************************************************************************/
|
|---|
| 247 |
|
|---|
| 248 | APIRET iConsoleInit(void) /* creation of the console subsystem */
|
|---|
| 249 | {
|
|---|
| 250 | APIRET rc; /* API return code */
|
|---|
| 251 | ULONG ulPostCount; /* semaphore post counter */
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 | if (ConsoleGlobals.hevConsole != NULLHANDLE) /* we're already initialized ?*/
|
|---|
| 256 | return (NO_ERROR); /* then abort immediately */
|
|---|
| 257 |
|
|---|
| 258 | /* create console synchronization semaphore */
|
|---|
| 259 | rc = DosCreateEventSem (NULL,
|
|---|
| 260 | &ConsoleGlobals.hevConsole,
|
|---|
| 261 | 0L, /* semaphore is private */
|
|---|
| 262 | FALSE); /* reset state */
|
|---|
| 263 | if (rc != NO_ERROR) /* other error ? */
|
|---|
| 264 | return (rc); /* raise error condition */
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 | /* create console input queue semaphore */
|
|---|
| 268 | rc = DosCreateEventSem (NULL,
|
|---|
| 269 | &ConsoleInput.hevInputQueue,
|
|---|
| 270 | 0L, /* semaphore is private */
|
|---|
| 271 | FALSE); /* reset state */
|
|---|
| 272 | if (rc != NO_ERROR) /* other error ? */
|
|---|
| 273 | {
|
|---|
| 274 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
|---|
| 275 | return (rc); /* raise error condition */
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 | rc = DosCreateMutexSem(NULL,
|
|---|
| 280 | &ConsoleInput.hmtxInputQueue,
|
|---|
| 281 | 0L,
|
|---|
| 282 | FALSE);
|
|---|
| 283 | if (rc != NO_ERROR) /* other error ? */
|
|---|
| 284 | {
|
|---|
| 285 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
|---|
| 286 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
|---|
| 287 | return (rc); /* raise error condition */
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 | /***************************************************************************
|
|---|
| 291 | * Create pseudo-devices and initialize ConsoleGlobals *
|
|---|
| 292 | ***************************************************************************/
|
|---|
| 293 |
|
|---|
| 294 | rc = iConsoleDevicesRegister(); /* ensure devices are there */
|
|---|
| 295 | if (rc != NO_ERROR) /* check for errors */
|
|---|
| 296 | {
|
|---|
| 297 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
|---|
| 298 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
|---|
| 299 | return (rc); /* raise error condition */
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 |
|
|---|
| 303 | /***************************************************************************
|
|---|
| 304 | * Presentation Manager Initialization phase *
|
|---|
| 305 | ***************************************************************************/
|
|---|
| 306 |
|
|---|
| 307 | /* OK, we're about to initialize the console subsystem for this process. */
|
|---|
| 308 | /* start message thread for console object window */
|
|---|
| 309 | ConsoleGlobals.tidConsole = _beginthread(iConsoleMsgThread,
|
|---|
| 310 | NULL,
|
|---|
| 311 | 12288,
|
|---|
| 312 | NULL);
|
|---|
| 313 | /* has the thread been created properly ? */
|
|---|
| 314 | if (ConsoleGlobals.tidConsole == -1)
|
|---|
| 315 | {
|
|---|
| 316 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
|---|
| 317 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close event semaphore */
|
|---|
| 318 | ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
|
|---|
| 319 | return (rc); /* raise error condition */
|
|---|
| 320 | }
|
|---|
| 321 | else
|
|---|
| 322 | DosSetPriority(PRTYS_THREAD, /* set priority */
|
|---|
| 323 | ConsoleGlobals.Options.ulConsoleThreadPriorityClass,
|
|---|
| 324 | ConsoleGlobals.Options.ulConsoleThreadPriorityDelta,
|
|---|
| 325 | ConsoleGlobals.tidConsole);
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 | /* wait for the child thread to do it's initialization */
|
|---|
| 329 | /* timeout isn't really useful */
|
|---|
| 330 | rc = DosWaitEventSem(ConsoleGlobals.hevConsole,
|
|---|
| 331 | SEM_INDEFINITE_WAIT);
|
|---|
| 332 | if (rc != NO_ERROR) /* check for errors */
|
|---|
| 333 | {
|
|---|
| 334 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
|---|
| 335 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close event semaphore */
|
|---|
| 336 | ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
|
|---|
| 337 | return (rc); /* raise error condition */
|
|---|
| 338 | }
|
|---|
| 339 |
|
|---|
| 340 | DosResetEventSem(ConsoleGlobals.hevConsole, /* reset event semaphore */
|
|---|
| 341 | &ulPostCount);
|
|---|
| 342 |
|
|---|
| 343 | rc = ConsoleGlobals.rcConsole; /* pass thru console thread's return code */
|
|---|
| 344 |
|
|---|
| 345 | return (rc); /* OK */
|
|---|
| 346 | }
|
|---|
| 347 |
|
|---|
| 348 |
|
|---|
| 349 | /*****************************************************************************
|
|---|
| 350 | * Name : ConsoleDevicesRegister
|
|---|
| 351 | * Purpose : creates and registers console devices if the standard handles
|
|---|
| 352 | * are not redirected to a file
|
|---|
| 353 | * Parameters:
|
|---|
| 354 | * Variables :
|
|---|
| 355 | * Result :
|
|---|
| 356 | * Remark :
|
|---|
| 357 | * Status :
|
|---|
| 358 | *
|
|---|
| 359 | * Author : Patrick Haller [Tue, 1998/03/17 01:55]
|
|---|
| 360 | *****************************************************************************/
|
|---|
| 361 |
|
|---|
| 362 | APIRET iConsoleDevicesRegister(void)
|
|---|
| 363 | {
|
|---|
| 364 | DWORD dwType; /* device handle type */
|
|---|
| 365 | HANDLE hStandardIn; /* stdin handle to CONIN$ */
|
|---|
| 366 | HANDLE hStandardOut; /* stdout handle to CONOUT$ */
|
|---|
| 367 | HANDLE hStandardError; /* stderr handle to CONOUT$ */
|
|---|
| 368 |
|
|---|
| 369 | HMDeviceConsoleInClass *pHMDeviceConsoleIn;
|
|---|
| 370 | HMDeviceConsoleOutClass *pHMDeviceConsoleOut;
|
|---|
| 371 | HMDeviceConsoleBufferClass *pHMDeviceConsoleBuffer;
|
|---|
| 372 |
|
|---|
| 373 | DWORD rc;
|
|---|
| 374 |
|
|---|
| 375 | static fDevicesInitialized; /* have we been initialized already ? */
|
|---|
| 376 |
|
|---|
| 377 | if (fDevicesInitialized == TRUE) /* OK, we're already done */
|
|---|
| 378 | return (NO_ERROR);
|
|---|
| 379 | else
|
|---|
| 380 | fDevicesInitialized = TRUE;
|
|---|
| 381 |
|
|---|
| 382 | dprintf(("KERNEL32:ConsoleDevicesRegister\n"));
|
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 | /*************************************
|
|---|
| 386 | * Initialize Console Window Options *
|
|---|
| 387 | *************************************/
|
|---|
| 388 |
|
|---|
| 389 | // load defaults
|
|---|
| 390 | ConsolePropertyDefault(&ConsoleGlobals.Options);
|
|---|
| 391 |
|
|---|
| 392 | ConsoleGlobals.ulTimerFrequency = 10; /* cursor + blitter timer frequency */
|
|---|
| 393 |
|
|---|
| 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 |
|
|---|
| 400 | ConsoleGlobals.flFrameFlags = FCF_SIZEBORDER | /* frame creation flags */
|
|---|
| 401 | FCF_TITLEBAR |
|
|---|
| 402 | FCF_SHELLPOSITION|
|
|---|
| 403 | FCF_SYSMENU |
|
|---|
| 404 | FCF_TASKLIST |
|
|---|
| 405 | FCF_AUTOICON |
|
|---|
| 406 | FCF_HORZSCROLL |
|
|---|
| 407 | FCF_VERTSCROLL |
|
|---|
| 408 | FCF_MINMAX;
|
|---|
| 409 |
|
|---|
| 410 | /* generate copy of title */
|
|---|
| 411 | ConsoleGlobals.pszWindowTitle = strdup(GetCommandLine());
|
|---|
| 412 |
|
|---|
| 413 | /* obtain module handle to our resources */
|
|---|
| 414 | rc = DosQueryModuleHandle("KERNEL32",
|
|---|
| 415 | &ConsoleGlobals.hmodResource);
|
|---|
| 416 | if (rc != NO_ERROR)
|
|---|
| 417 | WriteLog("KERNEL32/CONSOLE: Can't get handle to KERNEL32 (%u).\n",
|
|---|
| 418 | rc);
|
|---|
| 419 |
|
|---|
| 420 | /* standard console input modes */
|
|---|
| 421 | ConsoleInput.dwConsoleMode = ENABLE_LINE_INPUT |
|
|---|
| 422 | ENABLE_PROCESSED_INPUT;
|
|---|
| 423 | /* @@@PH ENABLE_ECHO_INPUT || ENABLE_MOUSE_INPUT; */
|
|---|
| 424 |
|
|---|
| 425 | ConsoleGlobals.hConsoleBufferDefault = INVALID_HANDLE_VALUE;
|
|---|
| 426 | ConsoleGlobals.hConsoleBuffer = INVALID_HANDLE_VALUE;
|
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 | // defaults are effective, try to read and apply stored properties
|
|---|
| 430 | if (ConsolePropertyLoad(&ConsoleGlobals.Options) == NO_ERROR)
|
|---|
| 431 | ConsolePropertyApply(&ConsoleGlobals.Options);
|
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 | /***************************************************************************
|
|---|
| 435 | * Standard handles Initialization phase *
|
|---|
| 436 | ***************************************************************************/
|
|---|
| 437 |
|
|---|
| 438 | /* create devices and register devices with handlemanager */
|
|---|
| 439 |
|
|---|
| 440 | pHMDeviceConsoleIn = new HMDeviceConsoleInClass("CONIN$",
|
|---|
| 441 | &ConsoleInput,
|
|---|
| 442 | &ConsoleGlobals);
|
|---|
| 443 | rc = HMDeviceRegister ("CONIN$",
|
|---|
| 444 | pHMDeviceConsoleIn);
|
|---|
| 445 | if (rc != NO_ERROR) /* check for errors */
|
|---|
| 446 | dprintf(("KERNEL32:ConsoleDevicesRegister: registering CONIN$ failed with %u.\n",
|
|---|
| 447 | rc));
|
|---|
| 448 |
|
|---|
| 449 |
|
|---|
| 450 | pHMDeviceConsoleOut = new HMDeviceConsoleOutClass("CONOUT$",
|
|---|
| 451 | &ConsoleInput,
|
|---|
| 452 | &ConsoleGlobals);
|
|---|
| 453 | rc = HMDeviceRegister ("CONOUT$",
|
|---|
| 454 | pHMDeviceConsoleOut);
|
|---|
| 455 | if (rc != NO_ERROR) /* check for errors */
|
|---|
| 456 | dprintf(("KERNEL32:ConsoleDevicesRegister: registering CONOUT$ failed with %u.\n",
|
|---|
| 457 | rc));
|
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 | pHMDeviceConsoleBuffer = new HMDeviceConsoleBufferClass("CONBUFFER$",
|
|---|
| 461 | &ConsoleInput,
|
|---|
| 462 | &ConsoleGlobals);
|
|---|
| 463 | rc = HMDeviceRegister ("CONBUFFER$",
|
|---|
| 464 | pHMDeviceConsoleBuffer);
|
|---|
| 465 | if (rc != NO_ERROR) /* check for errors */
|
|---|
| 466 | dprintf(("KERNEL32:ConsoleDevicesRegister: registering CONBUFFER$ failed with %u.\n",
|
|---|
| 467 | rc));
|
|---|
| 468 |
|
|---|
| 469 |
|
|---|
| 470 | /***********************************************************************
|
|---|
| 471 | * initialize stdin handle *
|
|---|
| 472 | ***********************************************************************/
|
|---|
| 473 | hStandardIn = GetStdHandle(STD_INPUT_HANDLE);
|
|---|
| 474 | dwType = GetFileType(hStandardIn);
|
|---|
| 475 | if (dwType == FILE_TYPE_CHAR) /* is handle redirected ? */
|
|---|
| 476 | hStandardIn = HMCreateFile("CONIN$",
|
|---|
| 477 | GENERIC_READ | GENERIC_WRITE,
|
|---|
| 478 | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|---|
| 479 | NULL,
|
|---|
| 480 | 0,
|
|---|
| 481 | CONSOLE_TEXTMODE_BUFFER,
|
|---|
| 482 | 0);
|
|---|
| 483 |
|
|---|
| 484 | HMSetStdHandle(STD_INPUT_HANDLE,
|
|---|
| 485 | hStandardIn);
|
|---|
| 486 |
|
|---|
| 487 | /***********************************************************************
|
|---|
| 488 | * initialize stdout handle *
|
|---|
| 489 | ***********************************************************************/
|
|---|
| 490 | hStandardOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
|---|
| 491 | dwType = GetFileType(hStandardOut);
|
|---|
| 492 | if (dwType == FILE_TYPE_CHAR) /* is handle redirected ? */
|
|---|
| 493 | hStandardOut = HMCreateFile("CONOUT$",
|
|---|
| 494 | GENERIC_READ | GENERIC_WRITE,
|
|---|
| 495 | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|---|
| 496 | NULL,
|
|---|
| 497 | 0,
|
|---|
| 498 | CONSOLE_TEXTMODE_BUFFER,
|
|---|
| 499 | 0);
|
|---|
| 500 |
|
|---|
| 501 | HMSetStdHandle(STD_OUTPUT_HANDLE,
|
|---|
| 502 | hStandardOut);
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 | /***********************************************************************
|
|---|
| 506 | * initialize stderr handle *
|
|---|
| 507 | ***********************************************************************/
|
|---|
| 508 | hStandardError = GetStdHandle(STD_ERROR_HANDLE);
|
|---|
| 509 | dwType = GetFileType(hStandardError);
|
|---|
| 510 | if (dwType == FILE_TYPE_CHAR) /* is handle redirected ? */
|
|---|
| 511 | hStandardError = HMCreateFile("CONOUT$",
|
|---|
| 512 | GENERIC_READ | GENERIC_WRITE,
|
|---|
| 513 | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|---|
| 514 | NULL,
|
|---|
| 515 | 0,
|
|---|
| 516 | CONSOLE_TEXTMODE_BUFFER,
|
|---|
| 517 | 0);
|
|---|
| 518 |
|
|---|
| 519 | HMSetStdHandle(STD_ERROR_HANDLE,
|
|---|
| 520 | hStandardError);
|
|---|
| 521 |
|
|---|
| 522 | return (NO_ERROR); /* OK */
|
|---|
| 523 | }
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 | /*****************************************************************************
|
|---|
| 527 | * Name : static APIRET ConsoleTerminate
|
|---|
| 528 | * Purpose : Shuts the OS/2 console subsystem down
|
|---|
| 529 | * Parameters: VOID
|
|---|
| 530 | * Variables :
|
|---|
| 531 | * Result : OS/2 API return code
|
|---|
| 532 | * Remark : That consolebuffer handle that became allocated as default
|
|---|
| 533 | * screen buffer is lost here. This would be a serious memory
|
|---|
| 534 | * leak if an application keeps opening and closing the console
|
|---|
| 535 | * frequently.
|
|---|
| 536 | * Status :
|
|---|
| 537 | *
|
|---|
| 538 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 539 | *****************************************************************************/
|
|---|
| 540 |
|
|---|
| 541 | ULONG iConsoleTerminate(VOID)
|
|---|
| 542 | {
|
|---|
| 543 | APIRET rc;
|
|---|
| 544 |
|
|---|
| 545 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
|---|
| 546 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
|---|
| 547 | DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */
|
|---|
| 548 |
|
|---|
| 549 |
|
|---|
| 550 | WinPostMsg (ConsoleGlobals.hwndFrame, /* force thread to terminate */
|
|---|
| 551 | WM_CLOSE,
|
|---|
| 552 | (MPARAM)NULL,
|
|---|
| 553 | (MPARAM)NULL);
|
|---|
| 554 |
|
|---|
| 555 | rc = DosWaitThread(&ConsoleGlobals.tidConsole,/* wait until thd terminates */
|
|---|
| 556 | DCWW_WAIT);
|
|---|
| 557 |
|
|---|
| 558 | /* close the consolebuffer handle */
|
|---|
| 559 | HMCloseHandle(ConsoleGlobals.hConsoleBufferDefault);
|
|---|
| 560 | free(ConsoleGlobals.pszWindowTitle); /* free previously allocated memory */
|
|---|
| 561 |
|
|---|
| 562 | return (rc); /* OK */
|
|---|
| 563 | }
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 | /*****************************************************************************
|
|---|
| 567 | * Name : static void ConsoleWaitClose
|
|---|
| 568 | * Purpose : Wait for the user to close console window
|
|---|
| 569 | * Parameters: VOID
|
|---|
| 570 | * Variables :
|
|---|
| 571 | * Result :
|
|---|
| 572 | * Remark :
|
|---|
| 573 | * Status :
|
|---|
| 574 | *
|
|---|
| 575 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 576 | *****************************************************************************/
|
|---|
| 577 |
|
|---|
| 578 | void iConsoleWaitClose(void)
|
|---|
| 579 | {
|
|---|
| 580 | CHAR szBuffer[128]; /* buffer for the title */
|
|---|
| 581 | BOOL fResult; /* result from subsequent calls to Win32 APIs */
|
|---|
| 582 |
|
|---|
| 583 | /* check if there is a console window at all */
|
|---|
| 584 | if (iConsoleIsActive() == FALSE)
|
|---|
| 585 | return; /* nope */
|
|---|
| 586 |
|
|---|
| 587 | strcpy (szBuffer, /* indicate console process has terminated */
|
|---|
| 588 | "Completed: ");
|
|---|
| 589 |
|
|---|
| 590 | fResult = GetConsoleTitleA(szBuffer + 11,/* 11 is length of Completed:_ */
|
|---|
| 591 | sizeof(szBuffer) - 11);
|
|---|
| 592 |
|
|---|
| 593 |
|
|---|
| 594 | /* Set new title: Win32 Console - Terminated */
|
|---|
| 595 | fResult = SetConsoleTitleA(szBuffer);
|
|---|
| 596 |
|
|---|
| 597 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */
|
|---|
| 598 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
|---|
| 599 | DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */
|
|---|
| 600 |
|
|---|
| 601 |
|
|---|
| 602 | /* terminate console immediately ? */
|
|---|
| 603 | if (ConsoleGlobals.Options.fTerminateAutomatically == FALSE)
|
|---|
| 604 | DosWaitThread(&ConsoleGlobals.tidConsole, /* wait until thd terminates */
|
|---|
| 605 | DCWW_WAIT);
|
|---|
| 606 | }
|
|---|
| 607 |
|
|---|
| 608 |
|
|---|
| 609 | /*****************************************************************************
|
|---|
| 610 | * Name : static BOOL ConsoleIsActive
|
|---|
| 611 | * Purpose : Check if Console window is opened
|
|---|
| 612 | * Parameters: VOID
|
|---|
| 613 | * Variables :
|
|---|
| 614 | * Result :
|
|---|
| 615 | * Remark :
|
|---|
| 616 | * Status :
|
|---|
| 617 | *
|
|---|
| 618 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 619 | *****************************************************************************/
|
|---|
| 620 |
|
|---|
| 621 | BOOL iConsoleIsActive(void)
|
|---|
| 622 | {
|
|---|
| 623 | return (NULLHANDLE != ConsoleGlobals.hevConsole);
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 |
|
|---|
| 627 | /*****************************************************************************
|
|---|
| 628 | * Name : static VOID ConsoleMsgThread
|
|---|
| 629 | * Purpose : Message handler thread for the console object window
|
|---|
| 630 | * Parameters: PVOID pDummy
|
|---|
| 631 | * Variables :
|
|---|
| 632 | * Result : is placed in Globals.rcConsole
|
|---|
| 633 | * Remark : the main thread has to wait for this thread
|
|---|
| 634 | * Status :
|
|---|
| 635 | *
|
|---|
| 636 | * Author : Patrick Haller [Tue, 1998/02/10 02:49]
|
|---|
| 637 | *****************************************************************************/
|
|---|
| 638 |
|
|---|
| 639 | VOID iConsoleMsgThread(PVOID pParameters)
|
|---|
| 640 | {
|
|---|
| 641 | APIRET rc; /* API return code */
|
|---|
| 642 |
|
|---|
| 643 |
|
|---|
| 644 | ConsoleGlobals.rcConsole = NO_ERROR; /* initialization */
|
|---|
| 645 |
|
|---|
| 646 | ConsoleGlobals.hab = WinInitialize(0); /* enable thread for PM */
|
|---|
| 647 | if (ConsoleGlobals.hab == NULLHANDLE) /* if anchor block allocation failed */
|
|---|
| 648 | ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
|
|---|
| 649 | else
|
|---|
| 650 | {
|
|---|
| 651 | /* create message queue */
|
|---|
| 652 | ConsoleGlobals.hmq = WinCreateMsgQueue(ConsoleGlobals.hab,
|
|---|
| 653 | 0);
|
|---|
| 654 | if (ConsoleGlobals.hmq == NULLHANDLE) /* if msg queue allocation failed */
|
|---|
| 655 | {
|
|---|
| 656 | WinTerminate(ConsoleGlobals.hab); /* stop thread from accessing PM */
|
|---|
| 657 | ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
|
|---|
| 658 | }
|
|---|
| 659 | else
|
|---|
| 660 | {
|
|---|
| 661 | if (WinRegisterClass(ConsoleGlobals.hab, /* register our class with PM */
|
|---|
| 662 | SZ_CONSOLE_CLASS,
|
|---|
| 663 | iConsoleWindowProc,
|
|---|
| 664 | CS_SIZEREDRAW,
|
|---|
| 665 | 0)
|
|---|
| 666 | == FALSE)
|
|---|
| 667 | {
|
|---|
| 668 | WinDestroyMsgQueue(ConsoleGlobals.hmq); /* destroy message queue */
|
|---|
| 669 | WinTerminate(ConsoleGlobals.hab); /* stop thread from accessing PM */
|
|---|
| 670 | ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
|
|---|
| 671 | }
|
|---|
| 672 | else
|
|---|
| 673 | {
|
|---|
| 674 | ConsoleGlobals.hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
|
|---|
| 675 | WS_VISIBLE,
|
|---|
| 676 | &ConsoleGlobals.flFrameFlags,
|
|---|
| 677 | SZ_CONSOLE_CLASS,
|
|---|
| 678 | ConsoleGlobals.pszWindowTitle,
|
|---|
| 679 | 0,
|
|---|
| 680 | ConsoleGlobals.hmodResource,
|
|---|
| 681 | ID_CONSOLE_MAIN,
|
|---|
| 682 | &ConsoleGlobals.hwndClient);
|
|---|
| 683 | if (ConsoleGlobals.hwndFrame == NULLHANDLE) /* check window creation */
|
|---|
| 684 | {
|
|---|
| 685 | WinDestroyMsgQueue(ConsoleGlobals.hmq); /* destroy message queue */
|
|---|
| 686 | WinTerminate(ConsoleGlobals.hab); /* stop thread from accessing PM */
|
|---|
| 687 | ConsoleGlobals.rcConsole = ERROR_NOT_ENOUGH_MEMORY;
|
|---|
| 688 | } /* WinCreateStdWindow */
|
|---|
| 689 | } /* WinRegisterClass */
|
|---|
| 690 | } /* WinCreateMsgQueue */
|
|---|
| 691 | } /* WinInitialize */
|
|---|
| 692 |
|
|---|
| 693 |
|
|---|
| 694 | DosPostEventSem(ConsoleGlobals.hevConsole); /* signal the main thread */
|
|---|
| 695 |
|
|---|
| 696 |
|
|---|
| 697 | if (ConsoleGlobals.rcConsole != NO_ERROR) /* if we ran into a problem */
|
|---|
| 698 | {
|
|---|
| 699 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
|---|
| 700 | DosCloseEventSem(ConsoleGlobals.hevConsole); /* subsystem not running .. */
|
|---|
| 701 | ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
|
|---|
| 702 | return; /* abort the message queue thread immediately */
|
|---|
| 703 | }
|
|---|
| 704 |
|
|---|
| 705 |
|
|---|
| 706 | while( WinGetMsg(ConsoleGlobals.hab, /* message loop */
|
|---|
| 707 | &ConsoleGlobals.qmsg,
|
|---|
| 708 | NULLHANDLE,
|
|---|
| 709 | 0,
|
|---|
| 710 | 0) )
|
|---|
| 711 | WinDispatchMsg(ConsoleGlobals.hab, /* dispatch the message */
|
|---|
| 712 | &ConsoleGlobals.qmsg);
|
|---|
| 713 |
|
|---|
| 714 | /* do the cleanup, destroy window, queue */
|
|---|
| 715 | /* and stop thread from using PM */
|
|---|
| 716 | WinDestroyWindow (ConsoleGlobals.hwndFrame);
|
|---|
| 717 | WinDestroyMsgQueue(ConsoleGlobals.hmq);
|
|---|
| 718 | WinTerminate (ConsoleGlobals.hab);
|
|---|
| 719 |
|
|---|
| 720 | /* destruction of semaphore indicates console is shutdown */
|
|---|
| 721 | DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */
|
|---|
| 722 | DosCloseEventSem(ConsoleGlobals.hevConsole);
|
|---|
| 723 | DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */
|
|---|
| 724 |
|
|---|
| 725 | ConsoleGlobals.hevConsole = NULLHANDLE; /* for ConsoleIsActive() */
|
|---|
| 726 | ConsoleInput.hevInputQueue = NULLHANDLE;
|
|---|
| 727 | ConsoleInput.hmtxInputQueue = NULLHANDLE;
|
|---|
| 728 |
|
|---|
| 729 | /* @@@PH we've got to exit the process here ! */
|
|---|
| 730 | ExitProcess(1);
|
|---|
| 731 | }
|
|---|
| 732 |
|
|---|
| 733 |
|
|---|
| 734 | /*****************************************************************************
|
|---|
| 735 | * Name : static MRESULT EXPENTRY ConsoleWindowProc
|
|---|
| 736 | * Purpose : Window Procedure for OUR console window
|
|---|
| 737 | * Parameters: HWND hwnd - window handle
|
|---|
| 738 | * ULONG msg - message identifier
|
|---|
| 739 | * MPARAM mp1 - message parameter 1
|
|---|
| 740 | * MPARAM mp2 - message parameter 2
|
|---|
| 741 | * Variables :
|
|---|
| 742 | * Result : MRESULT for PM
|
|---|
| 743 | * Remark :
|
|---|
| 744 | * Status :
|
|---|
| 745 | *
|
|---|
| 746 | * Author : Patrick Haller [Tue, 1998/02/10 03:24]
|
|---|
| 747 | *****************************************************************************/
|
|---|
| 748 |
|
|---|
| 749 | MRESULT EXPENTRY iConsoleWindowProc(HWND hwnd,
|
|---|
| 750 | ULONG msg,
|
|---|
| 751 | MPARAM mp1,
|
|---|
| 752 | MPARAM mp2)
|
|---|
| 753 | {
|
|---|
| 754 | static RECTL rcl; /* window rectangle */
|
|---|
| 755 | static HPS hps;
|
|---|
| 756 |
|
|---|
| 757 | switch(msg)
|
|---|
| 758 | {
|
|---|
| 759 | /*************************************************************************
|
|---|
| 760 | * WM_CREATE window creation *
|
|---|
| 761 | *************************************************************************/
|
|---|
| 762 |
|
|---|
| 763 | case WM_CREATE:
|
|---|
| 764 | WinPostMsg(hwnd, /* deferred initialization */
|
|---|
| 765 | UM_CONSOLE_CREATE,
|
|---|
| 766 | (MPARAM)NULL,
|
|---|
| 767 | (MPARAM)NULL);
|
|---|
| 768 | break;
|
|---|
| 769 |
|
|---|
| 770 |
|
|---|
| 771 | case UM_CONSOLE_CREATE:
|
|---|
| 772 | {
|
|---|
| 773 | APIRET rc; /* API return code */
|
|---|
| 774 | HWND hwndFrame; /* frame window handle */
|
|---|
| 775 |
|
|---|
| 776 | /* subclass the frame window */
|
|---|
| 777 | hwndFrame = ConsoleGlobals.hwndFrame;
|
|---|
| 778 | ConsoleGlobals.pfnwpFrameOriginal = WinSubclassWindow(hwndFrame,
|
|---|
| 779 | iConsoleFrameWindowProc);
|
|---|
| 780 |
|
|---|
| 781 | ConsoleGlobals.hwndMenuConsole
|
|---|
| 782 | = WinLoadMenu (hwnd, /* load context menue */
|
|---|
| 783 | ConsoleGlobals.hmodResource,
|
|---|
| 784 | ID_CONSOLE_MAIN);
|
|---|
| 785 |
|
|---|
| 786 | /* set an icon for the dialog */
|
|---|
| 787 | ConsoleGlobals.hPtrConsole = WinLoadPointer(HWND_DESKTOP,
|
|---|
| 788 | ConsoleGlobals.hmodResource,
|
|---|
| 789 | ID_CONSOLE_MAIN );
|
|---|
| 790 | WinSendMsg(ConsoleGlobals.hwndFrame,
|
|---|
| 791 | WM_SETICON,
|
|---|
| 792 | (MPARAM)ConsoleGlobals.hPtrConsole,
|
|---|
| 793 | 0L );
|
|---|
| 794 |
|
|---|
| 795 | /* determine handles of the horizontal / vertical scroll bars */
|
|---|
| 796 | ConsoleGlobals.hwndVertScroll = WinWindowFromID(ConsoleGlobals.hwndFrame,
|
|---|
| 797 | FID_VERTSCROLL);
|
|---|
| 798 |
|
|---|
| 799 | ConsoleGlobals.hwndHorzScroll = WinWindowFromID(ConsoleGlobals.hwndFrame,
|
|---|
| 800 | FID_HORZSCROLL);
|
|---|
| 801 |
|
|---|
| 802 | /* the initial state of the controls is DETACHED */
|
|---|
| 803 | WinSetParent(ConsoleGlobals.hwndHorzScroll, /* detach control */
|
|---|
| 804 | HWND_OBJECT,
|
|---|
| 805 | FALSE);
|
|---|
| 806 |
|
|---|
| 807 | WinSetParent(ConsoleGlobals.hwndVertScroll, /* detach control */
|
|---|
| 808 | HWND_OBJECT,
|
|---|
| 809 | FALSE);
|
|---|
| 810 |
|
|---|
| 811 |
|
|---|
| 812 | /* create AVIO presentation space */
|
|---|
| 813 | rc = VioCreatePS(&ConsoleGlobals.hvpsConsole,
|
|---|
| 814 | ConsoleGlobals.coordWindowSize.Y,
|
|---|
| 815 | ConsoleGlobals.coordWindowSize.X,
|
|---|
| 816 | 0, /* format, must be 0 */
|
|---|
| 817 | FORMAT_CGA,
|
|---|
| 818 | 0); /* template hvps, must be 0 */
|
|---|
| 819 | if (rc != NO_ERROR) /* check errors */
|
|---|
| 820 | WriteLog("KERNEL32/CONSOLE:VioCreatePS=%u\n",
|
|---|
| 821 | rc);
|
|---|
| 822 |
|
|---|
| 823 | /* PH 1998/02/12 this seems to be an OS/2 PM bug:
|
|---|
| 824 | when doing a WinOpenWindowDC here, PM hangs. Seems it never gets back into
|
|---|
| 825 | the message loop. To investigate and report to IBM
|
|---|
| 826 | */
|
|---|
| 827 |
|
|---|
| 828 | /* get a device context for the client window */
|
|---|
| 829 | ConsoleGlobals.hdcConsole = WinOpenWindowDC(hwnd);
|
|---|
| 830 | /* associate AVIO PS with the HDC */
|
|---|
| 831 | rc = VioAssociate(ConsoleGlobals.hdcConsole,
|
|---|
| 832 | ConsoleGlobals.hvpsConsole);
|
|---|
| 833 | if (rc != NO_ERROR) /* check errors */
|
|---|
| 834 | WriteLog("KERNEL32/CONSOLE:VioAssociate=%u\n",
|
|---|
| 835 | rc);
|
|---|
| 836 |
|
|---|
| 837 | iConsoleFontQuery(); /* query current cell sizes */
|
|---|
| 838 |
|
|---|
| 839 | /* adjust window size and position */
|
|---|
| 840 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
|---|
| 841 | DRQ_INTERNAL_CONSOLEADJUSTWINDOW,
|
|---|
| 842 | 0,
|
|---|
| 843 | 0,
|
|---|
| 844 | 0,
|
|---|
| 845 | 0);
|
|---|
| 846 |
|
|---|
| 847 | /* @@@PH if console is maximized - now switched on per default ! */
|
|---|
| 848 | WinSetWindowPos (ConsoleGlobals.hwndFrame,
|
|---|
| 849 | HWND_DESKTOP,
|
|---|
| 850 | 0,
|
|---|
| 851 | 0,
|
|---|
| 852 | ConsoleGlobals.Options.coordDefaultPosition.X *
|
|---|
| 853 | ConsoleGlobals.sCellCX +
|
|---|
| 854 | 2 * WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER),
|
|---|
| 855 | ConsoleGlobals.Options.coordDefaultPosition.Y *
|
|---|
| 856 | ConsoleGlobals.sCellCY +
|
|---|
| 857 | WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR) +
|
|---|
| 858 | 2 * WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER),
|
|---|
| 859 | SWP_SIZE);
|
|---|
| 860 |
|
|---|
| 861 | /* do we have to set the window position also ? */
|
|---|
| 862 | if (ConsoleGlobals.Options.fSetWindowPosition == TRUE)
|
|---|
| 863 | WinSetWindowPos (ConsoleGlobals.hwndFrame,
|
|---|
| 864 | HWND_DESKTOP,
|
|---|
| 865 | ConsoleGlobals.Options.coordDefaultPosition.X,
|
|---|
| 866 | ConsoleGlobals.Options.coordDefaultPosition.Y,
|
|---|
| 867 | 0,
|
|---|
| 868 | 0,
|
|---|
| 869 | SWP_MOVE);
|
|---|
| 870 |
|
|---|
| 871 | /* start timer service for blitting and cursor blinking */
|
|---|
| 872 | ConsoleGlobals.idTimer = WinStartTimer (ConsoleGlobals.hab,
|
|---|
| 873 | hwnd,
|
|---|
| 874 | CONSOLE_TIMER_ID, /* timer id */
|
|---|
| 875 | ConsoleGlobals.ulTimerFrequency);
|
|---|
| 876 |
|
|---|
| 877 | WinPostMsg (hwnd, /* send myself a start message so we get the first */
|
|---|
| 878 | WM_TIMER, /* frame immediately */
|
|---|
| 879 | (MPARAM)NULL,
|
|---|
| 880 | (MPARAM)NULL);
|
|---|
| 881 | }
|
|---|
| 882 | break;
|
|---|
| 883 |
|
|---|
| 884 |
|
|---|
| 885 | /*************************************************************************
|
|---|
| 886 | * WM_DESTROY window destruction *
|
|---|
| 887 | *************************************************************************/
|
|---|
| 888 |
|
|---|
| 889 | case WM_DESTROY:
|
|---|
| 890 | WinStopTimer (ConsoleGlobals.hab, /* anchor block */
|
|---|
| 891 | hwnd,
|
|---|
| 892 | ConsoleGlobals.idTimer); /* timer ID */
|
|---|
| 893 |
|
|---|
| 894 | VioAssociate(NULL,
|
|---|
| 895 | ConsoleGlobals.hvpsConsole); /* disassociates the AVIO PS */
|
|---|
| 896 | VioDestroyPS(ConsoleGlobals.hvpsConsole); /* destroys the AVIO PS */
|
|---|
| 897 |
|
|---|
| 898 | WinDestroyWindow(ConsoleGlobals.hwndMenuConsole);
|
|---|
| 899 | WinDestroyPointer(ConsoleGlobals.hPtrConsole);
|
|---|
| 900 | break;
|
|---|
| 901 |
|
|---|
| 902 |
|
|---|
| 903 | /*************************************************************************
|
|---|
| 904 | * WM_TIMER display cursor and update AVIO PS if required *
|
|---|
| 905 | *************************************************************************/
|
|---|
| 906 |
|
|---|
| 907 | case WM_TIMER:
|
|---|
| 908 | /* check if console has to be updated */
|
|---|
| 909 | if (ConsoleGlobals.fUpdateRequired == TRUE)
|
|---|
| 910 | {
|
|---|
| 911 | ConsoleGlobals.fUpdateRequired = FALSE; /* as soon as possible ! */
|
|---|
| 912 |
|
|---|
| 913 | /* as device to map itself to the VIO buffer */
|
|---|
| 914 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
|---|
| 915 | DRQ_INTERNAL_CONSOLEBUFFERMAP,
|
|---|
| 916 | 0,
|
|---|
| 917 | 0,
|
|---|
| 918 | 0,
|
|---|
| 919 | 0);
|
|---|
| 920 |
|
|---|
| 921 | { /* DEBUG */
|
|---|
| 922 | APIRET rc;
|
|---|
| 923 | /* and now bring it to the screen */
|
|---|
| 924 | rc = VioShowPS(ConsoleGlobals.coordWindowSize.Y,
|
|---|
| 925 | ConsoleGlobals.coordWindowSize.X,
|
|---|
| 926 | 0,
|
|---|
| 927 | ConsoleGlobals.hvpsConsole);
|
|---|
| 928 |
|
|---|
| 929 | dprintf(("KERNEL32::Console::1 VioShowPS(%u,%u,%u)=%u\n",
|
|---|
| 930 | ConsoleGlobals.coordWindowSize.Y,
|
|---|
| 931 | ConsoleGlobals.coordWindowSize.X,
|
|---|
| 932 | ConsoleGlobals.hvpsConsole,
|
|---|
| 933 | rc));
|
|---|
| 934 | }
|
|---|
| 935 |
|
|---|
| 936 | /* cursor is overwritten here ! */
|
|---|
| 937 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
|---|
| 938 | DRQ_INTERNAL_CONSOLECURSORSHOW,
|
|---|
| 939 | CONSOLECURSOR_OVERWRITTEN,
|
|---|
| 940 | 0,
|
|---|
| 941 | 0,
|
|---|
| 942 | 0);
|
|---|
| 943 | }
|
|---|
| 944 | else
|
|---|
| 945 | {
|
|---|
| 946 | ConsoleGlobals.ulTimerCursor++; /* increase counter */
|
|---|
| 947 | if (ConsoleGlobals.ulTimerCursor > ConsoleGlobals.Options.ucCursorDivisor)
|
|---|
| 948 | {
|
|---|
| 949 | ConsoleGlobals.ulTimerCursor = 0; /* reset counter */
|
|---|
| 950 | /* let our cursor blink */
|
|---|
| 951 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
|---|
| 952 | DRQ_INTERNAL_CONSOLECURSORSHOW,
|
|---|
| 953 | CONSOLECURSOR_BLINK,
|
|---|
| 954 | 0,
|
|---|
| 955 | 0,
|
|---|
| 956 | 0);
|
|---|
| 957 | }
|
|---|
| 958 | }
|
|---|
| 959 | break;
|
|---|
| 960 |
|
|---|
| 961 |
|
|---|
| 962 | /*************************************************************************
|
|---|
| 963 | * WM_MINMAXFRAME handle window repaint in case of iconized window *
|
|---|
| 964 | *************************************************************************/
|
|---|
| 965 |
|
|---|
| 966 | case WM_MINMAXFRAME :
|
|---|
| 967 | {
|
|---|
| 968 | BOOL fShow = ! (((PSWP) mp1)->fl & SWP_MINIMIZE);
|
|---|
| 969 | HENUM henum;
|
|---|
| 970 | HWND hwndChild;
|
|---|
| 971 |
|
|---|
| 972 | WinEnableWindowUpdate ( hwnd, FALSE );
|
|---|
| 973 |
|
|---|
| 974 | for (henum=WinBeginEnumWindows(hwnd);
|
|---|
| 975 | (hwndChild = WinGetNextWindow (henum)) != 0; )
|
|---|
| 976 | WinShowWindow ( hwndChild, fShow );
|
|---|
| 977 |
|
|---|
| 978 | WinEndEnumWindows ( henum );
|
|---|
| 979 | WinEnableWindowUpdate ( hwnd, TRUE );
|
|---|
| 980 | }
|
|---|
| 981 | break;
|
|---|
| 982 |
|
|---|
| 983 |
|
|---|
| 984 | /*************************************************************************
|
|---|
| 985 | * WM_PAINT repaint the window *
|
|---|
| 986 | *************************************************************************/
|
|---|
| 987 | case WM_PAINT:
|
|---|
| 988 | hps = WinBeginPaint(hwnd,
|
|---|
| 989 | (HPS)NULL,
|
|---|
| 990 | &rcl);
|
|---|
| 991 | /* blit the whole AVIO presentation space */
|
|---|
| 992 | { /* DEBUG */
|
|---|
| 993 | APIRET rc;
|
|---|
| 994 | /* and now bring it to the screen */
|
|---|
| 995 | rc = VioShowPS(ConsoleGlobals.coordWindowSize.Y,
|
|---|
| 996 | ConsoleGlobals.coordWindowSize.X,
|
|---|
| 997 | 0,
|
|---|
| 998 | ConsoleGlobals.hvpsConsole);
|
|---|
| 999 |
|
|---|
| 1000 | dprintf(("KERNEL32::Console::2 VioShowPS(%u,%u,%u)=%u\n",
|
|---|
| 1001 | ConsoleGlobals.coordWindowSize.Y,
|
|---|
| 1002 | ConsoleGlobals.coordWindowSize.X,
|
|---|
| 1003 | ConsoleGlobals.hvpsConsole,
|
|---|
| 1004 | rc));
|
|---|
| 1005 | }
|
|---|
| 1006 |
|
|---|
| 1007 | WinEndPaint(hps);
|
|---|
| 1008 | break;
|
|---|
| 1009 |
|
|---|
| 1010 |
|
|---|
| 1011 | /*************************************************************************
|
|---|
| 1012 | * WM_SIZE resize the window *
|
|---|
| 1013 | *************************************************************************/
|
|---|
| 1014 | case WM_SIZE:
|
|---|
| 1015 | {
|
|---|
| 1016 | /* calculate scrollbars if neccessary */
|
|---|
| 1017 | HMDeviceRequest(ConsoleGlobals.hConsoleBuffer,
|
|---|
| 1018 | DRQ_INTERNAL_CONSOLEADJUSTWINDOW,
|
|---|
| 1019 | 0,
|
|---|
| 1020 | 0,
|
|---|
| 1021 | 0,
|
|---|
| 1022 | 0);
|
|---|
| 1023 |
|
|---|
| 1024 | return WinDefAVioWindowProc(hwnd,
|
|---|
| 1025 | (USHORT)msg,
|
|---|
| 1026 | (ULONG)mp1,
|
|---|
| 1027 | (ULONG)mp2);
|
|---|
| 1028 | }
|
|---|
| 1029 |
|
|---|
| 1030 |
|
|---|
| 1031 | /*************************************************************************
|
|---|
| 1032 | * context menue *
|
|---|
| 1033 | *************************************************************************/
|
|---|
| 1034 | case WM_CONTEXTMENU:
|
|---|
| 1035 | {
|
|---|
| 1036 | WinPopupMenu (hwnd,
|
|---|
| 1037 | hwnd,
|
|---|
| 1038 | ConsoleGlobals.hwndMenuConsole,
|
|---|
| 1039 | SHORT1FROMMP(mp1),
|
|---|
| 1040 | SHORT2FROMMP(mp1),
|
|---|
| 1041 | CM_CONSOLE_PROPERTIES, /* item id */
|
|---|
| 1042 | PU_HCONSTRAIN |
|
|---|
| 1043 | PU_VCONSTRAIN |
|
|---|
| 1044 | PU_KEYBOARD |
|
|---|
| 1045 | PU_MOUSEBUTTON1 |
|
|---|
| 1046 | PU_MOUSEBUTTON2 |
|
|---|
| 1047 | PU_POSITIONONITEM);
|
|---|
| 1048 | }
|
|---|
| 1049 | return (MPARAM)FALSE;
|
|---|
| 1050 |
|
|---|
| 1051 |
|
|---|
| 1052 | /*************************************************************************
|
|---|
| 1053 | * WM_COMMAND command processing *
|
|---|
| 1054 | *************************************************************************/
|
|---|
| 1055 | case WM_COMMAND:
|
|---|
| 1056 | {
|
|---|
| 1057 | switch(SHORT1FROMMP(mp1)) /* select appropriate identifier */
|
|---|
| 1058 | {
|
|---|
| 1059 | /* close console window, however we can't call ConsoleTerminate here!*/
|
|---|
| 1060 | case CM_CONSOLE_EXIT:
|
|---|
| 1061 | WinPostMsg (ConsoleGlobals.hwndFrame,
|
|---|
| 1062 | WM_CLOSE,
|
|---|
| 1063 | (MPARAM)NULL,
|
|---|
| 1064 | (MPARAM)NULL);
|
|---|
| 1065 |
|
|---|
| 1066 | return (MPARAM)FALSE;
|
|---|
| 1067 |
|
|---|
| 1068 |
|
|---|
| 1069 | case CM_CONSOLE_REPAINT:
|
|---|
| 1070 | WinInvalidateRect(ConsoleGlobals.hwndClient,/* redraw frame window */
|
|---|
| 1071 | NULL,
|
|---|
| 1072 | TRUE);
|
|---|
| 1073 | return (MPARAM)FALSE;
|
|---|
| 1074 |
|
|---|
| 1075 | /* open the properties dialog */
|
|---|
| 1076 | case CM_CONSOLE_PROPERTIES:
|
|---|
| 1077 | {
|
|---|
| 1078 | ULONG ulResult; /* response from user */
|
|---|
| 1079 |
|
|---|
| 1080 | ConsoleGlobals.Options.hmodResources = /* save module handle */
|
|---|
| 1081 | ConsoleGlobals.hmodResource;
|
|---|
| 1082 |
|
|---|
| 1083 | ulResult = WinDlgBox(HWND_DESKTOP,
|
|---|
| 1084 | ConsoleGlobals.hwndClient,
|
|---|
| 1085 | &ConsolePropertyDlgProc,
|
|---|
| 1086 | ConsoleGlobals.hmodResource,
|
|---|
| 1087 | DLG_CONSOLE_PROPERTIES,
|
|---|
| 1088 | (PVOID)&ConsoleGlobals.Options);
|
|---|
| 1089 | switch (ulResult)
|
|---|
| 1090 | {
|
|---|
| 1091 | case ID_BTN_SAVE:
|
|---|
| 1092 | ConsolePropertySave(&ConsoleGlobals.Options);
|
|---|
| 1093 | ConsolePropertyApply(&ConsoleGlobals.Options);
|
|---|
| 1094 | break;
|
|---|
| 1095 |
|
|---|
| 1096 | case ID_BTN_APPLY:
|
|---|
| 1097 | ConsolePropertyApply(&ConsoleGlobals.Options);
|
|---|
| 1098 | break;
|
|---|
| 1099 |
|
|---|
| 1100 | default: break;
|
|---|
| 1101 | }
|
|---|
| 1102 |
|
|---|
| 1103 | return (MPARAM) FALSE;
|
|---|
| 1104 | }
|
|---|
| 1105 | }
|
|---|
| 1106 | }
|
|---|
| 1107 | break;
|
|---|
| 1108 |
|
|---|
| 1109 |
|
|---|
| 1110 | /*************************************************************************
|
|---|
| 1111 | * WM_CHAR keyboard char processing *
|
|---|
| 1112 | *************************************************************************/
|
|---|
| 1113 |
|
|---|
| 1114 | case WM_CHAR:
|
|---|
| 1115 | iConsoleInputEventPushKey(mp1, /* push event into queue */
|
|---|
| 1116 | mp2);
|
|---|
| 1117 | break; /* enable further processing ! */
|
|---|
| 1118 |
|
|---|
| 1119 |
|
|---|
| 1120 | /*************************************************************************
|
|---|
| 1121 | * WM_SETFOCUS focus changing processing *
|
|---|
| 1122 | *************************************************************************/
|
|---|
| 1123 |
|
|---|
| 1124 | case WM_SETFOCUS:
|
|---|
| 1125 | iConsoleInputEventPushFocus((BOOL)mp2); /* push event into queue */
|
|---|
| 1126 | break; /* enable further processing ! */
|
|---|
| 1127 |
|
|---|
| 1128 |
|
|---|
| 1129 | /*************************************************************************
|
|---|
| 1130 | * WM_MOUSEMOVE mouse event processing *
|
|---|
| 1131 | *************************************************************************/
|
|---|
| 1132 |
|
|---|
| 1133 | case WM_MOUSEMOVE:
|
|---|
| 1134 | case WM_BUTTON1UP:
|
|---|
| 1135 | case WM_BUTTON1DOWN:
|
|---|
| 1136 | case WM_BUTTON2UP:
|
|---|
| 1137 | case WM_BUTTON2DOWN:
|
|---|
| 1138 | case WM_BUTTON3UP:
|
|---|
| 1139 | case WM_BUTTON3DOWN:
|
|---|
| 1140 | case WM_BUTTON1DBLCLK:
|
|---|
| 1141 | case WM_BUTTON2DBLCLK:
|
|---|
| 1142 | case WM_BUTTON3DBLCLK:
|
|---|
| 1143 | iConsoleInputEventPushMouse(msg,
|
|---|
| 1144 | mp1, /* push event into queue */
|
|---|
| 1145 | mp2);
|
|---|
| 1146 | break; /* enable further processing ! */
|
|---|
| 1147 | }
|
|---|
| 1148 |
|
|---|
| 1149 | return WinDefWindowProc(hwnd, /* to default processing */
|
|---|
| 1150 | msg,
|
|---|
| 1151 | mp1,
|
|---|
| 1152 | mp2);
|
|---|
| 1153 | }
|
|---|
| 1154 |
|
|---|
| 1155 |
|
|---|
| 1156 | /*****************************************************************************
|
|---|
| 1157 | * Name : static MRESULT EXPENTRY ConsoleFrameWindowProc
|
|---|
| 1158 | * Purpose : Window Procedure for OUR console frame window
|
|---|
| 1159 | * Parameters: HWND hwnd - window handle
|
|---|
| 1160 | * ULONG msg - message identifier
|
|---|
| 1161 | * MPARAM mp1 - message parameter 1
|
|---|
| 1162 | * MPARAM mp2 - message parameter 2
|
|---|
| 1163 | * Variables :
|
|---|
| 1164 | * Result : MRESULT for PM
|
|---|
| 1165 | * Remark :
|
|---|
| 1166 | * Status :
|
|---|
| 1167 | *
|
|---|
| 1168 | * Author : Patrick Haller [Tue, 1998/02/10 03:24]
|
|---|
| 1169 | *****************************************************************************/
|
|---|
| 1170 |
|
|---|
| 1171 | MRESULT EXPENTRY iConsoleFrameWindowProc(HWND hwnd,
|
|---|
| 1172 | ULONG msg,
|
|---|
| 1173 | MPARAM mp1,
|
|---|
| 1174 | MPARAM mp2)
|
|---|
| 1175 | {
|
|---|
| 1176 | switch(msg)
|
|---|
| 1177 | {
|
|---|
| 1178 | /*************************************************************************
|
|---|
| 1179 | * WM_QUERYTRACKINFO handling *
|
|---|
| 1180 | *************************************************************************/
|
|---|
| 1181 | case WM_QUERYTRACKINFO:
|
|---|
| 1182 | {
|
|---|
| 1183 | MRESULT mr; /* message result */
|
|---|
| 1184 | PTRACKINFO pTrackInfo; /* frame window tracking information */
|
|---|
| 1185 |
|
|---|
| 1186 | /* let the original code do the hard work first */
|
|---|
| 1187 | mr = ConsoleGlobals.pfnwpFrameOriginal(hwnd,
|
|---|
| 1188 | msg,
|
|---|
| 1189 | mp1,
|
|---|
| 1190 | mp2);
|
|---|
| 1191 |
|
|---|
| 1192 | pTrackInfo = (PTRACKINFO)mp2; /* get track information */
|
|---|
| 1193 |
|
|---|
| 1194 | /* @@@PH */
|
|---|
| 1195 | pTrackInfo->ptlMinTrackSize.x = max(pTrackInfo->ptlMinTrackSize.x, 200);
|
|---|
| 1196 | pTrackInfo->ptlMinTrackSize.y = max(pTrackInfo->ptlMinTrackSize.y, 100);
|
|---|
| 1197 | pTrackInfo->ptlMaxTrackSize.x = min(pTrackInfo->ptlMaxTrackSize.x, ConsoleGlobals.coordMaxWindowPels.X);
|
|---|
| 1198 | pTrackInfo->ptlMaxTrackSize.y = min(pTrackInfo->ptlMaxTrackSize.y, ConsoleGlobals.coordMaxWindowPels.Y);
|
|---|
| 1199 |
|
|---|
| 1200 | return (mr); /* deliver result */
|
|---|
| 1201 | }
|
|---|
| 1202 | }
|
|---|
| 1203 |
|
|---|
| 1204 | /* call original frame window procedure code */
|
|---|
| 1205 | return (ConsoleGlobals.pfnwpFrameOriginal(hwnd,
|
|---|
| 1206 | msg,
|
|---|
| 1207 | mp1,
|
|---|
| 1208 | mp2));
|
|---|
| 1209 | }
|
|---|
| 1210 |
|
|---|
| 1211 |
|
|---|
| 1212 | /*****************************************************************************
|
|---|
| 1213 | * Name : static void ConsoleBufferMap
|
|---|
| 1214 | * Purpose : draw a whole consolebuffer into the VIO space
|
|---|
| 1215 | * Parameters: PCONSOLEBUFFER pConsoleBuffer
|
|---|
| 1216 | * Variables :
|
|---|
| 1217 | * Result : none
|
|---|
| 1218 | * Remark :
|
|---|
| 1219 | * Status :
|
|---|
| 1220 | *
|
|---|
| 1221 | * Author : Patrick Haller [Tue, 1998/02/17 12:57]
|
|---|
| 1222 | *****************************************************************************/
|
|---|
| 1223 |
|
|---|
| 1224 | void iConsoleBufferMap(PCONSOLEBUFFER pConsoleBuffer)
|
|---|
| 1225 | {
|
|---|
| 1226 | ULONG ulLine;
|
|---|
| 1227 |
|
|---|
| 1228 | ULONG ulSizeX; /* blitting length and height */
|
|---|
| 1229 | ULONG ulSizeY;
|
|---|
| 1230 |
|
|---|
| 1231 | ulSizeX = 2 * min(ConsoleGlobals.coordWindowSize.X,
|
|---|
| 1232 | pConsoleBuffer->coordBufferSize.X -
|
|---|
| 1233 | ConsoleGlobals.coordWindowPos.X);
|
|---|
| 1234 |
|
|---|
| 1235 | ulSizeY = min(ConsoleGlobals.coordWindowSize.Y,
|
|---|
| 1236 | pConsoleBuffer->coordBufferSize.Y -
|
|---|
| 1237 | ConsoleGlobals.coordWindowPos.Y);
|
|---|
| 1238 |
|
|---|
| 1239 | /* check if we're called with non-existing line buffer */
|
|---|
| 1240 | if (pConsoleBuffer->ppszLine == NULL)
|
|---|
| 1241 | return;
|
|---|
| 1242 |
|
|---|
| 1243 | for (ulLine = ConsoleGlobals.coordWindowPos.Y;
|
|---|
| 1244 | ulLine < ulSizeY;
|
|---|
| 1245 | ulLine++)
|
|---|
| 1246 | VioWrtCellStr(pConsoleBuffer->ppszLine[ulLine] +
|
|---|
| 1247 | ConsoleGlobals.coordWindowPos.X,
|
|---|
| 1248 | ulSizeX,
|
|---|
| 1249 | ulLine,
|
|---|
| 1250 | 0,
|
|---|
| 1251 | ConsoleGlobals.hvpsConsole);
|
|---|
| 1252 | }
|
|---|
| 1253 |
|
|---|
| 1254 |
|
|---|
| 1255 | /*****************************************************************************
|
|---|
| 1256 | * Name : static void ConsoleBufferFillLine
|
|---|
| 1257 | * Purpose : fills a line with a certain output pattern
|
|---|
| 1258 | * Parameters: ULONG ulPattern, PUSHORT pusTarget, ULONG ulSize
|
|---|
| 1259 | * Variables :
|
|---|
| 1260 | * Result : none
|
|---|
| 1261 | * Remark :
|
|---|
| 1262 | * Status :
|
|---|
| 1263 | *
|
|---|
| 1264 | * Author : Patrick Haller [Tue, 1998/02/17 12:57]
|
|---|
| 1265 | *****************************************************************************/
|
|---|
| 1266 |
|
|---|
| 1267 | void iConsoleBufferFillLine(ULONG ulPattern,
|
|---|
| 1268 | PUSHORT pusTarget,
|
|---|
| 1269 | ULONG ulSize)
|
|---|
| 1270 | {
|
|---|
| 1271 | ULONG ulCounter;
|
|---|
| 1272 |
|
|---|
| 1273 | for (ulCounter = 0;
|
|---|
| 1274 | ulCounter < (ulSize >> 1);
|
|---|
| 1275 | ulCounter++,
|
|---|
| 1276 | pusTarget+=2)
|
|---|
| 1277 | *(PULONG)pusTarget = ulPattern;
|
|---|
| 1278 |
|
|---|
| 1279 | if (ulSize & 0x00000001)
|
|---|
| 1280 | *pusTarget = (USHORT)ulPattern;
|
|---|
| 1281 | }
|
|---|
| 1282 |
|
|---|
| 1283 |
|
|---|
| 1284 | /*****************************************************************************
|
|---|
| 1285 | * Name : static void ConsoleBufferScrollUp
|
|---|
| 1286 | * Purpose : scroll whole buffer n lines up,
|
|---|
| 1287 | * fill new lines with default attribute
|
|---|
| 1288 | * Parameters: PCONSOLEBUFFER pConsoleBuffer
|
|---|
| 1289 | * ULONG ulLines
|
|---|
| 1290 | * Variables :
|
|---|
| 1291 | * Result : none
|
|---|
| 1292 | * Remark :
|
|---|
| 1293 | * Status :
|
|---|
| 1294 | *
|
|---|
| 1295 | * Author : Patrick Haller [Tue, 1998/02/17 12:57]
|
|---|
| 1296 | *****************************************************************************/
|
|---|
| 1297 |
|
|---|
| 1298 | void iConsoleBufferScrollUp(PCONSOLEBUFFER pConsoleBuffer,
|
|---|
| 1299 | ULONG ulLines)
|
|---|
| 1300 | {
|
|---|
| 1301 | ULONG ulLine;
|
|---|
| 1302 | ULONG ulPosition;
|
|---|
| 1303 | ULONG ulScrollLine;
|
|---|
| 1304 |
|
|---|
| 1305 | static ULONG ulUpdateCounter; /* counter for jump-scrolling */
|
|---|
| 1306 |
|
|---|
| 1307 | /* calculate new line offset to the first line */
|
|---|
| 1308 | pConsoleBuffer->ulScrollLineOffset += ulLines;
|
|---|
| 1309 | pConsoleBuffer->ulScrollLineOffset %= pConsoleBuffer->coordBufferSize.Y;
|
|---|
| 1310 |
|
|---|
| 1311 | /* do we have to scroll ? */
|
|---|
| 1312 | if (ulLines < pConsoleBuffer->coordBufferSize.Y)
|
|---|
| 1313 | {
|
|---|
| 1314 | for (ulLine = 0; /* do the scrolling */
|
|---|
| 1315 | ulLine < ConsoleGlobals.coordWindowSize.Y;
|
|---|
| 1316 | ulLine++)
|
|---|
| 1317 | {
|
|---|
| 1318 | ulScrollLine = (ulLine + pConsoleBuffer->ulScrollLineOffset)
|
|---|
| 1319 | % pConsoleBuffer->coordBufferSize.Y;
|
|---|
| 1320 |
|
|---|
| 1321 | ulPosition = (ULONG)pConsoleBuffer->ppszLine
|
|---|
| 1322 | + (pConsoleBuffer->coordBufferSize.Y * sizeof (PSZ) )
|
|---|
| 1323 | + (pConsoleBuffer->coordBufferSize.X * 2 * ulScrollLine);
|
|---|
| 1324 |
|
|---|
| 1325 | pConsoleBuffer->ppszLine[ulLine] = (PSZ)ulPosition;
|
|---|
| 1326 | }
|
|---|
| 1327 | }
|
|---|
| 1328 |
|
|---|
| 1329 | /* enforce the upper limit */
|
|---|
| 1330 | if (ulLines > pConsoleBuffer->coordBufferSize.Y)
|
|---|
| 1331 | ulLines = pConsoleBuffer->coordBufferSize.Y;
|
|---|
| 1332 |
|
|---|
| 1333 | ulPosition = ( ((ULONG)(pConsoleBuffer->ucDefaultAttribute) << 8) +
|
|---|
| 1334 | ((ULONG)' ') +
|
|---|
| 1335 | ((ULONG)(pConsoleBuffer->ucDefaultAttribute) << 24) +
|
|---|
| 1336 | ((ULONG)' ' << 16) );
|
|---|
| 1337 |
|
|---|
| 1338 | /* scroll the line index */
|
|---|
| 1339 | for (ulLine = pConsoleBuffer->coordBufferSize.Y - ulLines;
|
|---|
| 1340 | ulLine < pConsoleBuffer->coordBufferSize.Y;
|
|---|
| 1341 | ulLine++)
|
|---|
| 1342 | iConsoleBufferFillLine(ulPosition,
|
|---|
| 1343 | (PUSHORT)(pConsoleBuffer->ppszLine[ulLine]),
|
|---|
| 1344 | pConsoleBuffer->coordBufferSize.X);
|
|---|
| 1345 |
|
|---|
| 1346 | /* this code ensures frequent screen updating, even if the timer prooves */
|
|---|
| 1347 | /* to be to slow */
|
|---|
| 1348 | ulUpdateCounter++;
|
|---|
| 1349 | if (ulUpdateCounter > ConsoleGlobals.Options.ulUpdateLimit)
|
|---|
| 1350 | {
|
|---|
| 1351 | ulUpdateCounter = 0; /* reset the counter */
|
|---|
| 1352 | iConsoleBufferMap(pConsoleBuffer);
|
|---|
| 1353 | VioShowPS(ConsoleGlobals.coordWindowSize.Y,
|
|---|
| 1354 | ConsoleGlobals.coordWindowSize.X,
|
|---|
| 1355 | 0,
|
|---|
| 1356 | ConsoleGlobals.hvpsConsole);
|
|---|
| 1357 |
|
|---|
| 1358 | ConsoleGlobals.fUpdateRequired = FALSE; /* no more required ... */
|
|---|
| 1359 | }
|
|---|
| 1360 | }
|
|---|
| 1361 |
|
|---|
| 1362 |
|
|---|
| 1363 | /*****************************************************************************
|
|---|
| 1364 | * Name : static APIRET ConsoleInputEventPush
|
|---|
| 1365 | * Purpose : add an element to the console input queue
|
|---|
| 1366 | * Parameters: PINPUT_RECORD pInputRecord
|
|---|
| 1367 | * Variables :
|
|---|
| 1368 | * Result : API returncode
|
|---|
| 1369 | * Remark :
|
|---|
| 1370 | * Status :
|
|---|
| 1371 | *
|
|---|
| 1372 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 1373 | *****************************************************************************/
|
|---|
| 1374 |
|
|---|
| 1375 | APIRET iConsoleInputEventPush(PINPUT_RECORD pInputRecord)
|
|---|
| 1376 | {
|
|---|
| 1377 | PINPUT_RECORD pirFree; /* pointer to free record */
|
|---|
| 1378 | APIRET rc; /* API-returncode */
|
|---|
| 1379 |
|
|---|
| 1380 | #ifdef DEBUG_LOCAL2
|
|---|
| 1381 | dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPush(%08x).\n",
|
|---|
| 1382 | pInputRecord));
|
|---|
| 1383 | #endif
|
|---|
| 1384 |
|
|---|
| 1385 | iConsoleInputQueueLock();
|
|---|
| 1386 | /* get free event */
|
|---|
| 1387 | pirFree = &ConsoleInput.arrInputRecord[ConsoleInput.ulIndexFree];
|
|---|
| 1388 | if (pirFree->EventType != 0x0000)
|
|---|
| 1389 | {
|
|---|
| 1390 | iConsoleInputQueueUnlock();
|
|---|
| 1391 | return (ERROR_QUE_NO_MEMORY); /* queue is full ! */
|
|---|
| 1392 | }
|
|---|
| 1393 | /* put event in queue */
|
|---|
| 1394 |
|
|---|
| 1395 | ConsoleInput.ulIndexFree++; /* update index counter */
|
|---|
| 1396 | if (ConsoleInput.ulIndexFree >= CONSOLE_INPUTQUEUESIZE)
|
|---|
| 1397 | ConsoleInput.ulIndexFree = 0;
|
|---|
| 1398 |
|
|---|
| 1399 | ConsoleInput.ulEvents++; /* increate queue event counter */
|
|---|
| 1400 |
|
|---|
| 1401 | iConsoleInputQueueUnlock();
|
|---|
| 1402 |
|
|---|
| 1403 | memcpy(pirFree, /* copy data */
|
|---|
| 1404 | pInputRecord,
|
|---|
| 1405 | sizeof (INPUT_RECORD) );
|
|---|
| 1406 | /* unblock reading threads */
|
|---|
| 1407 | rc = DosPostEventSem(ConsoleInput.hevInputQueue);
|
|---|
| 1408 | return (rc); /* OK */
|
|---|
| 1409 | }
|
|---|
| 1410 |
|
|---|
| 1411 |
|
|---|
| 1412 | /*****************************************************************************
|
|---|
| 1413 | * Name : static APIRET ConsoleInputEventPop
|
|---|
| 1414 | * Purpose : read first element from the console input queue
|
|---|
| 1415 | * Parameters: PINPUT_RECORD pInputRecord
|
|---|
| 1416 | * Variables :
|
|---|
| 1417 | * Result : API returncode
|
|---|
| 1418 | * Remark :
|
|---|
| 1419 | * Status :
|
|---|
| 1420 | *
|
|---|
| 1421 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 1422 | *****************************************************************************/
|
|---|
| 1423 |
|
|---|
| 1424 | APIRET iConsoleInputEventPop(PINPUT_RECORD pInputRecord)
|
|---|
| 1425 | {
|
|---|
| 1426 | PINPUT_RECORD pirEvent; /* pointer to event record */
|
|---|
| 1427 | APIRET rc; /* API-returncode */
|
|---|
| 1428 |
|
|---|
| 1429 | #ifdef DEBUG_LOCAL2
|
|---|
| 1430 | dprintf(("KERNEL32/CONSOLE:ConsoleInputEventPop(%08x).\n",
|
|---|
| 1431 | pInputRecord));
|
|---|
| 1432 | #endif
|
|---|
| 1433 |
|
|---|
| 1434 | if (ConsoleInput.ulEvents == 0) /* empty console ? */
|
|---|
| 1435 | return (ERROR_QUE_EMPTY); /* queue is empty ! */
|
|---|
| 1436 |
|
|---|
| 1437 | iConsoleInputQueueLock();
|
|---|
| 1438 | /* get first event */
|
|---|
| 1439 | pirEvent = &ConsoleInput.arrInputRecord[ConsoleInput.ulIndexEvent];
|
|---|
| 1440 | if (pirEvent->EventType == 0x0000)
|
|---|
| 1441 | {
|
|---|
| 1442 | iConsoleInputQueueUnlock();
|
|---|
| 1443 | return (ERROR_QUE_EMPTY); /* queue is empty ! */
|
|---|
| 1444 | }
|
|---|
| 1445 |
|
|---|
| 1446 | if (ConsoleInput.ulEvents >= 0) /* decrease number of console events */
|
|---|
| 1447 | ConsoleInput.ulEvents--;
|
|---|
| 1448 |
|
|---|
| 1449 | ConsoleInput.ulIndexEvent++; /* update index counter */
|
|---|
| 1450 | if (ConsoleInput.ulIndexEvent >= CONSOLE_INPUTQUEUESIZE)
|
|---|
| 1451 | ConsoleInput.ulIndexEvent = 0;
|
|---|
| 1452 |
|
|---|
| 1453 | /* put event in queue */
|
|---|
| 1454 | memcpy(pInputRecord, /* copy data */
|
|---|
| 1455 | pirEvent,
|
|---|
| 1456 | sizeof (INPUT_RECORD) );
|
|---|
| 1457 |
|
|---|
| 1458 | pirEvent->EventType = 0x0000; /* mark event as read = free */
|
|---|
| 1459 |
|
|---|
| 1460 | iConsoleInputQueueUnlock();
|
|---|
| 1461 |
|
|---|
| 1462 | return (NO_ERROR); /* OK */
|
|---|
| 1463 | }
|
|---|
| 1464 |
|
|---|
| 1465 |
|
|---|
| 1466 | /*****************************************************************************
|
|---|
| 1467 | * Name : static APIRET ConsoleInputEventPushKey
|
|---|
| 1468 | * Purpose : push key event into the queue
|
|---|
| 1469 | * Parameters: MPARAM mp1, MPARAM mp2 from WM_CHAR processing
|
|---|
| 1470 | * Variables :
|
|---|
| 1471 | * Result : API returncode
|
|---|
| 1472 | * Remark : @@@PH: 2nd table that learns codes automatically from "down"
|
|---|
| 1473 | * messages from PM. With Alt-a, etc. it is 0 for "up" ?
|
|---|
| 1474 | * Status :
|
|---|
| 1475 | *
|
|---|
| 1476 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 1477 | *****************************************************************************/
|
|---|
| 1478 |
|
|---|
| 1479 | char 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 |
|
|---|
| 2039 | //@@@PH top calculation is wrong!
|
|---|
| 2040 | rclCursor.yBottom = rclWindow.yTop
|
|---|
| 2041 | - ConsoleGlobals.sCellCY * (pConsoleBuffer->coordCursorPosition.Y + 1);
|
|---|
| 2042 | rclCursor.yTop = rclCursor.yBottom + /* cursor height in percent */
|
|---|
| 2043 | (ConsoleGlobals.sCellCY *
|
|---|
| 2044 | pConsoleBuffer->CursorInfo.dwSize /
|
|---|
| 2045 | 100);
|
|---|
| 2046 |
|
|---|
| 2047 | hps = WinGetPS(ConsoleGlobals.hwndClient); /* get HPS */
|
|---|
| 2048 |
|
|---|
| 2049 | /* @@@PH invert coordinates here ... */
|
|---|
| 2050 | WinInvertRect(hps, /* our cursor is an inverted rectangle */
|
|---|
| 2051 | &rclCursor);
|
|---|
| 2052 |
|
|---|
| 2053 | WinReleasePS(hps); /* release the hps again */
|
|---|
| 2054 | }
|
|---|
| 2055 |
|
|---|
| 2056 |
|
|---|
| 2057 | /*****************************************************************************
|
|---|
| 2058 | * Name : static APIRET ConsoleFontQuery
|
|---|
| 2059 | * Purpose : queries the current font cell sizes
|
|---|
| 2060 | * Parameters:
|
|---|
| 2061 | * Variables :
|
|---|
| 2062 | * Result : API returncode
|
|---|
| 2063 | * Remark :
|
|---|
| 2064 | * Status :
|
|---|
| 2065 | *
|
|---|
| 2066 | * Author : Patrick Haller [Tue, 1998/03/07 16:55]
|
|---|
| 2067 | *****************************************************************************/
|
|---|
| 2068 |
|
|---|
| 2069 | APIRET iConsoleFontQuery (void)
|
|---|
| 2070 | {
|
|---|
| 2071 | return(VioGetDeviceCellSize(&ConsoleGlobals.sCellCY, /* query VIO manager */
|
|---|
| 2072 | &ConsoleGlobals.sCellCX,
|
|---|
| 2073 | ConsoleGlobals.hvpsConsole));
|
|---|
| 2074 | }
|
|---|
| 2075 |
|
|---|
| 2076 |
|
|---|
| 2077 | /*****************************************************************************
|
|---|
| 2078 | * Name : static void ConsoleCursorShow
|
|---|
| 2079 | * Purpose : query number of events in the queue
|
|---|
| 2080 | * Parameters:
|
|---|
| 2081 | * Variables :
|
|---|
| 2082 | * Result : number of events
|
|---|
| 2083 | * Remark : called during INIT, FONTCHANGE, RESIZE, BUFFERCHANGE
|
|---|
| 2084 | * Status :
|
|---|
| 2085 | *
|
|---|
| 2086 | * Author : Patrick Haller [Wed, 1998/04/29 16:55]
|
|---|
| 2087 | *****************************************************************************/
|
|---|
| 2088 |
|
|---|
| 2089 | void iConsoleAdjustWindow (PCONSOLEBUFFER pConsoleBuffer)
|
|---|
| 2090 | {
|
|---|
| 2091 | LONG lX, lY; /* temporary long values */
|
|---|
| 2092 | RECTL rcl;
|
|---|
| 2093 | PRECTL pRcl = &rcl;
|
|---|
| 2094 | ULONG flStyle; /* window frame control style */
|
|---|
| 2095 |
|
|---|
| 2096 | BOOL fNeedVertScroll; /* indicates need of scrollbars */
|
|---|
| 2097 | BOOL fNeedHorzScroll;
|
|---|
| 2098 |
|
|---|
| 2099 | LONG lScrollX; /* width and height of scrollbars */
|
|---|
| 2100 | LONG lScrollY;
|
|---|
| 2101 |
|
|---|
| 2102 | /* now calculate actual window size */
|
|---|
| 2103 | lX = ConsoleGlobals.sCellCX * ConsoleGlobals.coordWindowSize.X;
|
|---|
| 2104 | lY = ConsoleGlobals.sCellCY * ConsoleGlobals.coordWindowSize.Y;
|
|---|
| 2105 |
|
|---|
| 2106 | if ( (ConsoleGlobals.sCellCX == 0) || /* prevent division by zero */
|
|---|
| 2107 | (ConsoleGlobals.sCellCY == 0) )
|
|---|
| 2108 | return;
|
|---|
| 2109 |
|
|---|
| 2110 | /* calculate maximum console window size in pixels for the tracking */
|
|---|
| 2111 | ConsoleGlobals.coordMaxWindowPels.X = ConsoleGlobals.sCellCX * pConsoleBuffer->coordWindowSize.X
|
|---|
| 2112 | + WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER) * 2;
|
|---|
| 2113 |
|
|---|
| 2114 | ConsoleGlobals.coordMaxWindowPels.Y = ConsoleGlobals.sCellCY * pConsoleBuffer->coordWindowSize.Y
|
|---|
| 2115 | + WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER) * 2
|
|---|
| 2116 | + WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);
|
|---|
| 2117 |
|
|---|
| 2118 | /***************************/
|
|---|
| 2119 | /* @@@PH broken code below */
|
|---|
| 2120 | /***************************/
|
|---|
| 2121 | return;
|
|---|
| 2122 |
|
|---|
| 2123 | /* add the window border height and width, etc. */
|
|---|
| 2124 | WinQueryWindowRect (ConsoleGlobals.hwndClient,
|
|---|
| 2125 | pRcl);
|
|---|
| 2126 |
|
|---|
| 2127 | /* calculate visible area */
|
|---|
| 2128 | /* calculate real client window rectangle and take care of the scrollbars */
|
|---|
| 2129 | lScrollX = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
|
|---|
| 2130 | lScrollY = WinQuerySysValue(HWND_DESKTOP, SV_CYHSCROLL);
|
|---|
| 2131 | if (ConsoleGlobals.fHasHorzScroll)
|
|---|
| 2132 | {
|
|---|
| 2133 | lY += lScrollY;
|
|---|
| 2134 | ConsoleGlobals.coordMaxWindowPels.Y += lScrollY;
|
|---|
| 2135 | }
|
|---|
| 2136 |
|
|---|
| 2137 | if (ConsoleGlobals.fHasVertScroll)
|
|---|
| 2138 | {
|
|---|
| 2139 | lX += lScrollX;
|
|---|
| 2140 | ConsoleGlobals.coordMaxWindowPels.X += lScrollX;
|
|---|
| 2141 | }
|
|---|
| 2142 |
|
|---|
| 2143 | /* @@@PH might NOT exceed maximum VioPS size ! */
|
|---|
| 2144 | ConsoleGlobals.coordWindowSize.X = (pRcl->xRight - pRcl->xLeft)
|
|---|
| 2145 | / ConsoleGlobals.sCellCX;
|
|---|
| 2146 |
|
|---|
| 2147 | ConsoleGlobals.coordWindowSize.Y = (pRcl->yTop - pRcl->yBottom)
|
|---|
| 2148 | / ConsoleGlobals.sCellCY;
|
|---|
| 2149 |
|
|---|
| 2150 | /* do we have to enable the scrollbars ? */
|
|---|
| 2151 | fNeedHorzScroll = lX < pConsoleBuffer->coordWindowSize.X * ConsoleGlobals.sCellCX;
|
|---|
| 2152 | fNeedVertScroll = lY < pConsoleBuffer->coordWindowSize.Y * ConsoleGlobals.sCellCY;
|
|---|
| 2153 |
|
|---|
| 2154 |
|
|---|
| 2155 | if ( (ConsoleGlobals.fHasVertScroll != fNeedVertScroll) ||
|
|---|
| 2156 | (ConsoleGlobals.fHasHorzScroll != fNeedHorzScroll) )
|
|---|
| 2157 | {
|
|---|
| 2158 | flStyle = WinQueryWindowULong(ConsoleGlobals.hwndFrame,
|
|---|
| 2159 | QWL_STYLE);
|
|---|
| 2160 |
|
|---|
| 2161 | /* now set or remove the controls */
|
|---|
| 2162 | if (ConsoleGlobals.fHasHorzScroll != fNeedHorzScroll)
|
|---|
| 2163 | if (fNeedHorzScroll)
|
|---|
| 2164 | {
|
|---|
| 2165 | flStyle |= FCF_HORZSCROLL;
|
|---|
| 2166 | WinSetParent(ConsoleGlobals.hwndHorzScroll, /* attach control */
|
|---|
| 2167 | ConsoleGlobals.hwndFrame,
|
|---|
| 2168 | FALSE);
|
|---|
| 2169 | }
|
|---|
| 2170 | else
|
|---|
| 2171 | {
|
|---|
| 2172 | flStyle &= ~FCF_HORZSCROLL;
|
|---|
| 2173 | WinSetParent(ConsoleGlobals.hwndHorzScroll, /* detach control */
|
|---|
| 2174 | HWND_OBJECT,
|
|---|
| 2175 | FALSE);
|
|---|
| 2176 | ConsoleGlobals.coordWindowPos.X = 0; /* we can see the whole buffer */
|
|---|
| 2177 | }
|
|---|
| 2178 |
|
|---|
| 2179 | if (ConsoleGlobals.fHasVertScroll != fNeedVertScroll)
|
|---|
| 2180 | if (fNeedVertScroll)
|
|---|
| 2181 | {
|
|---|
| 2182 | flStyle |= FCF_VERTSCROLL;
|
|---|
| 2183 | WinSetParent(ConsoleGlobals.hwndVertScroll, /* attach control */
|
|---|
| 2184 | ConsoleGlobals.hwndFrame,
|
|---|
| 2185 | FALSE);
|
|---|
| 2186 | }
|
|---|
| 2187 | else
|
|---|
| 2188 | {
|
|---|
| 2189 | flStyle &= ~FCF_VERTSCROLL;
|
|---|
| 2190 | WinSetParent(ConsoleGlobals.hwndVertScroll, /* detach control */
|
|---|
| 2191 | HWND_OBJECT,
|
|---|
| 2192 | FALSE);
|
|---|
| 2193 | ConsoleGlobals.coordWindowPos.Y = 0; /* we can see the whole buffer */
|
|---|
| 2194 | }
|
|---|
| 2195 |
|
|---|
| 2196 |
|
|---|
| 2197 | WinSendMsg(ConsoleGlobals.hwndFrame, /* update frame */
|
|---|
| 2198 | WM_UPDATEFRAME,
|
|---|
| 2199 | MPFROMLONG(flStyle),
|
|---|
| 2200 | MPVOID);
|
|---|
| 2201 |
|
|---|
| 2202 | WinInvalidateRect(ConsoleGlobals.hwndFrame, /* redraw frame window */
|
|---|
| 2203 | NULL,
|
|---|
| 2204 | TRUE);
|
|---|
| 2205 |
|
|---|
| 2206 | ConsoleGlobals.fHasVertScroll = fNeedVertScroll; /* update globals */
|
|---|
| 2207 | ConsoleGlobals.fHasHorzScroll = fNeedHorzScroll; /* update globals */
|
|---|
| 2208 | }
|
|---|
| 2209 |
|
|---|
| 2210 |
|
|---|
| 2211 | /* setup the scrollbars and scrollranges */
|
|---|
| 2212 | if (ConsoleGlobals.fHasVertScroll)
|
|---|
| 2213 | {
|
|---|
| 2214 | /* setup vertical scrollbar */
|
|---|
| 2215 | }
|
|---|
| 2216 |
|
|---|
| 2217 |
|
|---|
| 2218 | if (ConsoleGlobals.fHasHorzScroll)
|
|---|
| 2219 | {
|
|---|
| 2220 | /* setup horizonal scrollbar */
|
|---|
| 2221 | }
|
|---|
| 2222 |
|
|---|
| 2223 |
|
|---|
| 2224 | WinCalcFrameRect(ConsoleGlobals.hwndFrame, /* calculate frame rectangle */
|
|---|
| 2225 | pRcl,
|
|---|
| 2226 | FALSE);
|
|---|
| 2227 |
|
|---|
| 2228 | /* @@@PH client may not overlap frame ! */
|
|---|
| 2229 | /* @@@PH write values to TRACKINFO */
|
|---|
| 2230 |
|
|---|
| 2231 | #if 0
|
|---|
| 2232 | /* @@@PH this results in recursion */
|
|---|
| 2233 | WinSetWindowPos (ConsoleGlobals.hwndClient, /* adjust client window size */
|
|---|
| 2234 | ConsoleGlobals.hwndFrame,
|
|---|
| 2235 | 0,
|
|---|
| 2236 | 0,
|
|---|
| 2237 | lX,
|
|---|
| 2238 | lY,
|
|---|
| 2239 | SWP_SIZE);
|
|---|
| 2240 |
|
|---|
| 2241 | WinSetWindowPos (ConsoleGlobals.hwndFrame, /* adjust client window size */
|
|---|
| 2242 | HWND_DESKTOP,
|
|---|
| 2243 | pRcl->xLeft,
|
|---|
| 2244 | pRcl->yBottom,
|
|---|
| 2245 | pRcl->xRight,
|
|---|
| 2246 | pRcl->yTop,
|
|---|
| 2247 | SWP_SIZE);
|
|---|
| 2248 | #endif
|
|---|
| 2249 | }
|
|---|
| 2250 |
|
|---|
| 2251 |
|
|---|
| 2252 | /*****************************************************************************
|
|---|
| 2253 | * Name : BOOL WIN32API AllocConsole
|
|---|
| 2254 | * Purpose : The AllocConsole function allocates a new console
|
|---|
| 2255 | * for the calling process
|
|---|
| 2256 | * Parameters: VOID
|
|---|
| 2257 | * Variables :
|
|---|
| 2258 | * Result : BOOL: TRUE - function succeeded
|
|---|
| 2259 | * FALSE - function failed. Extended error information
|
|---|
| 2260 | * obtainable via GetLastError
|
|---|
| 2261 | * Remark :
|
|---|
| 2262 | * Status : REWRITTEN UNTESTED
|
|---|
| 2263 | *
|
|---|
| 2264 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2265 | *****************************************************************************/
|
|---|
| 2266 |
|
|---|
| 2267 | BOOL WIN32API AllocConsole(VOID)
|
|---|
| 2268 | {
|
|---|
| 2269 | APIRET rc; /* API returncode */
|
|---|
| 2270 |
|
|---|
| 2271 | #ifdef DEBUG_LOCAL2
|
|---|
| 2272 | WriteLog("KERNEL32/CONSOLE: OS2AllocConsole() called.\n");
|
|---|
| 2273 | #endif
|
|---|
| 2274 |
|
|---|
| 2275 | rc = iConsoleInit(); /* initialize subsystem if required */
|
|---|
| 2276 | if (rc != NO_ERROR) /* check for errors */
|
|---|
| 2277 | {
|
|---|
| 2278 | SetLastError(rc); /* pass thru the error code */
|
|---|
| 2279 | return FALSE; /* signal failure */
|
|---|
| 2280 | }
|
|---|
| 2281 | else
|
|---|
| 2282 | return TRUE; /* Fine ! :) */
|
|---|
| 2283 | }
|
|---|
| 2284 |
|
|---|
| 2285 |
|
|---|
| 2286 | /*****************************************************************************
|
|---|
| 2287 | * Name : HANDLE WIN32API CreateConsoleScreenBuffer
|
|---|
| 2288 | * Purpose : The CreateConsoleScreenBuffer function creates a console
|
|---|
| 2289 | * screen buffer and returns a handle of it.
|
|---|
| 2290 | * Parameters: DWORD dwDesiredAccess - access flag
|
|---|
| 2291 | * DWORD dwShareMode - buffer share more
|
|---|
| 2292 | * PVOID pIgnored - LPSECURITY_ATTRIBUTES -> NT
|
|---|
| 2293 | * DWORD dwFlags - type of buffer to create
|
|---|
| 2294 | * LPVOID lpScreenBufferData - reserved
|
|---|
| 2295 | * Variables :
|
|---|
| 2296 | * Result :
|
|---|
| 2297 | * Remark : a console buffer is a kernel heap object equipped with
|
|---|
| 2298 | * share modes, access rights, etc.
|
|---|
| 2299 | * we can't really map this to OS/2 unless we build a
|
|---|
| 2300 | * console device driver for it ... maybe this turns out to
|
|---|
| 2301 | * be necessary since we've got to handle CONIN$ and CONOUT$, too.
|
|---|
| 2302 | * Status :
|
|---|
| 2303 | *
|
|---|
| 2304 | * Author : Patrick Haller [Tue, 1998/02/10 03:55]
|
|---|
| 2305 | *****************************************************************************/
|
|---|
| 2306 |
|
|---|
| 2307 | HANDLE WIN32API CreateConsoleScreenBuffer(DWORD dwDesiredAccess,
|
|---|
| 2308 | DWORD dwShareMode,
|
|---|
| 2309 | LPVOID lpSecurityAttributes,
|
|---|
| 2310 | DWORD dwFlags,
|
|---|
| 2311 | LPVOID lpScreenBufferData)
|
|---|
| 2312 | {
|
|---|
| 2313 | HANDLE hResult;
|
|---|
| 2314 |
|
|---|
| 2315 | #ifdef DEBUG_LOCAL2
|
|---|
| 2316 | WriteLog("KERNEL32/CONSOLE:OS2CreateConsoleScreenBuffer(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 2317 | dwDesiredAccess,
|
|---|
| 2318 | dwShareMode,
|
|---|
| 2319 | lpSecurityAttributes,
|
|---|
| 2320 | dwFlags,
|
|---|
| 2321 | lpScreenBufferData);
|
|---|
| 2322 | #endif
|
|---|
| 2323 |
|
|---|
| 2324 | hResult = HMCreateFile("CONBUFFER$", /* create a new buffer handle */
|
|---|
| 2325 | dwDesiredAccess,
|
|---|
| 2326 | dwShareMode,
|
|---|
| 2327 | (LPSECURITY_ATTRIBUTES)lpSecurityAttributes,
|
|---|
| 2328 | 0,
|
|---|
| 2329 | dwFlags,
|
|---|
| 2330 | INVALID_HANDLE_VALUE);
|
|---|
| 2331 |
|
|---|
| 2332 | return hResult;
|
|---|
| 2333 | }
|
|---|
| 2334 |
|
|---|
| 2335 |
|
|---|
| 2336 | /*****************************************************************************
|
|---|
| 2337 | * Name :
|
|---|
| 2338 | * Purpose :
|
|---|
| 2339 | * Parameters:
|
|---|
| 2340 | * Variables :
|
|---|
| 2341 | * Result :
|
|---|
| 2342 | * Remark :
|
|---|
| 2343 | * Status :
|
|---|
| 2344 | *
|
|---|
| 2345 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2346 | *****************************************************************************/
|
|---|
| 2347 |
|
|---|
| 2348 | BOOL WIN32API FillConsoleOutputAttribute(HANDLE hConsoleOutput,
|
|---|
| 2349 | WORD wAttribute,
|
|---|
| 2350 | DWORD nLength,
|
|---|
| 2351 | COORD dwWriteCoord,
|
|---|
| 2352 | LPDWORD lpNumberOfAttrsWritten)
|
|---|
| 2353 | {
|
|---|
| 2354 | BOOL fResult;
|
|---|
| 2355 |
|
|---|
| 2356 | #ifdef DEBUG_LOCAL2
|
|---|
| 2357 | WriteLog("KERNEL32/CONSOLE: OS2FillConsoleOutputAttribute(%08x,%04x,%08x,%08x,%08x).\n",
|
|---|
| 2358 | hConsoleOutput,
|
|---|
| 2359 | wAttribute,
|
|---|
| 2360 | nLength,
|
|---|
| 2361 | dwWriteCoord,
|
|---|
| 2362 | lpNumberOfAttrsWritten);
|
|---|
| 2363 | #endif
|
|---|
| 2364 |
|
|---|
| 2365 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2366 | DRQ_FILLCONSOLEOUTPUTATTRIBUTE,
|
|---|
| 2367 | (ULONG)wAttribute,
|
|---|
| 2368 | (ULONG)nLength,
|
|---|
| 2369 | COORD2ULONG(dwWriteCoord),
|
|---|
| 2370 | (ULONG)lpNumberOfAttrsWritten);
|
|---|
| 2371 |
|
|---|
| 2372 | return fResult;
|
|---|
| 2373 | }
|
|---|
| 2374 |
|
|---|
| 2375 |
|
|---|
| 2376 | /*****************************************************************************
|
|---|
| 2377 | * Name :
|
|---|
| 2378 | * Purpose :
|
|---|
| 2379 | * Parameters:
|
|---|
| 2380 | * Variables :
|
|---|
| 2381 | * Result :
|
|---|
| 2382 | * Remark :
|
|---|
| 2383 | * Status :
|
|---|
| 2384 | *
|
|---|
| 2385 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2386 | *****************************************************************************/
|
|---|
| 2387 |
|
|---|
| 2388 | BOOL WIN32API FillConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
|---|
| 2389 | UCHAR cCharacter,
|
|---|
| 2390 | DWORD nLength,
|
|---|
| 2391 | COORD dwWriteCoord,
|
|---|
| 2392 | LPDWORD lpNumberOfCharsWritten )
|
|---|
| 2393 | {
|
|---|
| 2394 | BOOL fResult;
|
|---|
| 2395 |
|
|---|
| 2396 | #ifdef DEBUG_LOCAL2
|
|---|
| 2397 | WriteLog("KERNEL32/CONSOLE: OS2FillConsoleOutputCharacterA(%08x,%c,%08x,%08x,%08x).\n",
|
|---|
| 2398 | hConsoleOutput,
|
|---|
| 2399 | cCharacter,
|
|---|
| 2400 | nLength,
|
|---|
| 2401 | dwWriteCoord,
|
|---|
| 2402 | lpNumberOfCharsWritten);
|
|---|
| 2403 | #endif
|
|---|
| 2404 |
|
|---|
| 2405 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2406 | DRQ_FILLCONSOLEOUTPUTCHARACTERA,
|
|---|
| 2407 | (ULONG)cCharacter,
|
|---|
| 2408 | (ULONG)nLength,
|
|---|
| 2409 | COORD2ULONG(dwWriteCoord),
|
|---|
| 2410 | (ULONG)lpNumberOfCharsWritten);
|
|---|
| 2411 |
|
|---|
| 2412 | return fResult;
|
|---|
| 2413 | }
|
|---|
| 2414 |
|
|---|
| 2415 |
|
|---|
| 2416 | /*****************************************************************************
|
|---|
| 2417 | * Name :
|
|---|
| 2418 | * Purpose :
|
|---|
| 2419 | * Parameters:
|
|---|
| 2420 | * Variables :
|
|---|
| 2421 | * Result :
|
|---|
| 2422 | * Remark :
|
|---|
| 2423 | * Status :
|
|---|
| 2424 | *
|
|---|
| 2425 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2426 | *****************************************************************************/
|
|---|
| 2427 |
|
|---|
| 2428 | BOOL WIN32API FillConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
|---|
| 2429 | WCHAR cCharacter,
|
|---|
| 2430 | DWORD nLength,
|
|---|
| 2431 | COORD dwWriteCoord,
|
|---|
| 2432 | LPDWORD lpNumberOfCharsWritten )
|
|---|
| 2433 | {
|
|---|
| 2434 | BOOL fResult;
|
|---|
| 2435 |
|
|---|
| 2436 | #ifdef DEBUG_LOCAL2
|
|---|
| 2437 | WriteLog("KERNEL32/CONSOLE: OS2FillConsoleOutputCharacterW(%08x,%c,%08x,%08x,%08x) .\n",
|
|---|
| 2438 | hConsoleOutput,
|
|---|
| 2439 | cCharacter,
|
|---|
| 2440 | nLength,
|
|---|
| 2441 | dwWriteCoord,
|
|---|
| 2442 | lpNumberOfCharsWritten);
|
|---|
| 2443 | #endif
|
|---|
| 2444 |
|
|---|
| 2445 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2446 | DRQ_FILLCONSOLEOUTPUTCHARACTERW,
|
|---|
| 2447 | (ULONG)cCharacter,
|
|---|
| 2448 | (ULONG)nLength,
|
|---|
| 2449 | COORD2ULONG(dwWriteCoord),
|
|---|
| 2450 | (ULONG)lpNumberOfCharsWritten);
|
|---|
| 2451 |
|
|---|
| 2452 | return fResult;
|
|---|
| 2453 | }
|
|---|
| 2454 |
|
|---|
| 2455 |
|
|---|
| 2456 | /*****************************************************************************
|
|---|
| 2457 | * Name :
|
|---|
| 2458 | * Purpose :
|
|---|
| 2459 | * Parameters:
|
|---|
| 2460 | * Variables :
|
|---|
| 2461 | * Result :
|
|---|
| 2462 | * Remark :
|
|---|
| 2463 | * Status :
|
|---|
| 2464 | *
|
|---|
| 2465 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2466 | *****************************************************************************/
|
|---|
| 2467 |
|
|---|
| 2468 | BOOL WIN32API FlushConsoleInputBuffer( HANDLE hConsoleInput )
|
|---|
| 2469 | {
|
|---|
| 2470 | BOOL fResult;
|
|---|
| 2471 |
|
|---|
| 2472 | #ifdef DEBUG_LOCAL2
|
|---|
| 2473 | WriteLog("KERNEL32/CONSOLE: OS2FlushConsoleInputBuffer(%08x).\n",
|
|---|
| 2474 | hConsoleInput);
|
|---|
| 2475 | #endif
|
|---|
| 2476 |
|
|---|
| 2477 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2478 | DRQ_FLUSHCONSOLEINPUTBUFFER,
|
|---|
| 2479 | 0,
|
|---|
| 2480 | 0,
|
|---|
| 2481 | 0,
|
|---|
| 2482 | 0);
|
|---|
| 2483 |
|
|---|
| 2484 | return fResult;
|
|---|
| 2485 | }
|
|---|
| 2486 |
|
|---|
| 2487 |
|
|---|
| 2488 | /*****************************************************************************
|
|---|
| 2489 | * Name : BOOL WIN32API FreeConsole
|
|---|
| 2490 | * Purpose : The FreeConsole function detaches the calling process
|
|---|
| 2491 | * from its console.
|
|---|
| 2492 | * Parameters: VOID
|
|---|
| 2493 | * Variables :
|
|---|
| 2494 | * Result : BOOL: TRUE - function succeeded
|
|---|
| 2495 | * FALSE - function failed. Extended error information
|
|---|
| 2496 | * obtainable via GetLastError
|
|---|
| 2497 | * Remark :
|
|---|
| 2498 | * Status : REWRITTEN UNTESTED
|
|---|
| 2499 | *
|
|---|
| 2500 | * Author : Patrick Haller [Tue, 1998/02/10 03:35]
|
|---|
| 2501 | *****************************************************************************/
|
|---|
| 2502 |
|
|---|
| 2503 | BOOL WIN32API FreeConsole( VOID )
|
|---|
| 2504 | {
|
|---|
| 2505 | APIRET rc; /* API returncode */
|
|---|
| 2506 |
|
|---|
| 2507 | #ifdef DEBUG_LOCAL2
|
|---|
| 2508 | WriteLog("KERNEL32/CONSOLE: OS2FreeConsole() called.\n");
|
|---|
| 2509 | #endif
|
|---|
| 2510 |
|
|---|
| 2511 | rc = iConsoleTerminate(); /* terminate subsystem if required */
|
|---|
| 2512 | if (rc != NO_ERROR) /* check for errors */
|
|---|
| 2513 | {
|
|---|
| 2514 | SetLastError(rc); /* pass thru the error code */
|
|---|
| 2515 | return FALSE; /* signal failure */
|
|---|
| 2516 | }
|
|---|
| 2517 | else
|
|---|
| 2518 | return TRUE; /* Fine ! :) */
|
|---|
| 2519 |
|
|---|
| 2520 | return TRUE;
|
|---|
| 2521 | }
|
|---|
| 2522 |
|
|---|
| 2523 |
|
|---|
| 2524 | /*****************************************************************************
|
|---|
| 2525 | * Name :
|
|---|
| 2526 | * Purpose :
|
|---|
| 2527 | * Parameters:
|
|---|
| 2528 | * Variables :
|
|---|
| 2529 | * Result :
|
|---|
| 2530 | * Remark :
|
|---|
| 2531 | * Status :
|
|---|
| 2532 | *
|
|---|
| 2533 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2534 | *****************************************************************************/
|
|---|
| 2535 |
|
|---|
| 2536 | BOOL WIN32API GenerateConsoleCtrlEvent(DWORD dwCtrlEvent,
|
|---|
| 2537 | DWORD dwProcessGroupId)
|
|---|
| 2538 | {
|
|---|
| 2539 | #ifdef DEBUG_LOCAL2
|
|---|
| 2540 | WriteLog("KERNEL32/CONSOLE: OS2GenerateConsoleCtrlEvent(%08x,%08x) not implemented.\n",
|
|---|
| 2541 | dwCtrlEvent,
|
|---|
| 2542 | dwProcessGroupId);
|
|---|
| 2543 | #endif
|
|---|
| 2544 |
|
|---|
| 2545 | return TRUE;
|
|---|
| 2546 | }
|
|---|
| 2547 |
|
|---|
| 2548 |
|
|---|
| 2549 | /*****************************************************************************
|
|---|
| 2550 | * Name :
|
|---|
| 2551 | * Purpose :
|
|---|
| 2552 | * Parameters:
|
|---|
| 2553 | * Variables :
|
|---|
| 2554 | * Result :
|
|---|
| 2555 | * Remark :
|
|---|
| 2556 | * Status :
|
|---|
| 2557 | *
|
|---|
| 2558 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2559 | *****************************************************************************/
|
|---|
| 2560 |
|
|---|
| 2561 | UINT WIN32API GetConsoleCP(VOID)
|
|---|
| 2562 | {
|
|---|
| 2563 | #ifdef DEBUG_LOCAL2
|
|---|
| 2564 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleCP not implemented.\n");
|
|---|
| 2565 | #endif
|
|---|
| 2566 |
|
|---|
| 2567 | return 1;
|
|---|
| 2568 | }
|
|---|
| 2569 |
|
|---|
| 2570 |
|
|---|
| 2571 | /*****************************************************************************
|
|---|
| 2572 | * Name :
|
|---|
| 2573 | * Purpose :
|
|---|
| 2574 | * Parameters:
|
|---|
| 2575 | * Variables :
|
|---|
| 2576 | * Result :
|
|---|
| 2577 | * Remark :
|
|---|
| 2578 | * Status :
|
|---|
| 2579 | *
|
|---|
| 2580 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2581 | *****************************************************************************/
|
|---|
| 2582 |
|
|---|
| 2583 | BOOL WIN32API GetConsoleCursorInfo(HANDLE hConsoleOutput,
|
|---|
| 2584 | PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
|
|---|
| 2585 | {
|
|---|
| 2586 | BOOL fResult;
|
|---|
| 2587 |
|
|---|
| 2588 | #ifdef DEBUG_LOCAL2
|
|---|
| 2589 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleCursorInfo(%08x,%08x).\n",
|
|---|
| 2590 | hConsoleOutput,
|
|---|
| 2591 | lpConsoleCursorInfo);
|
|---|
| 2592 | #endif
|
|---|
| 2593 |
|
|---|
| 2594 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2595 | DRQ_GETCONSOLECURSORINFO,
|
|---|
| 2596 | (ULONG)lpConsoleCursorInfo,
|
|---|
| 2597 | 0,
|
|---|
| 2598 | 0,
|
|---|
| 2599 | 0);
|
|---|
| 2600 |
|
|---|
| 2601 | return fResult;
|
|---|
| 2602 | }
|
|---|
| 2603 |
|
|---|
| 2604 |
|
|---|
| 2605 | /*****************************************************************************
|
|---|
| 2606 | * Name :
|
|---|
| 2607 | * Purpose :
|
|---|
| 2608 | * Parameters:
|
|---|
| 2609 | * Variables :
|
|---|
| 2610 | * Result :
|
|---|
| 2611 | * Remark :
|
|---|
| 2612 | * Status :
|
|---|
| 2613 | *
|
|---|
| 2614 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2615 | *****************************************************************************/
|
|---|
| 2616 |
|
|---|
| 2617 | BOOL WIN32API GetConsoleMode(HANDLE hConsole,
|
|---|
| 2618 | LPDWORD lpMode)
|
|---|
| 2619 | {
|
|---|
| 2620 | BOOL fResult;
|
|---|
| 2621 |
|
|---|
| 2622 | #ifdef DEBUG_LOCAL2
|
|---|
| 2623 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleMode(%08x,%08x).\n",
|
|---|
| 2624 | hConsole,
|
|---|
| 2625 | lpMode);
|
|---|
| 2626 | #endif
|
|---|
| 2627 |
|
|---|
| 2628 | fResult = (BOOL)HMDeviceRequest(hConsole,
|
|---|
| 2629 | DRQ_GETCONSOLEMODE,
|
|---|
| 2630 | (ULONG) lpMode,
|
|---|
| 2631 | 0,
|
|---|
| 2632 | 0,
|
|---|
| 2633 | 0);
|
|---|
| 2634 |
|
|---|
| 2635 | return fResult;
|
|---|
| 2636 | }
|
|---|
| 2637 |
|
|---|
| 2638 |
|
|---|
| 2639 | /*****************************************************************************
|
|---|
| 2640 | * Name :
|
|---|
| 2641 | * Purpose :
|
|---|
| 2642 | * Parameters:
|
|---|
| 2643 | * Variables :
|
|---|
| 2644 | * Result :
|
|---|
| 2645 | * Remark :
|
|---|
| 2646 | * Status :
|
|---|
| 2647 | *
|
|---|
| 2648 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2649 | *****************************************************************************/
|
|---|
| 2650 |
|
|---|
| 2651 | UINT WIN32API GetConsoleOutputCP(VOID)
|
|---|
| 2652 | {
|
|---|
| 2653 | #ifdef DEBUG_LOCAL2
|
|---|
| 2654 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleOutputCP not implemented.\n");
|
|---|
| 2655 | #endif
|
|---|
| 2656 |
|
|---|
| 2657 | return 1;
|
|---|
| 2658 | }
|
|---|
| 2659 |
|
|---|
| 2660 |
|
|---|
| 2661 | /*****************************************************************************
|
|---|
| 2662 | * Name :
|
|---|
| 2663 | * Purpose :
|
|---|
| 2664 | * Parameters:
|
|---|
| 2665 | * Variables :
|
|---|
| 2666 | * Result :
|
|---|
| 2667 | * Remark :
|
|---|
| 2668 | * Status :
|
|---|
| 2669 | *
|
|---|
| 2670 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2671 | *****************************************************************************/
|
|---|
| 2672 |
|
|---|
| 2673 | BOOL WIN32API GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
|
|---|
| 2674 | PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
|
|---|
| 2675 | {
|
|---|
| 2676 | BOOL fResult;
|
|---|
| 2677 |
|
|---|
| 2678 | #ifdef DEBUG_LOCAL2
|
|---|
| 2679 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleScreenBufferInfo(%08x,%08x).\n",
|
|---|
| 2680 | hConsoleOutput,
|
|---|
| 2681 | lpConsoleScreenBufferInfo);
|
|---|
| 2682 | #endif
|
|---|
| 2683 |
|
|---|
| 2684 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 2685 | DRQ_GETCONSOLESCREENBUFFERINFO,
|
|---|
| 2686 | (ULONG)lpConsoleScreenBufferInfo,
|
|---|
| 2687 | 0,
|
|---|
| 2688 | 0,
|
|---|
| 2689 | 0);
|
|---|
| 2690 |
|
|---|
| 2691 | return fResult;
|
|---|
| 2692 | }
|
|---|
| 2693 |
|
|---|
| 2694 |
|
|---|
| 2695 | /*****************************************************************************
|
|---|
| 2696 | * Name : DWORD WIN32API GetConsoleTitle
|
|---|
| 2697 | * Purpose : Query the current console window title
|
|---|
| 2698 | * Parameters: LPTSTR lpConsoleTitle
|
|---|
| 2699 | * DWORD nSize
|
|---|
| 2700 | * Variables :
|
|---|
| 2701 | * Result : number of copied bytes
|
|---|
| 2702 | * Remark :
|
|---|
| 2703 | * Status : REWRITTEN UNTESTED
|
|---|
| 2704 | *
|
|---|
| 2705 | * Author : Patrick Haller [Thu, 1998/02/12 23:31]
|
|---|
| 2706 | *****************************************************************************/
|
|---|
| 2707 |
|
|---|
| 2708 | DWORD WIN32API GetConsoleTitleA(LPTSTR lpConsoleTitle,
|
|---|
| 2709 | DWORD nSize)
|
|---|
| 2710 | {
|
|---|
| 2711 | ULONG ulLength; /* length of text */
|
|---|
| 2712 |
|
|---|
| 2713 | #ifdef DEBUG_LOCAL2
|
|---|
| 2714 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleTitleA(%08x,%08x).\n",
|
|---|
| 2715 | lpConsoleTitle,
|
|---|
| 2716 | nSize);
|
|---|
| 2717 | #endif
|
|---|
| 2718 |
|
|---|
| 2719 | if (ConsoleGlobals.pszWindowTitle == NULL) /* is there a window title ? */
|
|---|
| 2720 | return 0; /* abort immediately */
|
|---|
| 2721 |
|
|---|
| 2722 | ulLength = strlen(ConsoleGlobals.pszWindowTitle); /* length of text */
|
|---|
| 2723 |
|
|---|
| 2724 | strncpy(lpConsoleTitle,
|
|---|
| 2725 | ConsoleGlobals.pszWindowTitle,
|
|---|
| 2726 | nSize);
|
|---|
| 2727 |
|
|---|
| 2728 | return (nSize < ulLength) ? nSize : ulLength;
|
|---|
| 2729 | }
|
|---|
| 2730 |
|
|---|
| 2731 |
|
|---|
| 2732 | /*****************************************************************************
|
|---|
| 2733 | * Name : DWORD WIN32API GetConsoleTitle
|
|---|
| 2734 | * Purpose : Query the current console window title
|
|---|
| 2735 | * Parameters: LPTSTR lpConsoleTitle
|
|---|
| 2736 | * DWORD nSize
|
|---|
| 2737 | * Variables :
|
|---|
| 2738 | * Result : number of copied bytes
|
|---|
| 2739 | * Remark :
|
|---|
| 2740 | * Status : REWRITTEN UNTESTED
|
|---|
| 2741 | *
|
|---|
| 2742 | * Author : Patrick Haller [Thu, 1998/02/12 23:31]
|
|---|
| 2743 | *****************************************************************************/
|
|---|
| 2744 |
|
|---|
| 2745 | DWORD WIN32API GetConsoleTitleW(LPTSTR lpConsoleTitle,
|
|---|
| 2746 | DWORD nSize)
|
|---|
| 2747 | {
|
|---|
| 2748 | ULONG ulLength; /* length of text */
|
|---|
| 2749 |
|
|---|
| 2750 | #ifdef DEBUG_LOCAL2
|
|---|
| 2751 | WriteLog("KERNEL32/CONSOLE: OS2GetConsoleTitleW(%08x,%08x).\n",
|
|---|
| 2752 | lpConsoleTitle,
|
|---|
| 2753 | nSize);
|
|---|
| 2754 | #endif
|
|---|
| 2755 |
|
|---|
| 2756 | if (ConsoleGlobals.pszWindowTitle == NULL) /* is there a window title ? */
|
|---|
| 2757 | return 0; /* abort immediately */
|
|---|
| 2758 |
|
|---|
| 2759 | ulLength = strlen(ConsoleGlobals.pszWindowTitle); /* length of text */
|
|---|
| 2760 |
|
|---|
| 2761 | strncpy(lpConsoleTitle,
|
|---|
| 2762 | ConsoleGlobals.pszWindowTitle,
|
|---|
| 2763 | nSize);
|
|---|
| 2764 |
|
|---|
| 2765 | /* @@@PH Ascii2Unicode */
|
|---|
| 2766 |
|
|---|
| 2767 | return (nSize < ulLength) ? nSize : ulLength;
|
|---|
| 2768 | }
|
|---|
| 2769 |
|
|---|
| 2770 |
|
|---|
| 2771 | /*****************************************************************************
|
|---|
| 2772 | * Name : COORD WIN32API GetLargestConsoleWindowSize
|
|---|
| 2773 | * Purpose : Determine maximum AVIO size
|
|---|
| 2774 | * Parameters:
|
|---|
| 2775 | * Variables :
|
|---|
| 2776 | * Result :
|
|---|
| 2777 | * Remark :
|
|---|
| 2778 | * Status :
|
|---|
| 2779 | *
|
|---|
| 2780 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2781 | *****************************************************************************/
|
|---|
| 2782 |
|
|---|
| 2783 | COORD WIN32API GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
|
|---|
| 2784 | {
|
|---|
| 2785 | DWORD dwResult;
|
|---|
| 2786 | COORD coordResult;
|
|---|
| 2787 |
|
|---|
| 2788 | #ifdef DEBUG_LOCAL2
|
|---|
| 2789 | WriteLog("KERNEL32/CONSOLE: OS2GetLargestConsoleWindowSize(%08x).\n",
|
|---|
| 2790 | hConsoleOutput);
|
|---|
| 2791 | #endif
|
|---|
| 2792 |
|
|---|
| 2793 | dwResult = HMDeviceRequest(hConsoleOutput,
|
|---|
| 2794 | DRQ_GETLARGESTCONSOLEWINDOWSIZE,
|
|---|
| 2795 | 0,
|
|---|
| 2796 | 0,
|
|---|
| 2797 | 0,
|
|---|
| 2798 | 0);
|
|---|
| 2799 |
|
|---|
| 2800 | ULONG2COORD(coordResult,dwResult)
|
|---|
| 2801 | return ( coordResult );
|
|---|
| 2802 | }
|
|---|
| 2803 |
|
|---|
| 2804 |
|
|---|
| 2805 | /*****************************************************************************
|
|---|
| 2806 | * Name :
|
|---|
| 2807 | * Purpose :
|
|---|
| 2808 | * Parameters:
|
|---|
| 2809 | * Variables :
|
|---|
| 2810 | * Result :
|
|---|
| 2811 | * Remark :
|
|---|
| 2812 | * Status :
|
|---|
| 2813 | *
|
|---|
| 2814 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2815 | *****************************************************************************/
|
|---|
| 2816 |
|
|---|
| 2817 | BOOL WIN32API GetNumberOfConsoleInputEvents(HANDLE hConsoleInput,
|
|---|
| 2818 | LPDWORD lpNumberOfEvents)
|
|---|
| 2819 | {
|
|---|
| 2820 | BOOL fResult;
|
|---|
| 2821 |
|
|---|
| 2822 | #ifdef DEBUG_LOCAL2
|
|---|
| 2823 | WriteLog("KERNEL32/CONSOLE: OS2GetNumberOfConsoleInputEvents(%08x,%08x).\n",
|
|---|
| 2824 | hConsoleInput,
|
|---|
| 2825 | lpNumberOfEvents);
|
|---|
| 2826 | #endif
|
|---|
| 2827 |
|
|---|
| 2828 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2829 | DRQ_GETNUMBEROFCONSOLEINPUTEVENTS,
|
|---|
| 2830 | (ULONG)lpNumberOfEvents,
|
|---|
| 2831 | 0,
|
|---|
| 2832 | 0,
|
|---|
| 2833 | 0);
|
|---|
| 2834 |
|
|---|
| 2835 | return fResult;
|
|---|
| 2836 | }
|
|---|
| 2837 |
|
|---|
| 2838 |
|
|---|
| 2839 | /*****************************************************************************
|
|---|
| 2840 | * Name :
|
|---|
| 2841 | * Purpose :
|
|---|
| 2842 | * Parameters:
|
|---|
| 2843 | * Variables :
|
|---|
| 2844 | * Result :
|
|---|
| 2845 | * Remark :
|
|---|
| 2846 | * Status :
|
|---|
| 2847 | *
|
|---|
| 2848 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2849 | *****************************************************************************/
|
|---|
| 2850 |
|
|---|
| 2851 | BOOL WIN32API GetNumberOfConsoleMouseButtons(LPDWORD lpcNumberOfMouseButtons)
|
|---|
| 2852 | {
|
|---|
| 2853 | LONG lMouseButtons;
|
|---|
| 2854 |
|
|---|
| 2855 | #ifdef DEBUG_LOCAL2
|
|---|
| 2856 | WriteLog("KERNEL32/CONSOLE: OS2GetNumberOfConsoleMouseButtons(%08x).\n",
|
|---|
| 2857 | lpcNumberOfMouseButtons);
|
|---|
| 2858 | #endif
|
|---|
| 2859 |
|
|---|
| 2860 | lMouseButtons = WinQuerySysValue(HWND_DESKTOP, /* query PM for that */
|
|---|
| 2861 | SV_CMOUSEBUTTONS);
|
|---|
| 2862 |
|
|---|
| 2863 | *lpcNumberOfMouseButtons = (DWORD)lMouseButtons;
|
|---|
| 2864 |
|
|---|
| 2865 | return TRUE;
|
|---|
| 2866 | }
|
|---|
| 2867 |
|
|---|
| 2868 |
|
|---|
| 2869 | /*****************************************************************************
|
|---|
| 2870 | * Name :
|
|---|
| 2871 | * Purpose :
|
|---|
| 2872 | * Parameters:
|
|---|
| 2873 | * Variables :
|
|---|
| 2874 | * Result :
|
|---|
| 2875 | * Remark :
|
|---|
| 2876 | * Status :
|
|---|
| 2877 | *
|
|---|
| 2878 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2879 | *****************************************************************************/
|
|---|
| 2880 |
|
|---|
| 2881 | BOOL WIN32API PeekConsoleInputW(HANDLE hConsoleInput,
|
|---|
| 2882 | PINPUT_RECORD pirBuffer,
|
|---|
| 2883 | DWORD cInRecords,
|
|---|
| 2884 | LPDWORD lpcRead)
|
|---|
| 2885 | {
|
|---|
| 2886 | BOOL fResult;
|
|---|
| 2887 |
|
|---|
| 2888 | #ifdef DEBUG_LOCAL2
|
|---|
| 2889 | WriteLog("KERNEL32/CONSOLE: OS2PeekConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
|---|
| 2890 | hConsoleInput,
|
|---|
| 2891 | pirBuffer,
|
|---|
| 2892 | cInRecords,
|
|---|
| 2893 | lpcRead);
|
|---|
| 2894 | #endif
|
|---|
| 2895 |
|
|---|
| 2896 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2897 | DRQ_PEEKCONSOLEINPUTW,
|
|---|
| 2898 | (ULONG)pirBuffer,
|
|---|
| 2899 | (ULONG)cInRecords,
|
|---|
| 2900 | (ULONG)lpcRead,
|
|---|
| 2901 | 0);
|
|---|
| 2902 |
|
|---|
| 2903 | return fResult;
|
|---|
| 2904 | }
|
|---|
| 2905 |
|
|---|
| 2906 |
|
|---|
| 2907 | /*****************************************************************************
|
|---|
| 2908 | * Name :
|
|---|
| 2909 | * Purpose :
|
|---|
| 2910 | * Parameters:
|
|---|
| 2911 | * Variables :
|
|---|
| 2912 | * Result :
|
|---|
| 2913 | * Remark :
|
|---|
| 2914 | * Status :
|
|---|
| 2915 | *
|
|---|
| 2916 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2917 | *****************************************************************************/
|
|---|
| 2918 |
|
|---|
| 2919 | BOOL WIN32API PeekConsoleInputA(HANDLE hConsoleInput,
|
|---|
| 2920 | PINPUT_RECORD pirBuffer,
|
|---|
| 2921 | DWORD cInRecords,
|
|---|
| 2922 | LPDWORD lpcRead)
|
|---|
| 2923 | {
|
|---|
| 2924 | BOOL fResult;
|
|---|
| 2925 |
|
|---|
| 2926 | #ifdef DEBUG_LOCAL2
|
|---|
| 2927 | WriteLog("KERNEL32/CONSOLE: OS2PeekConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
|---|
| 2928 | hConsoleInput,
|
|---|
| 2929 | pirBuffer,
|
|---|
| 2930 | cInRecords,
|
|---|
| 2931 | lpcRead);
|
|---|
| 2932 | #endif
|
|---|
| 2933 |
|
|---|
| 2934 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2935 | DRQ_PEEKCONSOLEINPUTA,
|
|---|
| 2936 | (ULONG)pirBuffer,
|
|---|
| 2937 | (ULONG)cInRecords,
|
|---|
| 2938 | (ULONG)lpcRead,
|
|---|
| 2939 | 0);
|
|---|
| 2940 |
|
|---|
| 2941 | return fResult;
|
|---|
| 2942 | }
|
|---|
| 2943 |
|
|---|
| 2944 |
|
|---|
| 2945 | /*****************************************************************************
|
|---|
| 2946 | * Name :
|
|---|
| 2947 | * Purpose :
|
|---|
| 2948 | * Parameters:
|
|---|
| 2949 | * Variables :
|
|---|
| 2950 | * Result :
|
|---|
| 2951 | * Remark :
|
|---|
| 2952 | * Status :
|
|---|
| 2953 | *
|
|---|
| 2954 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2955 | *****************************************************************************/
|
|---|
| 2956 |
|
|---|
| 2957 | BOOL WIN32API ReadConsoleA(HANDLE hConsoleInput,
|
|---|
| 2958 | LPVOID lpvBuffer,
|
|---|
| 2959 | DWORD cchToRead,
|
|---|
| 2960 | LPDWORD lpcchRead,
|
|---|
| 2961 | LPVOID lpvReserved)
|
|---|
| 2962 | {
|
|---|
| 2963 | BOOL fResult;
|
|---|
| 2964 |
|
|---|
| 2965 | #ifdef DEBUG_LOCAL2
|
|---|
| 2966 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 2967 | hConsoleInput,
|
|---|
| 2968 | lpvBuffer,
|
|---|
| 2969 | cchToRead,
|
|---|
| 2970 | lpcchRead,
|
|---|
| 2971 | lpvReserved);
|
|---|
| 2972 | #endif
|
|---|
| 2973 |
|
|---|
| 2974 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 2975 | DRQ_READCONSOLEA,
|
|---|
| 2976 | (ULONG)lpvBuffer,
|
|---|
| 2977 | (ULONG)cchToRead,
|
|---|
| 2978 | (ULONG)lpcchRead,
|
|---|
| 2979 | (ULONG)lpvReserved);
|
|---|
| 2980 |
|
|---|
| 2981 | return fResult;
|
|---|
| 2982 | }
|
|---|
| 2983 |
|
|---|
| 2984 |
|
|---|
| 2985 | /*****************************************************************************
|
|---|
| 2986 | * Name :
|
|---|
| 2987 | * Purpose :
|
|---|
| 2988 | * Parameters:
|
|---|
| 2989 | * Variables :
|
|---|
| 2990 | * Result :
|
|---|
| 2991 | * Remark :
|
|---|
| 2992 | * Status :
|
|---|
| 2993 | *
|
|---|
| 2994 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 2995 | *****************************************************************************/
|
|---|
| 2996 |
|
|---|
| 2997 | BOOL WIN32API ReadConsoleW(HANDLE hConsoleInput,
|
|---|
| 2998 | LPVOID lpvBuffer,
|
|---|
| 2999 | DWORD cchToRead,
|
|---|
| 3000 | LPDWORD lpcchRead,
|
|---|
| 3001 | LPVOID lpvReserved)
|
|---|
| 3002 | {
|
|---|
| 3003 | BOOL fResult;
|
|---|
| 3004 |
|
|---|
| 3005 | #ifdef DEBUG_LOCAL2
|
|---|
| 3006 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3007 | hConsoleInput,
|
|---|
| 3008 | lpvBuffer,
|
|---|
| 3009 | cchToRead,
|
|---|
| 3010 | lpcchRead,
|
|---|
| 3011 | lpvReserved);
|
|---|
| 3012 | #endif
|
|---|
| 3013 |
|
|---|
| 3014 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3015 | DRQ_READCONSOLEW,
|
|---|
| 3016 | (ULONG)lpvBuffer,
|
|---|
| 3017 | (ULONG)cchToRead,
|
|---|
| 3018 | (ULONG)lpcchRead,
|
|---|
| 3019 | (ULONG)lpvReserved);
|
|---|
| 3020 |
|
|---|
| 3021 | return fResult;
|
|---|
| 3022 | }
|
|---|
| 3023 |
|
|---|
| 3024 |
|
|---|
| 3025 | /*****************************************************************************
|
|---|
| 3026 | * Name :
|
|---|
| 3027 | * Purpose :
|
|---|
| 3028 | * Parameters:
|
|---|
| 3029 | * Variables :
|
|---|
| 3030 | * Result :
|
|---|
| 3031 | * Remark :
|
|---|
| 3032 | * Status :
|
|---|
| 3033 | *
|
|---|
| 3034 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3035 | *****************************************************************************/
|
|---|
| 3036 |
|
|---|
| 3037 | BOOL WIN32API ReadConsoleInputA(HANDLE hConsoleInput,
|
|---|
| 3038 | PINPUT_RECORD pirBuffer,
|
|---|
| 3039 | DWORD cInRecords,
|
|---|
| 3040 | LPDWORD lpcRead)
|
|---|
| 3041 | {
|
|---|
| 3042 | BOOL fResult;
|
|---|
| 3043 |
|
|---|
| 3044 | #ifdef DEBUG_LOCAL2
|
|---|
| 3045 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
|---|
| 3046 | hConsoleInput,
|
|---|
| 3047 | pirBuffer,
|
|---|
| 3048 | cInRecords,
|
|---|
| 3049 | lpcRead);
|
|---|
| 3050 | #endif
|
|---|
| 3051 |
|
|---|
| 3052 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3053 | DRQ_READCONSOLEINPUTA,
|
|---|
| 3054 | (ULONG)pirBuffer,
|
|---|
| 3055 | (ULONG)cInRecords,
|
|---|
| 3056 | (ULONG)lpcRead,
|
|---|
| 3057 | 0);
|
|---|
| 3058 |
|
|---|
| 3059 | return fResult;
|
|---|
| 3060 | }
|
|---|
| 3061 |
|
|---|
| 3062 |
|
|---|
| 3063 | /*****************************************************************************
|
|---|
| 3064 | * Name :
|
|---|
| 3065 | * Purpose :
|
|---|
| 3066 | * Parameters:
|
|---|
| 3067 | * Variables :
|
|---|
| 3068 | * Result :
|
|---|
| 3069 | * Remark :
|
|---|
| 3070 | * Status :
|
|---|
| 3071 | *
|
|---|
| 3072 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3073 | *****************************************************************************/
|
|---|
| 3074 |
|
|---|
| 3075 | BOOL WIN32API ReadConsoleInputW(HANDLE hConsoleInput,
|
|---|
| 3076 | PINPUT_RECORD pirBuffer,
|
|---|
| 3077 | DWORD cInRecords,
|
|---|
| 3078 | LPDWORD lpcRead)
|
|---|
| 3079 | {
|
|---|
| 3080 | BOOL fResult;
|
|---|
| 3081 |
|
|---|
| 3082 | #ifdef DEBUG_LOCAL2
|
|---|
| 3083 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
|---|
| 3084 | hConsoleInput,
|
|---|
| 3085 | pirBuffer,
|
|---|
| 3086 | cInRecords,
|
|---|
| 3087 | lpcRead);
|
|---|
| 3088 | #endif
|
|---|
| 3089 |
|
|---|
| 3090 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3091 | DRQ_READCONSOLEINPUTW,
|
|---|
| 3092 | (ULONG)pirBuffer,
|
|---|
| 3093 | (ULONG)cInRecords,
|
|---|
| 3094 | (ULONG)lpcRead,
|
|---|
| 3095 | 0);
|
|---|
| 3096 |
|
|---|
| 3097 | return fResult;
|
|---|
| 3098 | }
|
|---|
| 3099 |
|
|---|
| 3100 |
|
|---|
| 3101 | /*****************************************************************************
|
|---|
| 3102 | * Name :
|
|---|
| 3103 | * Purpose :
|
|---|
| 3104 | * Parameters:
|
|---|
| 3105 | * Variables :
|
|---|
| 3106 | * Result :
|
|---|
| 3107 | * Remark :
|
|---|
| 3108 | * Status :
|
|---|
| 3109 | *
|
|---|
| 3110 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3111 | *****************************************************************************/
|
|---|
| 3112 |
|
|---|
| 3113 | BOOL WIN32API ReadConsoleOutputA(HANDLE hConsoleOutput,
|
|---|
| 3114 | PCHAR_INFO pchiDestBuffer,
|
|---|
| 3115 | COORD coordDestBufferSize,
|
|---|
| 3116 | COORD coordDestBufferCoord,
|
|---|
| 3117 | PSMALL_RECT psrctSourceRect)
|
|---|
| 3118 | {
|
|---|
| 3119 | BOOL fResult;
|
|---|
| 3120 |
|
|---|
| 3121 | #ifdef DEBUG_LOCAL2
|
|---|
| 3122 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3123 | hConsoleOutput,
|
|---|
| 3124 | pchiDestBuffer,
|
|---|
| 3125 | coordDestBufferSize,
|
|---|
| 3126 | coordDestBufferCoord,
|
|---|
| 3127 | psrctSourceRect);
|
|---|
| 3128 | #endif
|
|---|
| 3129 |
|
|---|
| 3130 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3131 | DRQ_READCONSOLEOUTPUTA,
|
|---|
| 3132 | (ULONG)pchiDestBuffer,
|
|---|
| 3133 | COORD2ULONG(coordDestBufferSize),
|
|---|
| 3134 | COORD2ULONG(coordDestBufferCoord),
|
|---|
| 3135 | (ULONG)psrctSourceRect);
|
|---|
| 3136 |
|
|---|
| 3137 | return fResult;
|
|---|
| 3138 | }
|
|---|
| 3139 |
|
|---|
| 3140 |
|
|---|
| 3141 | /*****************************************************************************
|
|---|
| 3142 | * Name :
|
|---|
| 3143 | * Purpose :
|
|---|
| 3144 | * Parameters:
|
|---|
| 3145 | * Variables :
|
|---|
| 3146 | * Result :
|
|---|
| 3147 | * Remark :
|
|---|
| 3148 | * Status :
|
|---|
| 3149 | *
|
|---|
| 3150 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3151 | *****************************************************************************/
|
|---|
| 3152 |
|
|---|
| 3153 | BOOL WIN32API ReadConsoleOutputW(HANDLE hConsoleOutput,
|
|---|
| 3154 | PCHAR_INFO pchiDestBuffer,
|
|---|
| 3155 | COORD coordDestBufferSize,
|
|---|
| 3156 | COORD coordDestBufferCoord,
|
|---|
| 3157 | PSMALL_RECT psrctSourceRect)
|
|---|
| 3158 | {
|
|---|
| 3159 | BOOL fResult;
|
|---|
| 3160 |
|
|---|
| 3161 | #ifdef DEBUG_LOCAL2
|
|---|
| 3162 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3163 | hConsoleOutput,
|
|---|
| 3164 | pchiDestBuffer,
|
|---|
| 3165 | coordDestBufferSize,
|
|---|
| 3166 | coordDestBufferCoord,
|
|---|
| 3167 | psrctSourceRect);
|
|---|
| 3168 | #endif
|
|---|
| 3169 |
|
|---|
| 3170 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3171 | DRQ_READCONSOLEOUTPUTW,
|
|---|
| 3172 | (ULONG)pchiDestBuffer,
|
|---|
| 3173 | COORD2ULONG(coordDestBufferSize),
|
|---|
| 3174 | COORD2ULONG(coordDestBufferCoord),
|
|---|
| 3175 | (ULONG)psrctSourceRect);
|
|---|
| 3176 |
|
|---|
| 3177 | return fResult;
|
|---|
| 3178 | }
|
|---|
| 3179 |
|
|---|
| 3180 |
|
|---|
| 3181 | /*****************************************************************************
|
|---|
| 3182 | * Name :
|
|---|
| 3183 | * Purpose :
|
|---|
| 3184 | * Parameters:
|
|---|
| 3185 | * Variables :
|
|---|
| 3186 | * Result :
|
|---|
| 3187 | * Remark :
|
|---|
| 3188 | * Status :
|
|---|
| 3189 | *
|
|---|
| 3190 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3191 | *****************************************************************************/
|
|---|
| 3192 |
|
|---|
| 3193 | BOOL WIN32API ReadConsoleOutputAttribute(HANDLE hConsoleOutput,
|
|---|
| 3194 | LPWORD lpwAttribute,
|
|---|
| 3195 | DWORD cReadCells,
|
|---|
| 3196 | COORD coordReadCoord,
|
|---|
| 3197 | LPDWORD lpcNumberRead)
|
|---|
| 3198 | {
|
|---|
| 3199 | BOOL fResult;
|
|---|
| 3200 |
|
|---|
| 3201 | #ifdef DEBUG_LOCAL2
|
|---|
| 3202 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputAttribute(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3203 | hConsoleOutput,
|
|---|
| 3204 | lpwAttribute,
|
|---|
| 3205 | cReadCells,
|
|---|
| 3206 | coordReadCoord,
|
|---|
| 3207 | lpcNumberRead);
|
|---|
| 3208 | #endif
|
|---|
| 3209 |
|
|---|
| 3210 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3211 | DRQ_READCONSOLEOUTPUTATTRIBUTE,
|
|---|
| 3212 | (ULONG)lpwAttribute,
|
|---|
| 3213 | (ULONG)cReadCells,
|
|---|
| 3214 | COORD2ULONG(coordReadCoord),
|
|---|
| 3215 | (ULONG)lpcNumberRead);
|
|---|
| 3216 |
|
|---|
| 3217 | return fResult;
|
|---|
| 3218 | }
|
|---|
| 3219 |
|
|---|
| 3220 |
|
|---|
| 3221 | /*****************************************************************************
|
|---|
| 3222 | * Name :
|
|---|
| 3223 | * Purpose :
|
|---|
| 3224 | * Parameters:
|
|---|
| 3225 | * Variables :
|
|---|
| 3226 | * Result :
|
|---|
| 3227 | * Remark :
|
|---|
| 3228 | * Status :
|
|---|
| 3229 | *
|
|---|
| 3230 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3231 | *****************************************************************************/
|
|---|
| 3232 |
|
|---|
| 3233 | BOOL WIN32API ReadConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
|---|
| 3234 | LPTSTR lpReadBuffer,
|
|---|
| 3235 | DWORD cchRead,
|
|---|
| 3236 | COORD coordReadCoord,
|
|---|
| 3237 | LPDWORD lpcNumberRead)
|
|---|
| 3238 | {
|
|---|
| 3239 | BOOL fResult;
|
|---|
| 3240 |
|
|---|
| 3241 | #ifdef DEBUG_LOCAL2
|
|---|
| 3242 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputCharacterA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3243 | hConsoleOutput,
|
|---|
| 3244 | lpReadBuffer,
|
|---|
| 3245 | cchRead,
|
|---|
| 3246 | coordReadCoord,
|
|---|
| 3247 | lpcNumberRead);
|
|---|
| 3248 | #endif
|
|---|
| 3249 |
|
|---|
| 3250 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3251 | DRQ_READCONSOLEOUTPUTCHARACTERA,
|
|---|
| 3252 | (ULONG)lpReadBuffer,
|
|---|
| 3253 | (ULONG)cchRead,
|
|---|
| 3254 | COORD2ULONG(coordReadCoord),
|
|---|
| 3255 | (ULONG)lpcNumberRead);
|
|---|
| 3256 |
|
|---|
| 3257 | return fResult;
|
|---|
| 3258 | }
|
|---|
| 3259 |
|
|---|
| 3260 |
|
|---|
| 3261 | /*****************************************************************************
|
|---|
| 3262 | * Name :
|
|---|
| 3263 | * Purpose :
|
|---|
| 3264 | * Parameters:
|
|---|
| 3265 | * Variables :
|
|---|
| 3266 | * Result :
|
|---|
| 3267 | * Remark :
|
|---|
| 3268 | * Status :
|
|---|
| 3269 | *
|
|---|
| 3270 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3271 | *****************************************************************************/
|
|---|
| 3272 |
|
|---|
| 3273 | BOOL WIN32API ReadConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
|---|
| 3274 | LPTSTR lpReadBuffer,
|
|---|
| 3275 | DWORD cchRead,
|
|---|
| 3276 | COORD coordReadCoord,
|
|---|
| 3277 | LPDWORD lpcNumberRead)
|
|---|
| 3278 | {
|
|---|
| 3279 | BOOL fResult;
|
|---|
| 3280 |
|
|---|
| 3281 | #ifdef DEBUG_LOCAL2
|
|---|
| 3282 | WriteLog("KERNEL32/CONSOLE: OS2ReadConsoleOutputCharacterW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3283 | hConsoleOutput,
|
|---|
| 3284 | lpReadBuffer,
|
|---|
| 3285 | cchRead,
|
|---|
| 3286 | coordReadCoord,
|
|---|
| 3287 | lpcNumberRead);
|
|---|
| 3288 | #endif
|
|---|
| 3289 |
|
|---|
| 3290 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3291 | DRQ_READCONSOLEOUTPUTCHARACTERW,
|
|---|
| 3292 | (ULONG)lpReadBuffer,
|
|---|
| 3293 | (ULONG)cchRead,
|
|---|
| 3294 | COORD2ULONG(coordReadCoord),
|
|---|
| 3295 | (ULONG)lpcNumberRead);
|
|---|
| 3296 |
|
|---|
| 3297 | return fResult;
|
|---|
| 3298 | }
|
|---|
| 3299 |
|
|---|
| 3300 |
|
|---|
| 3301 | /*****************************************************************************
|
|---|
| 3302 | * Name :
|
|---|
| 3303 | * Purpose :
|
|---|
| 3304 | * Parameters:
|
|---|
| 3305 | * Variables :
|
|---|
| 3306 | * Result :
|
|---|
| 3307 | * Remark :
|
|---|
| 3308 | * Status :
|
|---|
| 3309 | *
|
|---|
| 3310 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3311 | *****************************************************************************/
|
|---|
| 3312 |
|
|---|
| 3313 | BOOL WIN32API ScrollConsoleScreenBufferA(HANDLE hConsoleOutput,
|
|---|
| 3314 | PSMALL_RECT psrctSourceRect,
|
|---|
| 3315 | PSMALL_RECT psrctClipRect,
|
|---|
| 3316 | COORD coordDestOrigin,
|
|---|
| 3317 | PCHAR_INFO pchiFill)
|
|---|
| 3318 | {
|
|---|
| 3319 | BOOL fResult;
|
|---|
| 3320 |
|
|---|
| 3321 | #ifdef DEBUG_LOCAL2
|
|---|
| 3322 | WriteLog("KERNEL32/CONSOLE: OS2ScrollConsoleScreenBufferA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3323 | hConsoleOutput,
|
|---|
| 3324 | psrctSourceRect,
|
|---|
| 3325 | psrctClipRect,
|
|---|
| 3326 | coordDestOrigin,
|
|---|
| 3327 | pchiFill);
|
|---|
| 3328 | #endif
|
|---|
| 3329 |
|
|---|
| 3330 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3331 | DRQ_SCROLLCONSOLESCREENBUFFERA,
|
|---|
| 3332 | (ULONG)psrctSourceRect,
|
|---|
| 3333 | (ULONG)psrctClipRect,
|
|---|
| 3334 | COORD2ULONG(coordDestOrigin),
|
|---|
| 3335 | (ULONG)pchiFill);
|
|---|
| 3336 |
|
|---|
| 3337 | return fResult;
|
|---|
| 3338 | }
|
|---|
| 3339 |
|
|---|
| 3340 |
|
|---|
| 3341 | /*****************************************************************************
|
|---|
| 3342 | * Name :
|
|---|
| 3343 | * Purpose :
|
|---|
| 3344 | * Parameters:
|
|---|
| 3345 | * Variables :
|
|---|
| 3346 | * Result :
|
|---|
| 3347 | * Remark :
|
|---|
| 3348 | * Status :
|
|---|
| 3349 | *
|
|---|
| 3350 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3351 | *****************************************************************************/
|
|---|
| 3352 |
|
|---|
| 3353 | BOOL WIN32API ScrollConsoleScreenBufferW(HANDLE hConsoleOutput,
|
|---|
| 3354 | PSMALL_RECT psrctSourceRect,
|
|---|
| 3355 | PSMALL_RECT psrctClipRect,
|
|---|
| 3356 | COORD coordDestOrigin,
|
|---|
| 3357 | PCHAR_INFO pchiFill)
|
|---|
| 3358 | {
|
|---|
| 3359 | BOOL fResult;
|
|---|
| 3360 |
|
|---|
| 3361 | #ifdef DEBUG_LOCAL2
|
|---|
| 3362 | WriteLog("KERNEL32/CONSOLE: OS2ScrollConsoleScreenBufferW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3363 | hConsoleOutput,
|
|---|
| 3364 | psrctSourceRect,
|
|---|
| 3365 | psrctClipRect,
|
|---|
| 3366 | coordDestOrigin,
|
|---|
| 3367 | pchiFill);
|
|---|
| 3368 | #endif
|
|---|
| 3369 |
|
|---|
| 3370 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3371 | DRQ_SCROLLCONSOLESCREENBUFFERW,
|
|---|
| 3372 | (ULONG)psrctSourceRect,
|
|---|
| 3373 | (ULONG)psrctClipRect,
|
|---|
| 3374 | COORD2ULONG(coordDestOrigin),
|
|---|
| 3375 | (ULONG)pchiFill);
|
|---|
| 3376 |
|
|---|
| 3377 | return fResult;
|
|---|
| 3378 | }
|
|---|
| 3379 |
|
|---|
| 3380 | /*****************************************************************************
|
|---|
| 3381 | * Name :
|
|---|
| 3382 | * Purpose :
|
|---|
| 3383 | * Parameters:
|
|---|
| 3384 | * Variables :
|
|---|
| 3385 | * Result :
|
|---|
| 3386 | * Remark :
|
|---|
| 3387 | * Status :
|
|---|
| 3388 | *
|
|---|
| 3389 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3390 | *****************************************************************************/
|
|---|
| 3391 |
|
|---|
| 3392 | BOOL WIN32API SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
|
|---|
| 3393 | {
|
|---|
| 3394 | BOOL fResult;
|
|---|
| 3395 |
|
|---|
| 3396 | #ifdef DEBUG_LOCAL2
|
|---|
| 3397 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleActiveScreenBuffer(%08x).\n",
|
|---|
| 3398 | hConsoleOutput);
|
|---|
| 3399 | #endif
|
|---|
| 3400 |
|
|---|
| 3401 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3402 | DRQ_SETCONSOLEACTIVESCREENBUFFER,
|
|---|
| 3403 | 0,
|
|---|
| 3404 | 0,
|
|---|
| 3405 | 0,
|
|---|
| 3406 | 0);
|
|---|
| 3407 |
|
|---|
| 3408 | return fResult;
|
|---|
| 3409 | }
|
|---|
| 3410 |
|
|---|
| 3411 |
|
|---|
| 3412 | /*****************************************************************************
|
|---|
| 3413 | * Name :
|
|---|
| 3414 | * Purpose :
|
|---|
| 3415 | * Parameters:
|
|---|
| 3416 | * Variables :
|
|---|
| 3417 | * Result :
|
|---|
| 3418 | * Remark :
|
|---|
| 3419 | * Status :
|
|---|
| 3420 | *
|
|---|
| 3421 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3422 | *****************************************************************************/
|
|---|
| 3423 |
|
|---|
| 3424 | BOOL WIN32API SetConsoleCP(UINT IDCodePage)
|
|---|
| 3425 | {
|
|---|
| 3426 | #ifdef DEBUG_LOCAL2
|
|---|
| 3427 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCP(%08x) not implemented.\n",
|
|---|
| 3428 | IDCodePage);
|
|---|
| 3429 | #endif
|
|---|
| 3430 |
|
|---|
| 3431 | return TRUE;
|
|---|
| 3432 | }
|
|---|
| 3433 |
|
|---|
| 3434 |
|
|---|
| 3435 | /*****************************************************************************
|
|---|
| 3436 | * Name :
|
|---|
| 3437 | * Purpose :
|
|---|
| 3438 | * Parameters:
|
|---|
| 3439 | * Variables :
|
|---|
| 3440 | * Result :
|
|---|
| 3441 | * Remark :
|
|---|
| 3442 | * Status :
|
|---|
| 3443 | *
|
|---|
| 3444 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3445 | *****************************************************************************/
|
|---|
| 3446 |
|
|---|
| 3447 | BOOL WIN32API SetConsoleCtrlHandler(PHANDLER_ROUTINE pHandlerRoutine,
|
|---|
| 3448 | BOOL fAdd)
|
|---|
| 3449 | {
|
|---|
| 3450 | #ifdef DEBUG_LOCAL2
|
|---|
| 3451 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCtrlHandler(%08x,%08x) not implemented.\n",
|
|---|
| 3452 | pHandlerRoutine,
|
|---|
| 3453 | fAdd);
|
|---|
| 3454 | #endif
|
|---|
| 3455 |
|
|---|
| 3456 | return TRUE;
|
|---|
| 3457 | }
|
|---|
| 3458 |
|
|---|
| 3459 |
|
|---|
| 3460 | /*****************************************************************************
|
|---|
| 3461 | * Name :
|
|---|
| 3462 | * Purpose :
|
|---|
| 3463 | * Parameters:
|
|---|
| 3464 | * Variables :
|
|---|
| 3465 | * Result :
|
|---|
| 3466 | * Remark :
|
|---|
| 3467 | * Status :
|
|---|
| 3468 | *
|
|---|
| 3469 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3470 | *****************************************************************************/
|
|---|
| 3471 |
|
|---|
| 3472 | BOOL WIN32API SetConsoleCursorInfo(HANDLE hConsoleOutput,
|
|---|
| 3473 | PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
|
|---|
| 3474 | {
|
|---|
| 3475 | BOOL fResult;
|
|---|
| 3476 |
|
|---|
| 3477 | #ifdef DEBUG_LOCAL2
|
|---|
| 3478 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCursorInfo(%08x,%08x).\n",
|
|---|
| 3479 | hConsoleOutput,
|
|---|
| 3480 | lpConsoleCursorInfo);
|
|---|
| 3481 | #endif
|
|---|
| 3482 |
|
|---|
| 3483 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3484 | DRQ_SETCONSOLECURSORINFO,
|
|---|
| 3485 | (ULONG)lpConsoleCursorInfo,
|
|---|
| 3486 | 0,
|
|---|
| 3487 | 0,
|
|---|
| 3488 | 0);
|
|---|
| 3489 |
|
|---|
| 3490 | return fResult;
|
|---|
| 3491 | }
|
|---|
| 3492 |
|
|---|
| 3493 |
|
|---|
| 3494 | /*****************************************************************************
|
|---|
| 3495 | * Name :
|
|---|
| 3496 | * Purpose :
|
|---|
| 3497 | * Parameters:
|
|---|
| 3498 | * Variables :
|
|---|
| 3499 | * Result :
|
|---|
| 3500 | * Remark :
|
|---|
| 3501 | * Status :
|
|---|
| 3502 | *
|
|---|
| 3503 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3504 |
|
|---|
| 3505 | *****************************************************************************/
|
|---|
| 3506 |
|
|---|
| 3507 | BOOL WIN32API SetConsoleCursorPosition(HANDLE hConsoleOutput,
|
|---|
| 3508 | COORD coordCursor)
|
|---|
| 3509 | {
|
|---|
| 3510 | BOOL fResult;
|
|---|
| 3511 |
|
|---|
| 3512 | #ifdef DEBUG_LOCAL2
|
|---|
| 3513 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleCursorPosition(%08x,%08x).\n",
|
|---|
| 3514 | hConsoleOutput,
|
|---|
| 3515 | coordCursor);
|
|---|
| 3516 | #endif
|
|---|
| 3517 |
|
|---|
| 3518 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3519 | DRQ_SETCONSOLECURSORPOSITION,
|
|---|
| 3520 | COORD2ULONG(coordCursor),
|
|---|
| 3521 | 0,
|
|---|
| 3522 | 0,
|
|---|
| 3523 | 0);
|
|---|
| 3524 |
|
|---|
| 3525 | return fResult;
|
|---|
| 3526 | }
|
|---|
| 3527 |
|
|---|
| 3528 |
|
|---|
| 3529 | /*****************************************************************************
|
|---|
| 3530 | * Name :
|
|---|
| 3531 | * Purpose :
|
|---|
| 3532 | * Parameters:
|
|---|
| 3533 | * Variables :
|
|---|
| 3534 | * Result :
|
|---|
| 3535 | * Remark :
|
|---|
| 3536 | * Status :
|
|---|
| 3537 | *
|
|---|
| 3538 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3539 | *****************************************************************************/
|
|---|
| 3540 |
|
|---|
| 3541 | BOOL WIN32API SetConsoleMode(HANDLE hConsole,
|
|---|
| 3542 | DWORD fdwMode)
|
|---|
| 3543 | {
|
|---|
| 3544 | BOOL fResult;
|
|---|
| 3545 |
|
|---|
| 3546 | #ifdef DEBUG_LOCAL2
|
|---|
| 3547 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleMode(%08x,%08x).\n",
|
|---|
| 3548 | hConsole,
|
|---|
| 3549 | fdwMode);
|
|---|
| 3550 | #endif
|
|---|
| 3551 |
|
|---|
| 3552 | fResult = (BOOL)HMDeviceRequest(hConsole,
|
|---|
| 3553 | DRQ_SETCONSOLEMODE,
|
|---|
| 3554 | (ULONG)fdwMode,
|
|---|
| 3555 | 0,
|
|---|
| 3556 | 0,
|
|---|
| 3557 | 0);
|
|---|
| 3558 |
|
|---|
| 3559 | return fResult;
|
|---|
| 3560 | }
|
|---|
| 3561 |
|
|---|
| 3562 |
|
|---|
| 3563 | /*****************************************************************************
|
|---|
| 3564 | * Name :
|
|---|
| 3565 | * Purpose :
|
|---|
| 3566 | * Parameters:
|
|---|
| 3567 | * Variables :
|
|---|
| 3568 | * Result :
|
|---|
| 3569 | * Remark :
|
|---|
| 3570 | * Status :
|
|---|
| 3571 | *
|
|---|
| 3572 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3573 | *****************************************************************************/
|
|---|
| 3574 |
|
|---|
| 3575 | BOOL WIN32API SetConsoleOutputCP(UINT IDCodePage)
|
|---|
| 3576 | {
|
|---|
| 3577 | #ifdef DEBUG_LOCAL2
|
|---|
| 3578 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleOutputCP(%08x) not implemented.\n",
|
|---|
| 3579 | IDCodePage);
|
|---|
| 3580 | #endif
|
|---|
| 3581 |
|
|---|
| 3582 | return TRUE;
|
|---|
| 3583 | }
|
|---|
| 3584 |
|
|---|
| 3585 |
|
|---|
| 3586 | /*****************************************************************************
|
|---|
| 3587 | * Name :
|
|---|
| 3588 | * Purpose :
|
|---|
| 3589 | * Parameters:
|
|---|
| 3590 | * Variables :
|
|---|
| 3591 | * Result :
|
|---|
| 3592 | * Remark :
|
|---|
| 3593 | * Status :
|
|---|
| 3594 | *
|
|---|
| 3595 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3596 | *****************************************************************************/
|
|---|
| 3597 |
|
|---|
| 3598 | BOOL WIN32API SetConsoleScreenBufferSize(HANDLE hConsoleOutput,
|
|---|
| 3599 | COORD coordSize)
|
|---|
| 3600 | {
|
|---|
| 3601 | BOOL fResult;
|
|---|
| 3602 |
|
|---|
| 3603 | #ifdef DEBUG_LOCAL2
|
|---|
| 3604 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleScreenBufferSize(%08x,%08x).\n",
|
|---|
| 3605 | hConsoleOutput,
|
|---|
| 3606 | coordSize);
|
|---|
| 3607 | #endif
|
|---|
| 3608 |
|
|---|
| 3609 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3610 | DRQ_SETCONSOLESCREENBUFFERSIZE,
|
|---|
| 3611 | COORD2ULONG(coordSize),
|
|---|
| 3612 | 0,
|
|---|
| 3613 | 0,
|
|---|
| 3614 | 0);
|
|---|
| 3615 |
|
|---|
| 3616 | return fResult;
|
|---|
| 3617 | }
|
|---|
| 3618 |
|
|---|
| 3619 |
|
|---|
| 3620 | /*****************************************************************************
|
|---|
| 3621 | * Name :
|
|---|
| 3622 | * Purpose :
|
|---|
| 3623 | * Parameters:
|
|---|
| 3624 | * Variables :
|
|---|
| 3625 | * Result :
|
|---|
| 3626 | * Remark :
|
|---|
| 3627 | * Status :
|
|---|
| 3628 | *
|
|---|
| 3629 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3630 | *****************************************************************************/
|
|---|
| 3631 |
|
|---|
| 3632 | BOOL WIN32API SetConsoleTextAttribute(HANDLE hConsoleOutput,
|
|---|
| 3633 | WORD wAttr)
|
|---|
| 3634 | {
|
|---|
| 3635 | BOOL fResult;
|
|---|
| 3636 |
|
|---|
| 3637 | #ifdef DEBUG_LOCAL2
|
|---|
| 3638 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleTextAttribute(%08x,%04x).\n",
|
|---|
| 3639 | hConsoleOutput,
|
|---|
| 3640 | wAttr);
|
|---|
| 3641 | #endif
|
|---|
| 3642 |
|
|---|
| 3643 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3644 | DRQ_SETCONSOLETEXTATTRIBUTE,
|
|---|
| 3645 | (ULONG)wAttr,
|
|---|
| 3646 | 0,
|
|---|
| 3647 | 0,
|
|---|
| 3648 | 0);
|
|---|
| 3649 |
|
|---|
| 3650 | return fResult;
|
|---|
| 3651 | }
|
|---|
| 3652 |
|
|---|
| 3653 |
|
|---|
| 3654 | /*****************************************************************************
|
|---|
| 3655 | * Name : BOOL WIN32API SetConsoleTitleA
|
|---|
| 3656 | * Purpose : Set new title text for the console window
|
|---|
| 3657 | * Parameters: LPTSTR lpszTitle
|
|---|
| 3658 | * Variables :
|
|---|
| 3659 | * Result :
|
|---|
| 3660 | * Remark :
|
|---|
| 3661 | * Status : REWRITTEN UNTESTED
|
|---|
| 3662 | *
|
|---|
| 3663 | * Author : Patrick Haller [Tue, 1998/02/12 23:28]
|
|---|
| 3664 | *****************************************************************************/
|
|---|
| 3665 |
|
|---|
| 3666 | BOOL WIN32API SetConsoleTitleA(LPTSTR lpszTitle)
|
|---|
| 3667 | {
|
|---|
| 3668 | #ifdef DEBUG_LOCAL2
|
|---|
| 3669 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleTitleA(%s).\n",
|
|---|
| 3670 | lpszTitle);
|
|---|
| 3671 | #endif
|
|---|
| 3672 |
|
|---|
| 3673 | if (ConsoleGlobals.pszWindowTitle != NULL) /* previously set name */
|
|---|
| 3674 | free (ConsoleGlobals.pszWindowTitle); /* then free it */
|
|---|
| 3675 |
|
|---|
| 3676 | ConsoleGlobals.pszWindowTitle = strdup(lpszTitle); /* copy the new name */
|
|---|
| 3677 |
|
|---|
| 3678 | WinSetWindowText(ConsoleGlobals.hwndFrame, /* set new title text */
|
|---|
| 3679 | ConsoleGlobals.pszWindowTitle);
|
|---|
| 3680 |
|
|---|
| 3681 | return TRUE;
|
|---|
| 3682 | }
|
|---|
| 3683 |
|
|---|
| 3684 |
|
|---|
| 3685 | /*****************************************************************************
|
|---|
| 3686 | * Name : BOOL WIN32API SetConsoleTitleW
|
|---|
| 3687 | * Purpose : Set new title text for the console window
|
|---|
| 3688 | * Parameters: LPTSTR lpszTitle
|
|---|
| 3689 | * Variables :
|
|---|
| 3690 | * Result :
|
|---|
| 3691 | * Remark :
|
|---|
| 3692 | * Status : REWRITTEN UNTESTED
|
|---|
| 3693 | *
|
|---|
| 3694 | * Author : Patrick Haller [Tue, 1998/02/12 23:28]
|
|---|
| 3695 | *****************************************************************************/
|
|---|
| 3696 |
|
|---|
| 3697 | BOOL WIN32API SetConsoleTitleW(LPTSTR lpszTitle)
|
|---|
| 3698 | {
|
|---|
| 3699 | #ifdef DEBUG_LOCAL2
|
|---|
| 3700 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleTitleW(%s) not implemented.\n",
|
|---|
| 3701 | lpszTitle);
|
|---|
| 3702 | #endif
|
|---|
| 3703 |
|
|---|
| 3704 | /* @@@PH Unicode2Ascii */
|
|---|
| 3705 |
|
|---|
| 3706 | if (ConsoleGlobals.pszWindowTitle != NULL) /* previously set name */
|
|---|
| 3707 | free (ConsoleGlobals.pszWindowTitle); /* then free it */
|
|---|
| 3708 |
|
|---|
| 3709 | ConsoleGlobals.pszWindowTitle = strdup(lpszTitle); /* copy the new name */
|
|---|
| 3710 |
|
|---|
| 3711 | WinSetWindowText(ConsoleGlobals.hwndFrame, /* set new title text */
|
|---|
| 3712 | ConsoleGlobals.pszWindowTitle);
|
|---|
| 3713 |
|
|---|
| 3714 | return TRUE;
|
|---|
| 3715 | }
|
|---|
| 3716 |
|
|---|
| 3717 |
|
|---|
| 3718 | /*****************************************************************************
|
|---|
| 3719 | * Name :
|
|---|
| 3720 | * Purpose :
|
|---|
| 3721 | * Parameters:
|
|---|
| 3722 | * Variables :
|
|---|
| 3723 | * Result :
|
|---|
| 3724 | * Remark :
|
|---|
| 3725 | * Status :
|
|---|
| 3726 | *
|
|---|
| 3727 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3728 | *****************************************************************************/
|
|---|
| 3729 |
|
|---|
| 3730 | BOOL WIN32API SetConsoleWindowInfo(HANDLE hConsoleOutput,
|
|---|
| 3731 | BOOL fAbsolute,
|
|---|
| 3732 | PSMALL_RECT psrctWindowRect)
|
|---|
| 3733 | {
|
|---|
| 3734 | BOOL fResult;
|
|---|
| 3735 |
|
|---|
| 3736 | #ifdef DEBUG_LOCAL2
|
|---|
| 3737 | WriteLog("KERNEL32/CONSOLE: OS2SetConsoleWindowInfo(%08x,%08x,%08x).\n",
|
|---|
| 3738 | hConsoleOutput,
|
|---|
| 3739 | fAbsolute,
|
|---|
| 3740 | psrctWindowRect);
|
|---|
| 3741 | #endif
|
|---|
| 3742 |
|
|---|
| 3743 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3744 | DRQ_SETCONSOLEWINDOWINFO,
|
|---|
| 3745 | (ULONG)fAbsolute,
|
|---|
| 3746 | (ULONG)psrctWindowRect,
|
|---|
| 3747 | 0,
|
|---|
| 3748 | 0);
|
|---|
| 3749 |
|
|---|
| 3750 | return fResult;
|
|---|
| 3751 | }
|
|---|
| 3752 |
|
|---|
| 3753 |
|
|---|
| 3754 | /*****************************************************************************
|
|---|
| 3755 | * Name :
|
|---|
| 3756 | * Purpose :
|
|---|
| 3757 | * Parameters:
|
|---|
| 3758 | * Variables :
|
|---|
| 3759 | * Result :
|
|---|
| 3760 | * Remark :
|
|---|
| 3761 | * Status :
|
|---|
| 3762 | *
|
|---|
| 3763 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3764 | *****************************************************************************/
|
|---|
| 3765 |
|
|---|
| 3766 | BOOL WIN32API WriteConsoleA(HANDLE hConsoleOutput,
|
|---|
| 3767 | CONST VOID* lpvBuffer,
|
|---|
| 3768 | DWORD cchToWrite,
|
|---|
| 3769 | LPDWORD lpcchWritten,
|
|---|
| 3770 | LPVOID lpvReserved)
|
|---|
| 3771 | {
|
|---|
| 3772 | BOOL fResult;
|
|---|
| 3773 |
|
|---|
| 3774 | #ifdef DEBUG_LOCAL2
|
|---|
| 3775 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3776 | hConsoleOutput,
|
|---|
| 3777 | lpvBuffer,
|
|---|
| 3778 | cchToWrite,
|
|---|
| 3779 | lpcchWritten,
|
|---|
| 3780 | lpvReserved);
|
|---|
| 3781 | #endif
|
|---|
| 3782 |
|
|---|
| 3783 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3784 | DRQ_WRITECONSOLEA,
|
|---|
| 3785 | (ULONG)lpvBuffer,
|
|---|
| 3786 | (ULONG)cchToWrite,
|
|---|
| 3787 | (ULONG)lpcchWritten,
|
|---|
| 3788 | (ULONG)lpvReserved);
|
|---|
| 3789 |
|
|---|
| 3790 | return fResult;
|
|---|
| 3791 | }
|
|---|
| 3792 |
|
|---|
| 3793 |
|
|---|
| 3794 | /*****************************************************************************
|
|---|
| 3795 | * Name :
|
|---|
| 3796 | * Purpose :
|
|---|
| 3797 | * Parameters:
|
|---|
| 3798 | * Variables :
|
|---|
| 3799 | * Result :
|
|---|
| 3800 | * Remark :
|
|---|
| 3801 | * Status :
|
|---|
| 3802 | *
|
|---|
| 3803 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3804 | *****************************************************************************/
|
|---|
| 3805 |
|
|---|
| 3806 | BOOL WIN32API WriteConsoleW(HANDLE hConsoleOutput,
|
|---|
| 3807 | CONST VOID* lpvBuffer,
|
|---|
| 3808 | DWORD cchToWrite,
|
|---|
| 3809 | LPDWORD lpcchWritten,
|
|---|
| 3810 | LPVOID lpvReserved)
|
|---|
| 3811 | {
|
|---|
| 3812 | BOOL fResult;
|
|---|
| 3813 |
|
|---|
| 3814 | #ifdef DEBUG_LOCAL2
|
|---|
| 3815 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3816 | hConsoleOutput,
|
|---|
| 3817 | lpvBuffer,
|
|---|
| 3818 | cchToWrite,
|
|---|
| 3819 | lpcchWritten,
|
|---|
| 3820 | lpvReserved);
|
|---|
| 3821 | #endif
|
|---|
| 3822 |
|
|---|
| 3823 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3824 | DRQ_WRITECONSOLEW,
|
|---|
| 3825 | (ULONG)lpvBuffer,
|
|---|
| 3826 | (ULONG)cchToWrite,
|
|---|
| 3827 | (ULONG)lpcchWritten,
|
|---|
| 3828 | (ULONG)lpvReserved);
|
|---|
| 3829 |
|
|---|
| 3830 | return fResult;
|
|---|
| 3831 | }
|
|---|
| 3832 |
|
|---|
| 3833 |
|
|---|
| 3834 | /*****************************************************************************
|
|---|
| 3835 | * Name :
|
|---|
| 3836 | * Purpose :
|
|---|
| 3837 | * Parameters:
|
|---|
| 3838 | * Variables :
|
|---|
| 3839 | * Result :
|
|---|
| 3840 | * Remark :
|
|---|
| 3841 | * Status :
|
|---|
| 3842 | *
|
|---|
| 3843 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3844 | *****************************************************************************/
|
|---|
| 3845 |
|
|---|
| 3846 | BOOL WIN32API WriteConsoleInputA(HANDLE hConsoleInput,
|
|---|
| 3847 | PINPUT_RECORD pirBuffer,
|
|---|
| 3848 | DWORD cInRecords,
|
|---|
| 3849 | LPDWORD lpcWritten)
|
|---|
| 3850 | {
|
|---|
| 3851 | BOOL fResult;
|
|---|
| 3852 |
|
|---|
| 3853 | #ifdef DEBUG_LOCAL2
|
|---|
| 3854 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
|---|
| 3855 | hConsoleInput,
|
|---|
| 3856 | pirBuffer,
|
|---|
| 3857 | cInRecords,
|
|---|
| 3858 | lpcWritten);
|
|---|
| 3859 | #endif
|
|---|
| 3860 |
|
|---|
| 3861 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3862 | DRQ_WRITECONSOLEINPUTA,
|
|---|
| 3863 | (ULONG)pirBuffer,
|
|---|
| 3864 | (ULONG)cInRecords,
|
|---|
| 3865 | (ULONG)lpcWritten,
|
|---|
| 3866 | 0);
|
|---|
| 3867 |
|
|---|
| 3868 | return fResult;
|
|---|
| 3869 | }
|
|---|
| 3870 |
|
|---|
| 3871 |
|
|---|
| 3872 | /*****************************************************************************
|
|---|
| 3873 | * Name :
|
|---|
| 3874 | * Purpose :
|
|---|
| 3875 | * Parameters:
|
|---|
| 3876 | * Variables :
|
|---|
| 3877 | * Result :
|
|---|
| 3878 | * Remark :
|
|---|
| 3879 | * Status :
|
|---|
| 3880 | *
|
|---|
| 3881 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3882 | *****************************************************************************/
|
|---|
| 3883 |
|
|---|
| 3884 | BOOL WIN32API WriteConsoleInputW(HANDLE hConsoleInput,
|
|---|
| 3885 | PINPUT_RECORD pirBuffer,
|
|---|
| 3886 | DWORD cInRecords,
|
|---|
| 3887 | LPDWORD lpcWritten)
|
|---|
| 3888 | {
|
|---|
| 3889 | BOOL fResult;
|
|---|
| 3890 |
|
|---|
| 3891 | #ifdef DEBUG_LOCAL2
|
|---|
| 3892 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
|---|
| 3893 | hConsoleInput,
|
|---|
| 3894 | pirBuffer,
|
|---|
| 3895 | cInRecords,
|
|---|
| 3896 | lpcWritten);
|
|---|
| 3897 | #endif
|
|---|
| 3898 |
|
|---|
| 3899 | fResult = (BOOL)HMDeviceRequest(hConsoleInput,
|
|---|
| 3900 | DRQ_WRITECONSOLEINPUTW,
|
|---|
| 3901 | (ULONG)pirBuffer,
|
|---|
| 3902 | (ULONG)cInRecords,
|
|---|
| 3903 | (ULONG)lpcWritten,
|
|---|
| 3904 | 0);
|
|---|
| 3905 |
|
|---|
| 3906 | return fResult;
|
|---|
| 3907 | }
|
|---|
| 3908 |
|
|---|
| 3909 |
|
|---|
| 3910 | /*****************************************************************************
|
|---|
| 3911 | * Name :
|
|---|
| 3912 | * Purpose :
|
|---|
| 3913 | * Parameters:
|
|---|
| 3914 | * Variables :
|
|---|
| 3915 | * Result :
|
|---|
| 3916 | * Remark :
|
|---|
| 3917 | * Status :
|
|---|
| 3918 | *
|
|---|
| 3919 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3920 | *****************************************************************************/
|
|---|
| 3921 |
|
|---|
| 3922 | BOOL WIN32API WriteConsoleOutputA(HANDLE hConsoleOutput,
|
|---|
| 3923 | PCHAR_INFO pchiSrcBuffer,
|
|---|
| 3924 | COORD coordSrcBufferSize,
|
|---|
| 3925 | COORD coordSrcBufferCoord,
|
|---|
| 3926 | PSMALL_RECT psrctDestRect)
|
|---|
| 3927 | {
|
|---|
| 3928 | BOOL fResult;
|
|---|
| 3929 |
|
|---|
| 3930 | #ifdef DEBUG_LOCAL2
|
|---|
| 3931 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3932 | hConsoleOutput,
|
|---|
| 3933 | pchiSrcBuffer,
|
|---|
| 3934 | coordSrcBufferSize,
|
|---|
| 3935 | coordSrcBufferCoord,
|
|---|
| 3936 | psrctDestRect);
|
|---|
| 3937 | #endif
|
|---|
| 3938 |
|
|---|
| 3939 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3940 | DRQ_WRITECONSOLEOUTPUTA,
|
|---|
| 3941 | (ULONG)pchiSrcBuffer,
|
|---|
| 3942 | COORD2ULONG(coordSrcBufferSize),
|
|---|
| 3943 | COORD2ULONG(coordSrcBufferCoord),
|
|---|
| 3944 | (ULONG)psrctDestRect);
|
|---|
| 3945 |
|
|---|
| 3946 | return fResult;
|
|---|
| 3947 | }
|
|---|
| 3948 |
|
|---|
| 3949 |
|
|---|
| 3950 | /*****************************************************************************
|
|---|
| 3951 | * Name :
|
|---|
| 3952 | * Purpose :
|
|---|
| 3953 | * Parameters:
|
|---|
| 3954 | * Variables :
|
|---|
| 3955 | * Result :
|
|---|
| 3956 | * Remark :
|
|---|
| 3957 | * Status :
|
|---|
| 3958 | *
|
|---|
| 3959 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3960 | *****************************************************************************/
|
|---|
| 3961 |
|
|---|
| 3962 | BOOL WIN32API WriteConsoleOutputW(HANDLE hConsoleOutput,
|
|---|
| 3963 | PCHAR_INFO pchiSrcBuffer,
|
|---|
| 3964 | COORD coordSrcBufferSize,
|
|---|
| 3965 | COORD coordSrcBufferCoord,
|
|---|
| 3966 | PSMALL_RECT psrctDestRect)
|
|---|
| 3967 | {
|
|---|
| 3968 | BOOL fResult;
|
|---|
| 3969 |
|
|---|
| 3970 | #ifdef DEBUG_LOCAL2
|
|---|
| 3971 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 3972 | hConsoleOutput,
|
|---|
| 3973 | pchiSrcBuffer,
|
|---|
| 3974 | coordSrcBufferSize,
|
|---|
| 3975 | coordSrcBufferCoord,
|
|---|
| 3976 | psrctDestRect);
|
|---|
| 3977 | #endif
|
|---|
| 3978 |
|
|---|
| 3979 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 3980 | DRQ_WRITECONSOLEOUTPUTW,
|
|---|
| 3981 | (ULONG)pchiSrcBuffer,
|
|---|
| 3982 | COORD2ULONG(coordSrcBufferSize),
|
|---|
| 3983 | COORD2ULONG(coordSrcBufferCoord),
|
|---|
| 3984 | (ULONG)psrctDestRect);
|
|---|
| 3985 |
|
|---|
| 3986 | return fResult;
|
|---|
| 3987 | }
|
|---|
| 3988 |
|
|---|
| 3989 | /*****************************************************************************
|
|---|
| 3990 | * Name :
|
|---|
| 3991 | * Purpose :
|
|---|
| 3992 | * Parameters:
|
|---|
| 3993 | * Variables :
|
|---|
| 3994 | * Result :
|
|---|
| 3995 | * Remark :
|
|---|
| 3996 | * Status :
|
|---|
| 3997 | *
|
|---|
| 3998 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 3999 | *****************************************************************************/
|
|---|
| 4000 |
|
|---|
| 4001 | BOOL WIN32API WriteConsoleOutputAttribute(HANDLE hConsoleOutput,
|
|---|
| 4002 | LPWORD lpwAttribute,
|
|---|
| 4003 | DWORD cWriteCells,
|
|---|
| 4004 | COORD coordWriteCoord,
|
|---|
| 4005 | LPDWORD lpcNumberWritten)
|
|---|
| 4006 | {
|
|---|
| 4007 | BOOL fResult;
|
|---|
| 4008 |
|
|---|
| 4009 | #ifdef DEBUG_LOCAL2
|
|---|
| 4010 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputAttribute(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 4011 | hConsoleOutput,
|
|---|
| 4012 | lpwAttribute,
|
|---|
| 4013 | cWriteCells,
|
|---|
| 4014 | coordWriteCoord,
|
|---|
| 4015 | lpcNumberWritten);
|
|---|
| 4016 | #endif
|
|---|
| 4017 |
|
|---|
| 4018 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 4019 | DRQ_WRITECONSOLEOUTPUTATTRIBUTE,
|
|---|
| 4020 | (ULONG)lpwAttribute,
|
|---|
| 4021 | (ULONG)cWriteCells,
|
|---|
| 4022 | COORD2ULONG(coordWriteCoord),
|
|---|
| 4023 | (ULONG)lpcNumberWritten);
|
|---|
| 4024 |
|
|---|
| 4025 | return fResult;
|
|---|
| 4026 | }
|
|---|
| 4027 |
|
|---|
| 4028 |
|
|---|
| 4029 | /*****************************************************************************
|
|---|
| 4030 | * Name :
|
|---|
| 4031 | * Purpose :
|
|---|
| 4032 | * Parameters:
|
|---|
| 4033 | * Variables :
|
|---|
| 4034 | * Result :
|
|---|
| 4035 | * Remark :
|
|---|
| 4036 | * Status :
|
|---|
| 4037 | *
|
|---|
| 4038 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 4039 | *****************************************************************************/
|
|---|
| 4040 |
|
|---|
| 4041 | BOOL WIN32API WriteConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
|---|
| 4042 | LPTSTR lpWriteBuffer,
|
|---|
| 4043 | DWORD cchWrite,
|
|---|
| 4044 | COORD coordWriteCoord,
|
|---|
| 4045 | LPDWORD lpcWritten)
|
|---|
| 4046 | {
|
|---|
| 4047 | BOOL fResult;
|
|---|
| 4048 |
|
|---|
| 4049 | #ifdef DEBUG_LOCAL2
|
|---|
| 4050 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputCharacterA(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 4051 | hConsoleOutput,
|
|---|
| 4052 | lpWriteBuffer,
|
|---|
| 4053 | cchWrite,
|
|---|
| 4054 | coordWriteCoord,
|
|---|
| 4055 | lpcWritten);
|
|---|
| 4056 | #endif
|
|---|
| 4057 |
|
|---|
| 4058 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 4059 | DRQ_WRITECONSOLEOUTPUTCHARACTERA,
|
|---|
| 4060 | (ULONG)lpWriteBuffer,
|
|---|
| 4061 | (ULONG)cchWrite,
|
|---|
| 4062 | COORD2ULONG(coordWriteCoord),
|
|---|
| 4063 | (ULONG)lpcWritten);
|
|---|
| 4064 |
|
|---|
| 4065 | return fResult;
|
|---|
| 4066 | }
|
|---|
| 4067 |
|
|---|
| 4068 |
|
|---|
| 4069 | /*****************************************************************************
|
|---|
| 4070 | * Name :
|
|---|
| 4071 | * Purpose :
|
|---|
| 4072 | * Parameters:
|
|---|
| 4073 | * Variables :
|
|---|
| 4074 | * Result :
|
|---|
| 4075 | * Remark :
|
|---|
| 4076 | * Status :
|
|---|
| 4077 | *
|
|---|
| 4078 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 4079 | *****************************************************************************/
|
|---|
| 4080 |
|
|---|
| 4081 | BOOL WIN32API WriteConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
|---|
| 4082 | LPTSTR lpWriteBuffer,
|
|---|
| 4083 | DWORD cchWrite,
|
|---|
| 4084 | COORD coordWriteCoord,
|
|---|
| 4085 | LPDWORD lpcWritten)
|
|---|
| 4086 | {
|
|---|
| 4087 | BOOL fResult;
|
|---|
| 4088 |
|
|---|
| 4089 | #ifdef DEBUG_LOCAL2
|
|---|
| 4090 | WriteLog("KERNEL32/CONSOLE: OS2WriteConsoleOutputCharacterW(%08x,%08x,%08x,%08x,%08x).\n",
|
|---|
| 4091 | hConsoleOutput,
|
|---|
| 4092 | lpWriteBuffer,
|
|---|
| 4093 | cchWrite,
|
|---|
| 4094 | coordWriteCoord,
|
|---|
| 4095 | lpcWritten);
|
|---|
| 4096 | #endif
|
|---|
| 4097 |
|
|---|
| 4098 | fResult = (BOOL)HMDeviceRequest(hConsoleOutput,
|
|---|
| 4099 | DRQ_WRITECONSOLEOUTPUTCHARACTERW,
|
|---|
| 4100 | (ULONG)lpWriteBuffer,
|
|---|
| 4101 | (ULONG)cchWrite,
|
|---|
| 4102 | COORD2ULONG(coordWriteCoord),
|
|---|
| 4103 | (ULONG)lpcWritten);
|
|---|
| 4104 |
|
|---|
| 4105 | return fResult;
|
|---|
| 4106 | }
|
|---|