1 /*
2     SPDX-License-Identifier: GPL-2.0-or-later
3     SPDX-FileCopyrightText: 2009-2012 Alexander Rieder <alexanderrieder@gmail.com>
4     SPDX-FileCopyrightText: 2018-2021 by Alexander Semke (alexander.semke@web.de)
5 */
6 
7 #ifndef _MAXIMAEXPRESSION_H
8 #define _MAXIMAEXPRESSION_H
9 
10 #include "expression.h"
11 #include <QStringList>
12 #include <QFileSystemWatcher>
13 
14 class QTemporaryFile;
15 
16 class MaximaExpression : public Cantor::Expression
17 {
18   Q_OBJECT
19 
20 public:
21     explicit MaximaExpression(Cantor::Session*, bool internal = false);
22     ~MaximaExpression() override;
23 
24     void evaluate() override;
25     void interrupt() override;
26 
27     QString internalCommand() override;
28 
29     //Forces the status of this Expression to done
30     void forceDone();
31 
32     //reads from @param out until a prompt indicates that a new expression has started
33     bool parseOutput(QString&);
34     void parseError(const QString&);
35 
36     void addInformation(const QString&) override;
37 
38 private Q_SLOTS:
39     void imageChanged();
40 
41 private:
42     void parseResult(const QString&);
43 
44     QTemporaryFile* m_tempFile = nullptr;
45     QFileSystemWatcher m_fileWatch;
46     bool m_isHelpRequest = false;
47     bool m_isHelpRequestAdditional = false;
48     bool m_isPlot = false;
49     Cantor::Result* m_plotResult = nullptr;
50     int m_plotResultIndex = -1;
51     QString m_errorBuffer;
52     bool m_gotErrorContent = false;
53 };
54 
55 #endif /* _MAXIMAEXPRESSION_H */
56