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