diff options
author | George Nachman <georgen@google.com> | 2014-07-16 10:40:58 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-07-30 11:35:39 -0700 |
commit | 9f59cf14686d57904816a74c3a901e79612ddbdf (patch) | |
tree | 97a7284b2eec10a1eacddda9d04f4e96ed4f6c3c /screen.cpp | |
parent | 6c80a3461ce3d9da347a8e3072d3114a08948e58 (diff) |
Parse OSC codes in escape_code_length(). They begin with <esc> ] and are terminated with ST (<esc> backslash) or BEL (ASCII 7).
Diffstat (limited to 'screen.cpp')
-rw-r--r-- | screen.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -317,7 +317,42 @@ size_t escape_code_length(const wchar_t *code) resulting_length = cursor; } } + if (! found) + { + /* OSC code, terminated by <esc>\ or <bel> */ + if (code[1] == L']') + { + // Start at 2 to skip over <esc>] + size_t cursor = 2; + bool backslash_ends = false; + for (; code[cursor] != L'\0'; cursor++) + { + /* Consume a sequence of characters up to <esc>\ or <bel> */ + wchar_t c = code[cursor]; + if (c == L'\x1b') { + backslash_ends = true; + } + else if (c == L'\\' && backslash_ends) + { + found = true; + break; + } + else + { + backslash_ends = false; + } + if (c == L'\x07') { + found = true; + break; + } + } + if (found) + { + resulting_length = cursor + 1; + } + } + } if (! found) { /* Generic VT100 two byte sequence: <esc> followed by something in the range @ through _ */ |