Commit 938a020e authored by Alexander Semke's avatar Alexander Semke
Browse files

[R] properly show the results of R's "help commands" appropos(), vignette(),...

[R] properly show the results of R's "help commands" appropos(), vignette(), demos() and help.search().
parent 1b7c9c10
...@@ -28,7 +28,15 @@ m_isHelpRequest(false) ...@@ -28,7 +28,15 @@ m_isHelpRequest(false)
void RExpression::evaluate() void RExpression::evaluate()
{ {
if(command().startsWith(QLatin1Char('?')) || command().startsWith(QLatin1String("help("))) const auto& cmd = command();
//check whether we need to interpret the current command as a help command.
//see https://www.r-project.org/help.html for the list of different ways to get help in R.
if(cmd.startsWith(QLatin1Char('?')) || cmd.startsWith(QStringLiteral("help("))
|| cmd.startsWith(QStringLiteral("apropos("))
|| cmd.startsWith(QStringLiteral("vignette("))
|| cmd == QStringLiteral("demos()")
|| cmd.startsWith(QStringLiteral("help.search(")) )
m_isHelpRequest=true; m_isHelpRequest=true;
else else
m_isHelpRequest=false; m_isHelpRequest=false;
...@@ -46,7 +54,12 @@ void RExpression::parseOutput(const QString& text) ...@@ -46,7 +54,12 @@ void RExpression::parseOutput(const QString& text)
{ {
//qDebug() << "output text: " << text; //qDebug() << "output text: " << text;
if (!text.trimmed().isEmpty()) if (!text.trimmed().isEmpty())
addResult(new Cantor::TextResult(text)); {
if(m_isHelpRequest)
addResult(new Cantor::HelpResult(text));
else
addResult(new Cantor::TextResult(text));
}
setStatus(Cantor::Expression::Done); setStatus(Cantor::Expression::Done);
} }
......
...@@ -145,8 +145,7 @@ void RSession::expressionFinished(int returnCode, const QString& text, const QSt ...@@ -145,8 +145,7 @@ void RSession::expressionFinished(int returnCode, const QString& text, const QSt
if (expr->status() == Cantor::Expression::Interrupted) if (expr->status() == Cantor::Expression::Interrupted)
return; return;
if (!files.isEmpty()) expr->showFilesAsResult(files);
expr->showFilesAsResult(files);
if(returnCode==RExpression::SuccessCode) if(returnCode==RExpression::SuccessCode)
expr->parseOutput(text); expr->parseOutput(text);
......
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