Hello editor now doesn't require '[' in ANSI escape sequences.
This commit is contained in:
parent
47c44caa8d
commit
55e9d358cf
|
@ -8,9 +8,11 @@ int main(int argc, char* argv[])
|
||||||
"This program is a probably the worst text editor ever made.\n"
|
"This program is a probably the worst text editor ever made.\n"
|
||||||
"You are currently using the buggy USA keyboard layout.\n"
|
"You are currently using the buggy USA keyboard layout.\n"
|
||||||
"This terminal is controlled using ANSI Escape Sequences:\n"
|
"This terminal is controlled using ANSI Escape Sequences:\n"
|
||||||
" - Type \e[32mESC [ 2 J\e[m to clear the screen\n"
|
" - Type \e[32mESC 2 J\e[m to clear the screen\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
bool lastwasesc = false;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
unsigned method = System::Keyboard::POLL;
|
unsigned method = System::Keyboard::POLL;
|
||||||
|
@ -22,11 +24,13 @@ int main(int argc, char* argv[])
|
||||||
if ( codepoint == Maxsi::Keyboard::DOWN ) { printf("\e[B"); continue; }
|
if ( codepoint == Maxsi::Keyboard::DOWN ) { printf("\e[B"); continue; }
|
||||||
if ( codepoint == Maxsi::Keyboard::RIGHT ) { printf("\e[C"); continue; }
|
if ( codepoint == Maxsi::Keyboard::RIGHT ) { printf("\e[C"); continue; }
|
||||||
if ( codepoint == Maxsi::Keyboard::LEFT ) { printf("\e[D"); continue; }
|
if ( codepoint == Maxsi::Keyboard::LEFT ) { printf("\e[D"); continue; }
|
||||||
if ( codepoint == Maxsi::Keyboard::ESC ) { printf("\e"); continue; }
|
if ( codepoint == Maxsi::Keyboard::ESC ) { printf("\e["); lastwasesc = true; continue; }
|
||||||
|
if ( lastwasesc && codepoint == '[' ) { continue; }
|
||||||
if ( codepoint >= 0x80 ) { continue; }
|
if ( codepoint >= 0x80 ) { continue; }
|
||||||
|
|
||||||
char msg[2]; msg[0] = codepoint; msg[1] = '\0';
|
char msg[2]; msg[0] = codepoint; msg[1] = '\0';
|
||||||
printf(msg);
|
printf(msg);
|
||||||
|
lastwasesc = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue