Commit 1fa50a4e authored by Nikita Sirgienko's avatar Nikita Sirgienko

[T8613] Add support for Octave and also move current directory for Octave...

[T8613] Add support for Octave and also move current directory for Octave session, loaded from file, to directory of the file
parent faacf1ce
Pipeline #33066 canceled with stage
......@@ -130,12 +130,41 @@ void OctaveSession::login()
evaluateExpression(autorunScripts, OctaveExpression::DeleteOnFinish, true);
updateVariables();
}
if (!m_worksheetPath.isEmpty())
{
static const QString mfilenameTemplate = QLatin1String(
"function retval = mfilename(arg_mem = \"\")\n"
"type_info=typeinfo(arg_mem);\n"
"if (strcmp(type_info, \"string\"))\n"
"if (strcmp(arg_mem, \"fullpath\"))\n"
"retval = \"%1\";\n"
"elseif (strcmp(arg_mem, \"fullpathext\"))\n"
"retval = \"%2\";\n"
"else\n"
"retval = \"script\";\n"
"endif\n"
"else\n"
"error(\"wrong type argument '%s'\", type_info)\n"
"endif\n"
"endfunction"
);
const QString& worksheetDirPath = QFileInfo(m_worksheetPath).absoluteDir().absolutePath();
const QString& worksheetPathWithoutExtension = m_worksheetPath.mid(0, m_worksheetPath.lastIndexOf(QLatin1Char('.')));
evaluateExpression(QLatin1String("cd ")+worksheetDirPath, OctaveExpression::DeleteOnFinish, true);
evaluateExpression(mfilenameTemplate.arg(worksheetPathWithoutExtension, m_worksheetPath), OctaveExpression::DeleteOnFinish, true);
}
changeStatus(Cantor::Session::Done);
emit loginDone();
qDebug()<<"login done";
}
void OctaveSession::setWorksheetPath(const QString& path)
{
m_worksheetPath = path;
}
void OctaveSession::logout()
{
qDebug()<<"logout";
......
......@@ -49,6 +49,7 @@ class OctaveSession : public Cantor::Session
Cantor::SyntaxHelpObject* syntaxHelpFor(const QString& cmd) override;
QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override;
void runFirstExpression() override;
void setWorksheetPath(const QString& path) override;
bool isIntegratedPlotsEnabled() const;
QString plotFilePrefixPath() const;
......@@ -67,6 +68,7 @@ class OctaveSession : public Cantor::Session
QString m_output;
QString m_plotFilePrefixPath;
QString m_worksheetPath;
bool m_isIntegratedPlotsEnabled; // Better move it in worksheet, like isCompletion, etc.
bool m_isIntegratedPlotsSettingsEnabled;
......
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