mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
parent
2bb08a4ca0
commit
d07ea3b66a
2 changed files with 33 additions and 0 deletions
|
@ -1209,6 +1209,13 @@ static void test_escape_sequences(void)
|
|||
if (escape_code_length(L"\x1b[2J") != 4) err(L"test_escape_sequences failed on line %d\n", __LINE__);
|
||||
if (escape_code_length(L"\x1b[38;5;123mABC") != strlen("\x1b[38;5;123m")) err(L"test_escape_sequences failed on line %d\n", __LINE__);
|
||||
if (escape_code_length(L"\x1b@") != 2) err(L"test_escape_sequences failed on line %d\n", __LINE__);
|
||||
if (escape_code_length(L"\x1b@") != 2) err(L"test_escape_sequences failed on line %d\n", __LINE__);
|
||||
|
||||
// iTerm2 escape sequences
|
||||
if (escape_code_length(L"\x1b]50;CurrentDir=/tmp/foo\x07NOT_PART_OF_SEQUENCE") != 24) err(L"test_escape_sequences failed on line %d\n", __LINE__);
|
||||
if (escape_code_length(L"\x1b]50;SetMark\x07NOT_PART_OF_SEQUENCE") != 12) err(L"test_escape_sequences failed on line %d\n", __LINE__);
|
||||
if (escape_code_length(L"\x1b" L"]6;1;bg;red;brightness;255\x07NOT_PART_OF_SEQUENCE") != 27) err(L"test_escape_sequences failed on line %d\n", __LINE__);
|
||||
if (escape_code_length(L"\x1b]Pg4040ff\x1b\\NOT_PART_OF_SEQUENCE") != 10) err(L"test_escape_sequences failed on line %d\n", __LINE__);
|
||||
}
|
||||
|
||||
class lru_node_test_t : public lru_node_t
|
||||
|
|
26
screen.cpp
26
screen.cpp
|
@ -253,6 +253,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)
|
||||
{
|
||||
/* Generic VT100 one byte sequence: CSI followed by something in the range @ through _ */
|
||||
|
|
Loading…
Reference in a new issue