Add IND, NEL and RI

These controls always operate on the buffer, in keeping with LF.
This commit is contained in:
Jason Hood 2017-12-03 12:50:13 +10:00
parent 0c2f9b314e
commit eb997019c1
4 changed files with 88 additions and 7 deletions

77
ANSI.c
View File

@ -152,7 +152,7 @@
remove wcstok, avoiding potential interference with the host; remove wcstok, avoiding potential interference with the host;
similarly, use a private heap instead of malloc. similarly, use a private heap instead of malloc.
v1.80, 26 October to 30 November, 2017: v1.80, 26 October to 3 December, 2017:
fix unloading; fix unloading;
revert back to (re)storing buffer cursor position; revert back to (re)storing buffer cursor position;
increase cache to five handles; increase cache to five handles;
@ -165,7 +165,8 @@
use intermediate byte '+' to use buffer, not window; use intermediate byte '+' to use buffer, not window;
ESC followed by a control character will display that character; ESC followed by a control character will display that character;
added palette sequences; added palette sequences;
change the scan lines in the graphics set to their actual Unicode chars. change the scan lines in the graphics set to their actual Unicode chars;
added IND, NEL & RI (using buffer, in keeping with LF).
*/ */
#include "ansicon.h" #include "ansicon.h"
@ -1418,6 +1419,61 @@ void InterpretEscSeq( void )
} }
} }
void ScrollDown( void )
{
CONSOLE_SCREEN_BUFFER_INFO Info;
SMALL_RECT Rect;
COORD Pos;
CHAR_INFO CharInfo;
GetConsoleScreenBufferInfo( hConOut, &Info );
if (CUR.Y == LAST)
{
Rect.Left = LEFT;
Rect.Right = RIGHT;
Rect.Top = 1;
Rect.Bottom = LAST;
Pos.X = Pos.Y = 0;
CharInfo.Char.UnicodeChar = ' ';
CharInfo.Attributes = Info.wAttributes;
ScrollConsoleScreenBuffer( hConOut, &Rect, NULL, Pos, &CharInfo );
}
else
{
++CUR.Y;
SetConsoleCursorPosition( hConOut, CUR );
}
}
void ScrollUp( void )
{
CONSOLE_SCREEN_BUFFER_INFO Info;
SMALL_RECT Rect;
COORD Pos;
CHAR_INFO CharInfo;
GetConsoleScreenBufferInfo( hConOut, &Info );
if (CUR.Y == 0)
{
Rect.Left = LEFT;
Rect.Right = RIGHT;
Rect.Top = 0;
Rect.Bottom = LAST - 1;
Pos.X = 0;
Pos.Y = 1;
CharInfo.Char.UnicodeChar = ' ';
CharInfo.Attributes = Info.wAttributes;
ScrollConsoleScreenBuffer( hConOut, &Rect, NULL, Pos, &CharInfo );
}
else
{
--CUR.Y;
SetConsoleCursorPosition( hConOut, CUR );
}
}
DWORD WINAPI BellThread( LPVOID param ) DWORD WINAPI BellThread( LPVOID param )
{ {
// XP doesn't support SND_SENTRY, so if it fails, try without. // XP doesn't support SND_SENTRY, so if it fails, try without.
@ -1491,6 +1547,23 @@ ParseAndPrintString( HANDLE hDev,
suffix2 = c; suffix2 = c;
else if (suffix2 != 0) else if (suffix2 != 0)
state = 1; state = 1;
else if (c == 'E') // NEL Next Line
{
PushBuffer( '\n' );
state = 1;
}
else if (c == 'D') // IND Index
{
FlushBuffer();
ScrollDown();
state = 1;
}
else if (c == 'M') // RI Reverse Index
{
FlushBuffer();
ScrollUp();
state = 1;
}
else if (c == '[' || // CSI Control Sequence Introducer else if (c == '[' || // CSI Control Sequence Introducer
c == ']') // OSC Operating System Command c == ']') // OSC Operating System Command
{ {

View File

@ -91,7 +91,7 @@
use -pu to unload from the parent. use -pu to unload from the parent.
*/ */
#define PDATE L"30 November, 2017" #define PDATE L"3 December, 2017"
#include "ansicon.h" #include "ansicon.h"
#include "version.h" #include "version.h"

View File

@ -189,9 +189,12 @@ Sequences Recognised
\e[#;#f HVP Character And Line Position \e[#;#f HVP Character And Line Position
\e[#@ ICH Insert Character \e[#@ ICH Insert Character
\e[#L IL Insert Line \e[#L IL Insert Line
\eD IND Index
SI LS0 Locking-shift Zero (see below) SI LS0 Locking-shift Zero (see below)
SO LS1 Locking-shift One SO LS1 Locking-shift One
\eE NEL Next Line
\e[#b REP Repeat \e[#b REP Repeat
\eM RI Reverse Index
\e[#;#;#m SGR Select Graphic Rendition \e[#;#;#m SGR Select Graphic Rendition
\e[#d VPA Line Position Absolute \e[#d VPA Line Position Absolute
\e[#k VPB Line Position Backward \e[#k VPB Line Position Backward
@ -304,7 +307,7 @@ Version History
Legend: + added, - bug-fixed, * changed. Legend: + added, - bug-fixed, * changed.
1.80 - 30 November, 2017: 1.80 - 3 December, 2017:
- fix unloading; - fix unloading;
- fix -e et al when redirecting to CON; - fix -e et al when redirecting to CON;
- hook CreateFile and CreateConsoleScreenBuffer to force read/write access - hook CreateFile and CreateConsoleScreenBuffer to force read/write access
@ -319,7 +322,8 @@ Version History
+ added Play Sound DECPS; + added Play Sound DECPS;
+ added '+' intermediate byte to use the buffer, rather than the window; + added '+' intermediate byte to use the buffer, rather than the window;
+ added palette sequences; + added palette sequences;
+ added -pu to unload from the parent. + added -pu to unload from the parent;
+ added IND, NEL and RI.
1.72 - 24 December, 2015: 1.72 - 24 December, 2015:
- handle STD_OUTPUT_HANDLE & STD_ERROR_HANDLE in WriteFile; - handle STD_OUTPUT_HANDLE & STD_ERROR_HANDLE in WriteFile;
@ -547,5 +551,5 @@ Distribution
in LICENSE.txt. in LICENSE.txt.
============================= ============================
Jason Hood, 30 November, 2017. Jason Hood, 3 December, 2017.

View File

@ -71,6 +71,10 @@ the Windows default beep (but only if it's not already playing).
[b repeat the previous character [b repeat the previous character
[#b repeat the previous character # times [#b repeat the previous character # times
D move cursor down one line (scroll if necessary; always uses buffer)
E same as LF
M move cursor up one line (scroll if necessary; always uses buffer)
[A move cursor up one line [A move cursor up one line
[#A move cursor up # lines [#A move cursor up # lines
[B move cursor down one line [B move cursor down one line