Changeset View
Changeset View
Standalone View
Standalone View
src/backends/octave/octavesession.h
Show All 26 Lines | |||||
27 | #include <QPointer> | 27 | #include <QPointer> | ||
28 | 28 | | |||
29 | namespace Cantor { | 29 | namespace Cantor { | ||
30 | class DefaultVariableModel; | 30 | class DefaultVariableModel; | ||
31 | } | 31 | } | ||
32 | 32 | | |||
33 | class KDirWatch; | 33 | class KDirWatch; | ||
34 | class OctaveExpression; | 34 | class OctaveExpression; | ||
35 | class OctaveVariableModel; | ||||
35 | class KProcess; | 36 | class KProcess; | ||
36 | 37 | | |||
37 | 38 | | |||
38 | class OctaveSession : public Cantor::Session | 39 | class OctaveSession : public Cantor::Session | ||
39 | { | 40 | { | ||
40 | Q_OBJECT | 41 | Q_OBJECT | ||
41 | public: | 42 | public: | ||
42 | explicit OctaveSession(Cantor::Backend* backend); | 43 | explicit OctaveSession(Cantor::Backend* backend); | ||
43 | ~OctaveSession() override = default; | 44 | ~OctaveSession() override = default; | ||
44 | void interrupt() override; | 45 | void interrupt() override; | ||
45 | Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior finishingBehavior = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; | 46 | Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior finishingBehavior = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; | ||
46 | void logout() override; | 47 | void logout() override; | ||
47 | void login() override; | 48 | void login() override; | ||
48 | Cantor::CompletionObject* completionFor(const QString& cmd, int index=-1) override; | 49 | Cantor::CompletionObject* completionFor(const QString& cmd, int index=-1) override; | ||
49 | Cantor::SyntaxHelpObject* syntaxHelpFor(const QString& cmd) override; | 50 | Cantor::SyntaxHelpObject* syntaxHelpFor(const QString& cmd) override; | ||
50 | QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override; | 51 | QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override; | ||
51 | QAbstractItemModel* variableModel() override; | 52 | QAbstractItemModel* variableModel() override; | ||
52 | void runFirstExpression() override; | 53 | void runFirstExpression() override; | ||
53 | 54 | | |||
54 | Q_SIGNALS: | | |||
55 | void variablesChanged(); | | |||
56 | | ||||
57 | private: | 55 | private: | ||
58 | const static QRegExp PROMPT_UNCHANGEABLE_COMMAND; | 56 | const static QRegExp PROMPT_UNCHANGEABLE_COMMAND; | ||
59 | 57 | | |||
60 | private: | 58 | private: | ||
61 | KProcess* m_process; | 59 | KProcess* m_process; | ||
62 | QTextStream m_stream; | 60 | QTextStream m_stream; | ||
63 | QRegExp m_prompt; | 61 | QRegExp m_prompt; | ||
64 | QRegExp m_subprompt; | 62 | QRegExp m_subprompt; | ||
65 | int m_previousPromptNumber; | 63 | int m_previousPromptNumber; | ||
66 | 64 | | |||
67 | KDirWatch* m_watch; | 65 | KDirWatch* m_watch; | ||
68 | QString m_tempDir; | 66 | QString m_tempDir; | ||
69 | bool m_syntaxError; | 67 | bool m_syntaxError; | ||
68 | bool m_needUpdate; | ||||
70 | 69 | | |||
71 | QString m_output; | 70 | QString m_output; | ||
72 | 71 | | |||
73 | Cantor::DefaultVariableModel* m_variableModel; | 72 | OctaveVariableModel* m_variableModel; | ||
74 | 73 | | |||
75 | private: | 74 | private: | ||
76 | void readFromOctave(QByteArray data); | 75 | void readFromOctave(QByteArray data); | ||
77 | bool isDoNothingCommand(const QString& command); | 76 | bool isDoNothingCommand(const QString& command); | ||
78 | bool isSpecialOctaveCommand(const QString& command); | 77 | bool isSpecialOctaveCommand(const QString& command); | ||
79 | 78 | | |||
80 | private Q_SLOTS: | 79 | private Q_SLOTS: | ||
81 | void readOutput(); | 80 | void readOutput(); | ||
82 | void readError(); | 81 | void readError(); | ||
83 | void currentExpressionStatusChanged(Cantor::Expression::Status status); | 82 | void currentExpressionStatusChanged(Cantor::Expression::Status status); | ||
84 | void processError(); | 83 | void processError(); | ||
85 | void plotFileChanged(const QString& filename); | 84 | void plotFileChanged(const QString& filename); | ||
86 | void runSpecificCommands(); | 85 | void runSpecificCommands(); | ||
87 | }; | 86 | }; | ||
88 | 87 | | |||
89 | #endif // OCTAVESESSION_H | 88 | #endif // OCTAVESESSION_H |