Changeset 1484 for trunk/src/kernel32
- Timestamp:
- Oct 27, 1999, 8:36:36 PM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/conbuffer.cpp
r297 r1484 1 /* $Id: conbuffer.cpp,v 1. 4 1999-07-12 17:45:50phaller Exp $ */1 /* $Id: conbuffer.cpp,v 1.5 1999-10-27 18:36:33 phaller Exp $ */ 2 2 3 3 /* … … 18 18 #endif 19 19 20 #undef DEBUG_LOCAL21 #undef DEBUG_LOCAL220 //#undef DEBUG_LOCAL 21 //#undef DEBUG_LOCAL2 22 22 23 23 … … 73 73 #include "ConBuffer.H" 74 74 #include "Console2.h" 75 #include <heapstring.h> 75 76 76 77 … … 289 290 290 291 case 8: /* Backspace */ 292 // not correct if deleting expanded tab character 291 293 if (pConsoleBuffer->coordCursorPosition.X > 0) 292 294 pConsoleBuffer->coordCursorPosition.X--; 295 296 //@@@PH overwrite old character 297 *(pConsoleBuffer->ppszLine[pConsoleBuffer->coordCursorPosition.Y] + 298 pConsoleBuffer->coordCursorPosition.X * 2) = 0x20; 293 299 break; 294 300 … … 319 325 break; 320 326 327 case 13: /* CARRIAGE RETURN */ 328 pConsoleBuffer->coordCursorPosition.X = 0; 329 //@@@PH test break; 330 321 331 case 10: /* LINEFEED */ 322 332 pConsoleBuffer->coordCursorPosition.Y++; … … 329 339 pConsoleBuffer->coordCursorPosition.Y--; 330 340 } 331 break;332 333 case 13: /* CARRIAGE RETURN */334 pConsoleBuffer->coordCursorPosition.X = 0;335 341 break; 336 342 … … 2521 2527 { 2522 2528 PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData; 2529 DWORD rc; 2530 LPSTR pszAscii; 2523 2531 2524 2532 #ifdef DEBUG_LOCAL2 … … 2531 2539 #endif 2532 2540 2533 /* @@@PH AScii -> unicode translation */ 2541 /* Ascii -> unicode translation */ 2542 pszAscii = (LPSTR)HEAP_malloc(cchToWrite); 2543 if (pszAscii == NULL) 2544 return ERROR_NOT_ENOUGH_MEMORY; 2545 2546 lstrcpynWtoA(pszAscii, (LPWSTR)lpvBuffer, cchToWrite); 2534 2547 2535 2548 /* simply forward the request to that routine */ 2536 return (HMDeviceConsoleBufferClass::WriteFile(pHMHandleData, 2537 lpvBuffer, 2538 cchToWrite, 2539 lpcchWritten, 2540 NULL)); 2549 rc = HMDeviceConsoleBufferClass::WriteFile(pHMHandleData, 2550 pszAscii, 2551 cchToWrite, 2552 lpcchWritten, 2553 NULL); 2554 // free memory again 2555 HEAP_free(pszAscii); 2556 return (rc); 2541 2557 } 2542 2558 -
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 */ -
trunk/src/kernel32/conout.cpp
r149 r1484 1 /* $Id: conout.cpp,v 1. 3 1999-06-21 18:53:51phaller Exp $ */1 /* $Id: conout.cpp,v 1.4 1999-10-27 18:36:35 phaller Exp $ */ 2 2 3 3 /* … … 13 13 #endif 14 14 15 #undef DEBUG_LOCAL16 #undef DEBUG_LOCAL215 //#undef DEBUG_LOCAL 16 //#undef DEBUG_LOCAL2 17 17 18 18 … … 83 83 { 84 84 void _System _O32_SetLastError(DWORD dwError); 85 int _System _O32_GetLastError(void); 85 86 } 86 87 … … 93 94 } 94 95 96 inline int GetLastError(void) 97 { 98 USHORT sel = GetFS(); 99 int rc; 100 101 rc = _O32_GetLastError(); 102 SetFS(sel); 103 return rc; 104 } 95 105 96 106 -
trunk/src/kernel32/console.cpp
r1476 r1484 1 /* $Id: console.cpp,v 1.1 5 1999-10-27 12:38:47phaller Exp $ */1 /* $Id: console.cpp,v 1.16 1999-10-27 18:36:35 phaller Exp $ */ 2 2 3 3 /* … … 18 18 #endif 19 19 20 #undef DEBUG_LOCAL21 #undef DEBUG_LOCAL220 //#undef DEBUG_LOCAL 21 //#undef DEBUG_LOCAL2 22 22 23 23 -
trunk/src/kernel32/heapstring.cpp
r1292 r1484 1 /* $Id: heapstring.cpp,v 1.1 5 1999-10-14 17:15:26 phaller Exp $ */1 /* $Id: heapstring.cpp,v 1.16 1999-10-27 18:36:36 phaller Exp $ */ 2 2 3 3 /* … … 570 570 571 571 // asciilen: max length of unicode buffer (including end 0) 572 572 // @@@PH 0 termination is NOT necessarily included ! 573 573 int WIN32API lstrcpynAtoW(LPWSTR unicode, 574 574 LPSTR ascii, … … 583 583 char* in_buf; 584 584 585 dprintf(("KERNEL32: HeapString: lstrcpynAtoW(%s,%08xh )\n",585 dprintf(("KERNEL32: HeapString: lstrcpynAtoW(%s,%08xh,%d)\n", 586 586 ascii, 587 unicode)); 587 unicode, 588 asciilen)); 588 589 589 590 //CB: no input, set at least terminator … … 599 600 if (getUconvObject()) 600 601 { 601 if (asciilen == 1) 602 //@@@PH what's this? 603 if ((asciilen == 1) && (*ascii == '\0') ) 602 604 { 603 605 unicode[0] = 0; … … 606 608 607 609 in_buf = ascii; 608 in_bytes_left = asciilen-1; //buffer size in bytes 610 611 //@@@PH what's this? 612 //in_bytes_left = asciilen-1; //buffer size in bytes 613 614 in_bytes_left = asciilen; //buffer size in bytes 609 615 out_buf = (UniChar*)unicode; 610 616 … … 616 622 &num_subs ); 617 623 618 unicode[asciilen-1-in_bytes_left] = 0; 624 //@@@PH what's this? 625 //unicode[asciilen-1-in_bytes_left] = 0; 619 626 620 627 //if (rc != ULS_SUCCESS && in_bytes_left > 0) //CB: never the case during my tests 621 628 // dprintf(("KERNEL32: AsciiToUnicode failed, %d bytes left!\n",in_bytes_left)); 622 return asciilen - 1; 629 630 //@@@PH what's this? 631 //return asciilen - 1; 632 return asciilen; 623 633 } 624 634 else 625 635 { //poor man's conversion 626 636 627 for(i = 0;i < asciilen-1;i++) 637 // for(i = 0;i < asciilen-1;i++) 638 for(i = 0;i < asciilen;i++) 628 639 { 629 640 unicode[i] = ascii[i]; 630 641 if (ascii[i] == 0) 631 return i-1; //work done 642 //return i-1; //work done 643 return i; //work done 632 644 } 633 645 634 unicode[asciilen-1] = 0; 635 return asciilen-1; 646 // unicode[asciilen-1] = 0; 647 // return asciilen-1; 648 return asciilen; 636 649 } 637 650 } … … 652 665 LPSTR WIN32API lstrcpyWtoA(LPSTR ascii, LPWSTR unicode) 653 666 { 667 //@@@PH huh? wuz dat? 654 668 if (unicode == NULL) 655 669 {
Note:
See TracChangeset
for help on using the changeset viewer.