Terminal: fix handling utf-8 characters in OSC commands

Process the Operating System Control command in multibyte-aware way.
That fixes corresponding behavior for latest versions of Midnight
Commander;
This commit is contained in:
Siarzhuk Zharski 2013-05-20 13:50:44 +02:00
parent 3bbef9dd76
commit 7c8e63e171

View File

@ -1048,8 +1048,19 @@ TermParse::EscParse()
uchar params[512];
// fill the buffer until BEL, ST or something else.
bool isParsed = false;
int32 skipCount = 0; // take care about UTF-8 characters
for (uint i = 0; !isParsed && i < sizeof(params); i++) {
params[i] = _NextParseChar();
if (skipCount > 0) {
skipCount--;
continue;
}
skipCount = UTF8Char::ByteCount(params[i]) - 1;
if (skipCount > 0)
continue;
switch (params[i]) {
// BEL
case 0x07:
@ -1074,6 +1085,9 @@ TermParse::EscParse()
params[i] = '\0';
}
// watchdog for the 'end of buffer' case
params[sizeof(params) - 1] = '\0';
if (isParsed)
_ProcessOperatingSystemControls(params);