Commit 29bff837 authored by Matan Ziv-Av's avatar Matan Ziv-Av Committed by Kurt Hindenburg
Browse files

Track error status of the command in the line properties.

parent d920a41a
......@@ -2346,6 +2346,26 @@ void Screen::setReplMode(int mode)
}
}
void Screen::setExitCode(int /*exitCode*/)
{
int y = _cuY - 1;
while (y >= 0) {
_lineProperties[y].flags.f.error = 1;
if (_lineProperties[y].flags.f.prompt_start) {
return;
}
y--;
}
while (y > -_history->getLines()) {
LineProperty prop = _history->getLineProperty(y + _history->getLines());
prop.flags.f.error = 1;
_history->setLineProperty(y + _history->getLines(), prop);
if (prop.flags.f.prompt_start) {
return;
}
y--;
}
}
void Screen::fillWithDefaultChar(Character *dest, int count)
{
std::fill_n(dest, count, Screen::DefaultChar);
......
......@@ -579,6 +579,7 @@ public:
* REPL_OUTPUT
*/
void setReplMode(int mode);
void setExitCode(int exitCode);
/** Return true if semantic shell integration is in use. */
bool hasRepl() const
{
......
......@@ -1067,7 +1067,14 @@ void Vt102Emulation::processSessionAttributeRequest(const int tokenSize, const u
auto list = value.split(QLatin1Char(';'));
for (int i = 1; i < list.size(); i++) {
int eq = list.at(i).indexOf(QLatin1Char('='));
if (eq > 0) {
if (i == 1 && value[0] == QLatin1Char('D')) {
// Special case - exit code without '='
params[QLatin1String("exit_code")] = list.at(1);
int exitCode = list.at(1).toInt();
if (exitCode) {
_currentScreen->setExitCode(exitCode);
}
} else if (eq > 0) {
params[list.at(i).mid(0, eq)] = list.at(i).mid(eq + 1);
}
}
......
......@@ -41,6 +41,7 @@ public:
uint output_start : 1;
uint input_start : 1;
uint output : 1;
uint error : 1;
} f;
} flags;
qint16 length;
......
Supports Markdown
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