Commit 62f956b7 authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Tomaz Canabrava
Browse files

Add support for DECSTR (Soft Terminal Reset)

DECSTR is a level 2 control (VT2xx and up), and is to be used instead of
RIS (Reset to Initial State), which can initiate a self-test and drop
the connection on some hardware terminals.

BUG: 134892
parent aeeb6ccf
Pipeline #144475 passed with stage
in 2 minutes and 2 seconds
......@@ -175,8 +175,10 @@ public:
*/
virtual void clearEntireScreen() = 0;
/** Resets the state of the terminal. */
virtual void reset() = 0;
/** Resets the state of the terminal.
*
* @param softReset The reset was initiated by DECSTR */
virtual void reset(bool softReset = false) = 0;
/**
* Returns true if the active terminal program is interested in Mouse
......
......@@ -782,12 +782,24 @@ int Screen::getScreenLineColumns(const int line) const
return _columns;
}
void Screen::reset()
void Screen::reset(bool softReset)
{
// Clear screen, but preserve the current line
scrollUp(0, _cuY);
_cuY = 0;
_cuX = 0;
if (!softReset) {
scrollUp(0, _cuY);
_cuY = 0;
_cuX = 0;
resetMode(MODE_Screen); // screen not inverse
resetMode(MODE_NewLine);
initTabStops();
if (_hasGraphics) {
delPlacements();
_currentTerminalDisplay->update();
}
}
_currentModes[MODE_Origin] = 0;
_savedModes[MODE_Origin] = 0;
......@@ -799,8 +811,6 @@ void Screen::reset()
saveMode(MODE_Insert); // overstroke
setMode(MODE_Cursor); // cursor visible
resetMode(MODE_Screen); // screen not inverse
resetMode(MODE_NewLine);
_topMargin = 0;
_bottomMargin = _lines - 1;
......@@ -808,14 +818,12 @@ void Screen::reset()
// Other terminal emulators reset the entire scroll history during a reset
// setScroll(getScroll(), false);
initTabStops();
setDefaultRendition();
saveCursor();
if (_hasGraphics) {
delPlacements();
_currentTerminalDisplay->update();
}
// DECSTR homes the saved cursor even though it doesn't home the current cursor
_savedState.cursorColumn = 0;
_savedState.cursorLine = 0;
}
void Screen::backspace()
......
......@@ -360,7 +360,7 @@ public:
* If @p clearScreen is true then the screen contents are erased entirely,
* otherwise they are unaltered.
*/
void reset();
void reset(bool softReset = false);
/**
* Displays a new character at the current cursor position.
......
......@@ -93,18 +93,26 @@ void Vt102Emulation::clearEntireScreen()
bufferedUpdate();
}
void Vt102Emulation::reset()
void Vt102Emulation::reset(bool softReset)
{
// Save the current codec so we can set it later.
// Ideally we would want to use the profile setting
const QTextCodec *currentCodec = codec();
resetTokenizer();
resetModes();
if (softReset) {
resetMode(MODE_AppCuKeys);
saveMode(MODE_AppCuKeys);
resetMode(MODE_AppKeyPad);
saveMode(MODE_AppKeyPad);
} else {
resetModes();
}
resetCharset(0);
_screen[0]->reset();
_screen[0]->reset(softReset);
resetCharset(1);
_screen[1]->reset();
_screen[1]->reset(softReset);
if (currentCodec != nullptr) {
setCodec(currentCodec);
......@@ -1262,8 +1270,8 @@ void Vt102Emulation::processToken(int token, int p, int q)
case token_csi_psp('q', 5) : Q_EMIT setCursorStyleRequest(Enum::IBeamCursor, true); break;
case token_csi_psp('q', 6) : Q_EMIT setCursorStyleRequest(Enum::IBeamCursor, false); break;
//FIXME: weird DEC reset sequence
case token_csi_pe('p' ) : /* IGNORED: reset ( ) */ break;
// DECSTR (Soft Terminal Reset)
case token_csi_pe('p' ) : reset(true); break; //VT220
//FIXME: when changing between vt52 and ansi mode evtl do some resetting.
case token_vt52('A' ) : _currentScreen->cursorUp ( 1); break; //VT52
......
......@@ -73,7 +73,7 @@ public:
// reimplemented from Emulation
void clearEntireScreen() override;
void reset() override;
void reset(bool softReset = false) override;
char eraseChar() const override;
public Q_SLOTS:
......
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