aboutsummaryrefslogtreecommitdiffhomepage
path: root/screen.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-07-26 14:07:17 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-07-26 14:07:17 -0700
commitd07ea3b66abcbdc4efbd91d3dc9f83952990e2fd (patch)
treeccd81bef6cf9099d539acb03d5d8ac2f0e2b19fe /screen.cpp
parent2bb08a4ca0bc5e31e109abf7d627324c74f98436 (diff)
Teach fish to compute the length of more escape sequences.
Fixes #1243
Diffstat (limited to 'screen.cpp')
-rw-r--r--screen.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/screen.cpp b/screen.cpp
index 96fe0f2a..7bb02226 100644
--- a/screen.cpp
+++ b/screen.cpp
@@ -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)
{