diff options
author | 2014-07-26 14:07:17 -0700 | |
---|---|---|
committer | 2014-07-26 14:07:17 -0700 | |
commit | d07ea3b66abcbdc4efbd91d3dc9f83952990e2fd (patch) | |
tree | ccd81bef6cf9099d539acb03d5d8ac2f0e2b19fe /screen.cpp | |
parent | 2bb08a4ca0bc5e31e109abf7d627324c74f98436 (diff) |
Teach fish to compute the length of more escape sequences.
Fixes #1243
Diffstat (limited to 'screen.cpp')
-rw-r--r-- | screen.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -252,6 +252,32 @@ size_t escape_code_length(const wchar_t *code) } } } + + if (! found) + { + /* iTerm2 escape codes: CSI followed by ], terminated by either BEL or - see https://code.google.com/p/iterm2/wiki/ProprietaryEscapeCodes */ + if (code[1] == ']') + { + /* A sequence of characters terminated by either 'ESC backslash' or BEL */ + const wchar_t * const end1_sentinel = L"\x1b\\"; + const wchar_t * const end2_sentinel = L"\a"; + const wchar_t *end1 = wcsstr(&code[2], end1_sentinel); + const wchar_t *end2 = wcsstr(&code[2], end2_sentinel); + + // Use the non-null end, or if both are null, use the earlier end + const wchar_t *end = end1; + if (end == NULL || (end2 != NULL && end2 < end)) + { + end = end2; + } + if (end != NULL) + { + assert(end > code); + resulting_length = (end - code); + found = true; + } + } + } if (! found) { |