Commit 66c83048 authored by Luis Alves's avatar Luis Alves

Add new ANSI sequences CNL and CPL

- It implements Cursor Next Line (CNL) sequence.
- It implments Cursor Previous Line (CPL) sequence.
- Ex: echo -e "Hello\e[3EWorld" or echo -e "Hello\e[3FWorld"

BUG: 418519
FIXED-IN: 20.08

!116
parent 0a3c582b
......@@ -129,6 +129,37 @@ void Screen::cursorLeft(int n)
_cuX = qMax(0, _cuX - n);
}
void Screen::cursorNextLine(int n)
//=CNL
{
if (n == 0) {
n = 1; // Default
}
_cuX = 0;
while (n > 0) {
if (_cuY < _lines - 1) {
_cuY += 1;
}
n--;
}
}
void Screen::cursorPreviousLine(int n)
//=CPL
{
if (n == 0) {
n = 1; // Default
}
_cuX = 0;
while (n > 0) {
if (_cuY > 0) {
_cuY -= 1;
}
n--;
}
}
void Screen::cursorRight(int n)
//=CUF
{
......
......@@ -117,6 +117,16 @@ public:
* The cursor will stop at the first column.
*/
void cursorLeft(int n);
/**
* Moves cursor to beginning of the line by @p n lines down.
* The cursor will stop at the beginning of the line.
*/
void cursorNextLine(int n);
/**
* Moves cursor to beginning of the line by @p n lines up.
* The cursor will stop at the beginning of the line.
*/
void cursorPreviousLine(int n);
/**
* Move the cursor to the right by @p n columns.
* The cursor will stop at the right-most column.
......
......@@ -291,7 +291,7 @@ void Vt102Emulation::initTokenizer()
for (i = 32; i < 256; ++i) {
charClass[i] |= CHR;
}
for (s = (quint8 *)"@ABCDGHILMPSTXZbcdfry"; *s != 0u; ++s) {
for (s = (quint8 *)"@ABCDEFGHILMPSTXZbcdfry"; *s != 0u; ++s) {
charClass[*s] |= CPN;
}
// resize = \e[8;<row>;<col>t
......@@ -753,8 +753,8 @@ void Vt102Emulation::processToken(int token, int p, int q)
case token_csi_pn('B' ) : _currentScreen->cursorDown (p ); break; //VT100
case token_csi_pn('C' ) : _currentScreen->cursorRight (p ); break; //VT100
case token_csi_pn('D' ) : _currentScreen->cursorLeft (p ); break; //VT100
case token_csi_pn('E' ) : /* Not implemented: cursor next p lines */ break; //VT100
case token_csi_pn('F' ) : /* Not implemented: cursor preceding p lines */ break; //VT100
case token_csi_pn('E' ) : _currentScreen->cursorNextLine (p ); break; //VT100
case token_csi_pn('F' ) : _currentScreen->cursorPreviousLine (p ); break; //VT100
case token_csi_pn('G' ) : _currentScreen->setCursorX (p ); break; //LINUX
case token_csi_pn('H' ) : _currentScreen->setCursorYX (p, q); break; //VT100
case token_csi_pn('I' ) : _currentScreen->tab (p ); break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment