Changeset 1484 for trunk/src/kernel32/conin.cpp
- Timestamp:
- Oct 27, 1999, 8:36:36 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/conin.cpp
r670 r1484 1 /* $Id: conin.cpp,v 1. 5 1999-08-24 23:37:07phaller Exp $ */1 /* $Id: conin.cpp,v 1.6 1999-10-27 18:36:34 phaller Exp $ */ 2 2 3 3 /* … … 10 10 #ifdef DEBUG 11 11 #define DEBUG_LOCAL 12 #define DEBUG_LOCAL2 12 13 #endif 13 14 … … 41 42 #include "Conin.H" 42 43 #include "Console2.h" 44 #include <heapstring.h> 43 45 44 46 … … 123 125 INPUT_RECORD InputRecord; /* buffer for the event to be read */ 124 126 ULONG ulPostCounter; /* semaphore post counter */ 127 BOOL fLoop = TRUE; /* set to false if function may return to caller */ 125 128 126 129 #ifdef DEBUG_LOCAL … … 138 141 139 142 /* block if no key events are in the queue */ 140 for (; ulCounter==0;) /* until we got some characters */143 for (;fLoop;) /* until we got some characters */ 141 144 { 142 145 if (iConsoleInputQueryEvents() == 0) /* if queue is currently empty */ … … 153 156 if (rc == NO_ERROR) /* if we've got a valid event in the queue */ 154 157 { 155 if (InputRecord.EventType == KEY_EVENT) /* check event type */ 158 //@@@PH other events are discarded! 159 if ( (InputRecord.EventType == KEY_EVENT) && /* check event type */ 160 (InputRecord.Event.KeyEvent.bKeyDown == TRUE) ) 156 161 { 162 // console in line input mode ? 163 if (pConsoleInput->dwConsoleMode & ENABLE_LINE_INPUT) 164 { 165 // continue until buffer full or CR entered 166 if (InputRecord.Event.KeyEvent.uChar.AsciiChar == 0x0d) 167 fLoop = FALSE; 168 } 169 else 170 fLoop = FALSE; // return on any single key in buffer :) 171 172 // record key stroke 173 if (pConsoleInput->dwConsoleMode & ENABLE_PROCESSED_INPUT) 174 { 175 // filter special characters first 176 switch (InputRecord.Event.KeyEvent.uChar.AsciiChar) 177 { 178 case 0x03: // ctrl-c is filtered! 179 case 0x0a: // LF 180 case 0x0d: // CR 181 // do NOT insert those keys into the resulting buffer 182 break; 183 184 case 0x08: // backspace 185 if (ulCounter > 0) 186 { 187 //@@@PH erase character on screen! 188 ulCounter--; 189 pszTarget--; 157 190 /* local echo enabled ? */ 158 if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)159 HMWriteFile(pConsoleGlobals->hConsoleBuffer,191 if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT) 192 HMWriteFile(pConsoleGlobals->hConsoleBuffer, 160 193 &InputRecord.Event.KeyEvent.uChar.AsciiChar, 161 194 1, 162 195 &ulPostCounter, /* dummy result */ 163 196 NULL); 164 165 // console in line input mode ? 166 if ( (pConsoleInput->dwConsoleMode & ENABLE_LINE_INPUT) && 167 (InputRecord.Event.KeyEvent.uChar.AsciiChar == 0x0d)) 168 goto __readfile_exit; 169 170 // record key stroke 171 *pszTarget = InputRecord.Event.KeyEvent.uChar.AsciiChar; 172 pszTarget++; 173 ulCounter++; 197 } 198 break; 199 200 default: 201 // OK, for the rest ... 202 *pszTarget = InputRecord.Event.KeyEvent.uChar.AsciiChar; 203 dprintf(("KERNEL32:CONIN$: Debug: recorded key (%c - %02xh)\n", 204 *pszTarget, 205 *pszTarget)); 206 207 pszTarget++; 208 ulCounter++; 209 /* local echo enabled ? */ 210 if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT) 211 HMWriteFile(pConsoleGlobals->hConsoleBuffer, 212 &InputRecord.Event.KeyEvent.uChar.AsciiChar, 213 1, 214 &ulPostCounter, /* dummy result */ 215 NULL); 216 217 218 } 219 } 220 else 221 { 222 *pszTarget = InputRecord.Event.KeyEvent.uChar.AsciiChar; 223 dprintf(("KERNEL32:CONIN$: Debug: recorded key (%c - %02xh)\n", 224 *pszTarget, 225 *pszTarget)); 226 227 pszTarget++; 228 ulCounter++; 229 230 /* local echo enabled ? */ 231 if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT) 232 HMWriteFile(pConsoleGlobals->hConsoleBuffer, 233 &InputRecord.Event.KeyEvent.uChar.AsciiChar, 234 1, 235 &ulPostCounter, /* dummy result */ 236 NULL); 237 } 174 238 175 239 // buffer filled? 176 240 if (ulCounter >= nNumberOfBytesToRead) /* at buffer's end ? */ 177 goto __readfile_exit;241 fLoop = FALSE; 178 242 } 179 243 /* Note: other events are discarded */ … … 182 246 while (rc == NO_ERROR); 183 247 } 184 185 __readfile_exit:186 248 187 249 *lpNumberOfBytesRead = ulCounter; /* write result */ … … 642 704 PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData; 643 705 DWORD dwResult; 706 LPSTR lpstrAscii; 644 707 645 708 #ifdef DEBUG_LOCAL2 … … 652 715 #endif 653 716 717 // create ascii buffer 718 lpstrAscii = (LPSTR)HEAP_malloc(cchToRead); 719 if (lpstrAscii == NULL) 720 return ERROR_NOT_ENOUGH_MEMORY; 721 654 722 /* simply forward the request to that routine */ 655 723 dwResult = HMDeviceConsoleInClass::ReadFile(pHMHandleData, 656 lp vBuffer,724 lpstrAscii, 657 725 cchToRead, 658 726 lpcchRead, 659 727 NULL); 660 /* @@@PH AScii -> unicode translation */ 728 /* Ascii -> unicode translation */ 729 if (dwResult == TRUE) 730 lstrcpynAtoW((LPWSTR)lpvBuffer, lpstrAscii, *lpcchRead); 731 732 HEAP_free(lpstrAscii); 661 733 662 734 return (dwResult); /* deliver return code */
Note:
See TracChangeset
for help on using the changeset viewer.