aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Semke <[email protected]>2018-03-25 19:15:38 +0200
committerAlexander Semke <[email protected]>2018-04-01 12:33:34 +0200
commitc7b8212a01a7c4c9173dc0a73158164bfbc059ab (patch)
tree4aa41d39c7f2d914ac798b7a8d238e061228c8de
parentc484f3d037273487cb76d9dcc2ac90a76f765558 (diff)
[Octave] fixed the initial parsing of Octave's promt.
-rw-r--r--src/backends/octave/octavesession.cpp37
-rw-r--r--src/worksheet.cpp3
2 files changed, 18 insertions, 22 deletions
diff --git a/src/backends/octave/octavesession.cpp b/src/backends/octave/octavesession.cpp
index 55700b2..5b21949 100644
--- a/src/backends/octave/octavesession.cpp
+++ b/src/backends/octave/octavesession.cpp
@@ -92,20 +92,6 @@ void OctaveSession::login()
args << QLatin1String("--eval");
args << QLatin1String("____TMP_DIR____ = tempdir");
- m_process->setProgram ( OctaveSettings::path().toLocalFile(), args );
- qDebug() << "starting " << m_process->program();
- m_process->setOutputChannelMode ( KProcess::SeparateChannels );
-
-
- m_process->start();
- m_process->waitForStarted();
- m_process->waitForReadyRead();
- qDebug()<<m_process->readAllStandardOutput();
-
- connect ( m_process, SIGNAL ( readyReadStandardOutput() ), SLOT ( readOutput() ) );
- connect ( m_process, SIGNAL ( readyReadStandardError() ), SLOT ( readError() ) );
- connect ( m_process, SIGNAL ( error ( QProcess::ProcessError ) ), SLOT ( processError() ) );
-
if (OctaveSettings::integratePlots())
{
m_watch = new KDirWatch(this);
@@ -113,6 +99,19 @@ void OctaveSession::login()
connect (m_watch, SIGNAL(dirty(QString)), SLOT(plotFileChanged(QString)) );
}
+ // connect the signal and slots prior to staring octave to make sure we handle the very first output
+ // in parserOutput() to determine the temp folder and the format of the promt
+ connect ( m_process, SIGNAL ( readyReadStandardOutput() ), SLOT ( readOutput() ) );
+ connect ( m_process, SIGNAL ( readyReadStandardError() ), SLOT ( readError() ) );
+ connect ( m_process, SIGNAL ( error ( QProcess::ProcessError ) ), SLOT ( processError() ) );
+
+ m_process->setProgram ( OctaveSettings::path().toLocalFile(), args );
+ qDebug() << "starting " << m_process->program();
+ m_process->setOutputChannelMode ( KProcess::SeparateChannels );
+ m_process->start();
+ m_process->waitForStarted();
+ m_process->waitForReadyRead();
+
if(!OctaveSettings::self()->autorunScripts().isEmpty()){
QString autorunScripts = OctaveSettings::self()->autorunScripts().join(QLatin1String("\n"));
@@ -227,19 +226,15 @@ void OctaveSession::readOutput()
}
QString line = QString::fromLocal8Bit(m_process->readLine());
qDebug()<<"start parsing " << " " << line;
- if (!m_currentExpression)
+ if (!m_currentExpression || m_prompt.isEmpty())
{
+ // no expression is available, we're parsing the first output of octave after the start
+ // -> determine the location of the temporary folder and the format of octave's promt
if (m_prompt.isEmpty() && line.contains(QLatin1String(":1>")))
{
qDebug() << "Found Octave prompt:" << line;
line.replace(QLatin1String(":1"), QLatin1String(":[0-9]+"));
m_prompt.setPattern(line);
- changeStatus(Done);
- if (!m_expressionQueue.isEmpty())
- {
- runExpression(m_expressionQueue.dequeue());
- }
- emit loginDone();
}
else if (line.contains(QLatin1String("____TMP_DIR____")))
{
diff --git a/src/worksheet.cpp b/src/worksheet.cpp
index 2ee0b79..ac0d8fc 100644
--- a/src/worksheet.cpp
+++ b/src/worksheet.cpp
@@ -763,7 +763,8 @@ void Worksheet::enableHighlighting(bool highlight)
if(m_highlighter)
m_highlighter->deleteLater();
- //octave highligther fetches the funcitons names from ocate -> we need to login here
+ //octave highligther fetches the function names from octave -> we need to login here
+ //TODO: re-design this later - highlighting should also be possible in the absence of the actual backend
if (!m_loginDone && m_session->backend()->name() == QLatin1String("Octave"))
loginToSession();