I can't get the text to display on console and neither is it saved properly. I got the arrow keys, enter,backspace and escpe working though.
also another /small/ error I don't really get is when I press esc and it exits from the void I get directed to this piece of code
#endif /* defined (_M_IX86) || defined (_M_X64) */
__fastfail(FAST_FAIL_STACK_COOKIE_CHECK_FAILURE);
inside of gc_report.c, which I don't find nuch infor,ation about (or atleast related to my problem).
#define KEY_UP 72
#define KEY_DOWN 80
#define KEY_LEFT 75
#define KEY_RIGHT 77
#define KEY_ENTER 13
#define KEY_BACKSPACE 8
#define KEY_ESCAPE 27
void texteditor(int x, int y,int kolommen,char textarr[20][20],int rijen=20)
{
int index = 0, indey = 0, keuze,lol = 20;
do{
gotoxy(index + x, indey + y);
keuze = 0;
keuze = _getch();
if (keuze == 0 || keuze == 0xE0 || keuze == 224)
{
keuze = _getch();
gotoxy(index + x, indey + y);
switch (keuze)
{
case KEY_UP:indey--;
break;
case KEY_LEFT: index--;
break;
case KEY_DOWN:indey++;
break;
case KEY_RIGHT: index++;
break;
}
indey = (indey <= 0) ? 0 : (indey > kolommen) ? kolommen : indey;
index = (index <= 0) ? 0 : (index > rijen) ? rijen : index;
}
if (keuze == 32 || (keuze >= 46 && keuze <= 57) || (keuze <= 64 && keuze >= 126))
{
textarr[index][indey] = (char)keuze;
std::cout << textarr[index][indey];
index++;
index = (index <= 0) ? 0 : (index > rijen) ? rijen : index;
}
if (keuze == KEY_BACKSPACE)
{
index = index--;
gotoxy(index + x, indey + y);
std::cout << " ";
index = (index <= 0) ? 0 : (index > rijen) ? rijen : index;
}
if (keuze == KEY_ENTER)
{
index = 0;
indey++;
indey =(indey >= kolommen) ? kolommen : indey++;
}
} while (keuze != KEY_ESCAPE);}
I also searched a bit on the values behind the arrow keys, in which I found 37(left arrow),38(up arrow),39(right arrow),40(down arrow) as ASCII value, then what's the difference from mine?