Compiler/OS. You said C:\\ (You should know the \\ is only because you are escaping the character) so I am assuming Windows.
Code:
#include <windows.h>
#include <stdio.h>
void MouseChangeCursorPos(MOUSE_EVENT_RECORD mEr)
{
HANDLE hOut;
COORD cRt;
if(mEr.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)
{
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
cRt = mEr.dwMousePosition;
SetConsoleCursorPosition(hOut, cRt);
}
}
void WriteKey(KEY_EVENT_RECORD kEr)
{
if(kEr.bKeyDown)
{
if(
kEr.dwControlKeyState != LEFT_ALT_PRESSED &&
kEr.dwControlKeyState != LEFT_CTRL_PRESSED &&
kEr.dwControlKeyState != RIGHT_CTRL_PRESSED &&
kEr.dwControlKeyState != RIGHT_ALT_PRESSED &&
kEr.dwControlKeyState != SHIFT_PRESSED &&
kEr.uChar.AsciiChar)
{
printf("%c", kEr.uChar.AsciiChar);
}
}
}
int main(int argc, char *argv[])
{
HANDLE hIn;
DWORD read, dwOld;
INPUT_RECORD irBuf[128];
hIn = GetStdHandle(STD_INPUT_HANDLE);
GetConsoleMode(hIn, &dwOld);
SetConsoleMode(hIn, ENABLE_MOUSE_INPUT);
printf("Hello World!");
while(true)
{
ReadConsoleInput(hIn, irBuf, 128, &read);
for (int i = 0; i < read; i++)
{
if(irBuf[i].EventType == KEY_EVENT)
WriteKey(irBuf[i].Event.KeyEvent);
if(irBuf[i].EventType == MOUSE_EVENT)
MouseChangeCursorPos(irBuf[i].Event.MouseEvent);
}
}
SetConsoleMode(hIn, dwOld);
return 0;
}
You can implement bounds checking and delete handling and undo's and all the fancy features of a text editor yourself? You will enjoy these API functions: http://msdn.microsoft.com/library/de..._functions.asp