Preserve ESC not part of a sequence

There are some instances when ESC should just be a normal character
(e.g. TCC uses it in aliases to clear the current line), so if no
sequence is recognised, pass the ESC through.
This commit is contained in:
Jason Hood 2017-11-07 11:35:42 +10:00
parent 43b3653c8a
commit 8eb06aad27
3 changed files with 23 additions and 10 deletions

19
ANSI.c
View File

@ -152,12 +152,14 @@
remove wcstok, avoiding potential interference with the host;
similarly, use a private heap instead of malloc.
v1.80, 26 October to 3 November, 2017:
v1.80, 26 October to 7 November, 2017:
fix unloading;
revert back to (re)storing buffer cursor position;
increase cache to five handles;
hook CreateFile & CreateConsoleScreenBuffer to enable readable handles;
fix cursor report with duplicated digits (e.g. "11" was just "1").
fix cursor report with duplicated digits (e.g. "11" was just "1");
preserve escape that isn't part of a sequence;
fix escape followed by CRM in control mode.
*/
#include "ansicon.h"
@ -1202,7 +1204,8 @@ ParseAndPrintString( HANDLE hDev,
}
else if (state == 2)
{
if (c == ESC) ; // \e\e...\e == \e
if (c == ESC)
PushBuffer( ESC );
else if (c >= '\x20' && c <= '\x2f')
suffix2 = c;
else if (suffix2 != 0)
@ -1225,7 +1228,12 @@ ParseAndPrintString( HANDLE hDev,
*Pt_arg = '\0';
state = 6;
}
else state = 1;
else
{
PushBuffer( ESC );
PushBuffer( (WCHAR)c );
state = 1;
}
}
else if (state == 3)
{
@ -1329,10 +1337,13 @@ ParseAndPrintString( HANDLE hDev,
else
{
PushBuffer( ESC );
if (c != ESC)
{
PushBuffer( (WCHAR)c );
state = 1;
}
}
}
else if (state == 8)
{
if (c == '3') state = 9;

View File

@ -90,7 +90,7 @@
write newline with _putws, not putwchar (fixes redirecting to CON).
*/
#define PDATE L"3 November, 2017"
#define PDATE L"7 November, 2017"
#include "ansicon.h"
#include "version.h"

View File

@ -295,13 +295,15 @@ Version History
Legend: + added, - bug-fixed, * changed.
1.80 - 3 November, 2017:
1.80 - 7 November, 2017:
- fix unloading;
- fix -e et al when redirecting to CON;
- hook CreateFile and CreateConsoleScreenBuffer to force read/write access
(fixes redirecting to CON and Microsoft's conio);
- fix cursor report with duplicated digits (e.g. "11" was only writing "1");
* go back to saving the buffer cursor position.
- fix escape followed by CRM in control mode;
* go back to saving the buffer cursor position;
* preserve escape that isn't part of a sequence.
1.72 - 24 December, 2015:
- handle STD_OUTPUT_HANDLE & STD_ERROR_HANDLE in WriteFile;
@ -530,4 +532,4 @@ Distribution
=============================
Jason Hood, 3 November, 2017.
Jason Hood, 7 November, 2017.