26 #define CCOM_WRITE_TEXT 0x2
29 #define CCOM_GET_TEXT 0x3
33 #define CCOM_GET_SCR_LINES 0x4
36 #define CCOM_SET_SCR_LINES 0x5
52 BOOL ReadText (LPTSTR pszText,
int iBeginLine,
int iEndLine);
116 if (!hFile || !heventParent || !heventChild)
118 printf (
"Qhost not present.\n");
122 printf (
"Initializing for qhost.\n");
133 printf (
"Couldn't create heventDone\n");
140 printf (
"Couldn't create QHOST thread\n");
145 hStdout = GetStdHandle (STD_OUTPUT_HANDLE);
146 hStdin = GetStdHandle (STD_INPUT_HANDLE);
164 HANDLE heventWait[2];
165 int iBeginLine, iEndLine;
172 dwRet = WaitForMultipleObjects (2, heventWait, FALSE, INFINITE);
175 if (dwRet == WAIT_OBJECT_0 + 1)
183 printf (
"Invalid hfileBuffer\n");
191 pBuffer[0] =
WriteText ((LPCTSTR) (pBuffer + 1));
197 iBeginLine = pBuffer[1];
198 iEndLine = pBuffer[2];
199 pBuffer[0] =
ReadText ((LPTSTR) (pBuffer + 1), iBeginLine,
228 FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
236 UnmapViewOfFile (pBuffer);
242 CONSOLE_SCREEN_BUFFER_INFO info;
245 bRet = GetConsoleScreenBufferInfo (
hStdout, &info);
248 *piLines = info.dwSize.Y;
268 coord.Y = iBeginLine;
270 bRet = ReadConsoleOutputCharacter(
273 80 * (iEndLine - iBeginLine + 1),
279 pszText[dwRead] =
'\0';
291 sz = (LPTSTR) szText;
299 upper = toupper(*sz);
301 rec.EventType = KEY_EVENT;
302 rec.Event.KeyEvent.bKeyDown = TRUE;
303 rec.Event.KeyEvent.wRepeatCount = 1;
304 rec.Event.KeyEvent.wVirtualKeyCode = upper;
305 rec.Event.KeyEvent.wVirtualScanCode =
CharToCode (*sz);
306 rec.Event.KeyEvent.uChar.AsciiChar = *sz;
307 rec.Event.KeyEvent.uChar.UnicodeChar = *sz;
308 rec.Event.KeyEvent.dwControlKeyState = isupper(*sz) ? 0x80 : 0x0;
316 rec.Event.KeyEvent.bKeyDown = FALSE;
347 return (30 + upper - 65);
350 return (1 + upper - 47);
358 CONSOLE_SCREEN_BUFFER_INFO info;
361 coordMax = GetLargestConsoleWindowSize(
hStdout);
369 if (!GetConsoleScreenBufferInfo(
hStdout, &info))
373 info.srWindow.Left = 0;
374 info.srWindow.Right = info.dwSize.X - 1;
375 info.srWindow.Top = 0;
376 info.srWindow.Bottom = cy - 1;
378 if (cy < info.dwSize.Y)
380 if (!SetConsoleWindowInfo(
hStdout, TRUE, &info.srWindow))
385 if (!SetConsoleScreenBufferSize(
hStdout, info.dwSize))
388 else if (cy > info.dwSize.Y)
392 if (!SetConsoleScreenBufferSize(
hStdout, info.dwSize))
395 if (!SetConsoleWindowInfo(
hStdout, TRUE, &info.srWindow))
399 if (!GetConsoleScreenBufferInfo(
hStdout, &info))
403 info.srWindow.Left = 0;
404 info.srWindow.Right = cx - 1;
405 info.srWindow.Top = 0;
406 info.srWindow.Bottom = info.dwSize.Y - 1;
408 if (cx < info.dwSize.X)
410 if (!SetConsoleWindowInfo(
hStdout, TRUE, &info.srWindow))
415 if (!SetConsoleScreenBufferSize(
hStdout, info.dwSize))
418 else if (cx > info.dwSize.X)
422 if (!SetConsoleScreenBufferSize(
hStdout, info.dwSize))
425 if (!SetConsoleWindowInfo(
hStdout, TRUE, &info.srWindow))