Skip to content

Commit

Permalink
win32: SGR emulation: minor fixup on invalid sequence
Browse files Browse the repository at this point in the history
This fixes two issues with invalid value after 38/48:
- It was not detected correctly and ended up skipping 4 instead of 0.
- The intent was to skip 0, but it's better to skip the rest.

Behavior with valid 2/5 after 38/48 was correct and is unaffected.
  • Loading branch information
avih committed Apr 24, 2020
1 parent b036e56 commit 77738ac
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions osdep/terminal-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,11 @@ void mp_write_console_ansi(HANDLE wstream, char *buf)
attr |= stdoutAttrs & BACKGROUND_ALL;
} else if (p == 38 || p == 48) { // ignore and skip sub-values
// 256 colors: <38/48>;5;N true colors: <38/48>;2;R;G;B
if (n+1 < num_params)
n += params[n+1] == 5 ? 2 : 2 ? 4 : 0;
if (n+1 < num_params) {
n += params[n+1] == 5 ? 2
: params[n+1] == 2 ? 4
: num_params; /* unrecognized -> the rest */
}
}
}

Expand Down

0 comments on commit 77738ac

Please sign in to comment.