Fixed UTF8 input in Main.cpp parse loop. More substantial key handling refactors coming soon.

This commit is contained in:
Casey Langen 2016-05-27 17:23:07 -07:00
parent 5514b0f726
commit 1ac9b18af9
2 changed files with 27 additions and 11 deletions

View File

@ -226,17 +226,34 @@ int main(int argc, char* argv[])
int64 next = -1; /* used in escape sequences */
#ifndef WIN32
/* convert +ESC to M- sequences */
if (kn == "^[") {
next = getch();
if (next != -1) {
kn = std::string("M-") + std::string(keyname((int) next));
}
/* convert +ESC to M- sequences */
if (kn == "^[") {
next = getch();
if (next != -1) {
kn = std::string("M-") + std::string(keyname((int) next));
}
#endif
}
/* multi-byte UTF8 character */
else if (ch >= 194 && ch <= 223) {
kn = "";
kn += (char) ch;
kn += (char) getch();
}
else if (ch >= 224 && ch <= 239) {
kn = "";
kn += (char) ch;
kn += (char) getch();
kn += (char) getch();
}
else if (ch >= 240 && ch <= 244) {
kn = "";
kn += (char) ch;
kn += (char) getch();
kn += (char) getch();
kn += (char) getch();
}
// std::cerr << "keyname: " << kn << std::endl;
//std::cerr << "keyname: " << kn << std::endl;
// std::cerr << "ch: " << ch << std::endl;
if (ch == '\t') { /* tab */

View File

@ -72,8 +72,6 @@ void CommandWindow::WriteChar(int64 ch) {
return;
}
waddch(this->GetContent(), ch);
if (ch == '\b' || ch == 127) { /* backspace */
wdelch(this->GetContent());
@ -97,6 +95,7 @@ void CommandWindow::WriteChar(int64 ch) {
this->bufferPosition = 0;
}
else {
waddch(this->GetContent(), ch);
this->buffer[bufferPosition++] = (char) ch;
}