Mercurial > hg > octave-lyh
annotate gui/src/OctaveLink.h @ 13518:bace956a3724
Put history model part into OctaveLink.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 19 Jul 2011 15:53:43 +0200 |
parents | 86adc9c4ec4b |
children | 35ecb6063c7b |
rev | line source |
---|---|
13501 | 1 /* |
2 * | |
3 * Copyright (C) 2007, 2008, 2009 John P. Swensen | |
4 * | |
13504
13e3d60aff2d
Replaced Quint with OctaveGUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13501
diff
changeset
|
5 * OctaveGUI - A graphical user interface for Octave |
13501 | 6 * Copyright (C) 2011 Jacob Dawid |
7 * jacob.dawid@googlemail.com | |
8 * This file is as a part of OctaveDE. | |
9 * | |
10 * Octave is free software; you can redistribute it and/or modify it | |
11 * under the terms of the GNU General Public License as published by the | |
12 * Free Software Foundation; either version 2, or (at your option) any | |
13 * later version. | |
14 * | |
15 * Octave is distributed in the hope that it will be useful, but WITHOUT | |
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
18 * for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with Octave; see the file COPYING. If not, write to the Free | |
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
23 * 02110-1301, USA. | |
24 * | |
25 * */ | |
26 | |
27 #ifndef OCTAVELINK_H | |
28 #define OCTAVELINK_H | |
29 | |
30 // Octave includes | |
31 #undef PACKAGE_BUGREPORT | |
32 #undef PACKAGE_NAME | |
33 #undef PACKAGE_STRING | |
34 #undef PACKAGE_TARNAME | |
35 #undef PACKAGE_VERSION | |
36 #undef PACKAGE_URL | |
37 #include <octave/config.h> | |
38 #include "octave/cmd-edit.h" | |
39 #include "octave/error.h" | |
40 #include "octave/file-io.h" | |
41 #include "octave/input.h" | |
42 #include "octave/lex.h" | |
43 #include "octave/load-path.h" | |
44 #include "octave/octave.h" | |
45 #include "octave/oct-hist.h" | |
46 #include "octave/oct-map.h" | |
47 #include "octave/oct-obj.h" | |
48 #include "octave/ops.h" | |
49 #include "octave/ov.h" | |
50 #include "octave/ov-usr-fcn.h" | |
51 #include "octave/symtab.h" | |
52 #include "octave/pt.h" | |
53 #include "octave/pt-eval.h" | |
54 #include "octave/config.h" | |
55 #include "octave/Range.h" | |
56 #include "octave/toplev.h" | |
57 #include "octave/procstream.h" | |
58 #include "octave/sighandlers.h" | |
59 #include "octave/debug.h" | |
60 #include "octave/sysdep.h" | |
61 #include "octave/ov.h" | |
62 #include "octave/unwind-prot.h" | |
63 #include "octave/utils.h" | |
64 #include "octave/variables.h" | |
65 | |
66 // Standard includes | |
67 #include <iostream> | |
68 #include <string> | |
69 #include <vector> | |
70 #include <readline/readline.h> | |
71 | |
72 // Qt includes | |
73 #include <QMutexLocker> | |
74 #include <QMutex> | |
75 #include <QFileInfo> | |
76 #include <QList> | |
77 #include <QString> | |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
78 #include <QStringList> |
13501 | 79 #include <QVector> |
80 #include <QSemaphore> | |
81 #include <QObject> | |
13518
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
82 #include <QStringListModel> |
13501 | 83 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
84 typedef symbol_table::symbol_record SymbolRecord; |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
85 typedef octave_value OctaveValue; |
13501 | 86 |
87 /** | |
88 * \class OctaveLink | |
89 * Manages a link to an octave instance. | |
90 */ | |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
91 class OctaveLink:QObject |
13501 | 92 { |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
93 Q_OBJECT |
13501 | 94 public: |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
95 static OctaveLink * |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
96 instance () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
97 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
98 return &m_singleton; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
99 } |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
100 static int |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
101 readlineEventHook (void); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
102 static QString |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
103 octaveValueAsQString (OctaveValue octaveValue); |
13501 | 104 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
105 /** |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
106 * Returns a copy of the current symbol table buffer. |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
107 * \return Copy of the current symbol table buffer. |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
108 */ |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
109 QList < SymbolRecord > currentSymbolTable (); |
13501 | 110 |
13518
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
111 void |
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
112 updateHistoryModel (); |
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
113 |
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
114 QStringListModel * |
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
115 historyModel (); |
13501 | 116 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
117 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
118 processOctaveServerData (); |
13501 | 119 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
120 /** |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
121 * Updates the current symbol table with new data |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
122 * from octave. |
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
123 */ |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
124 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
125 fetchSymbolTable (); |
13501 | 126 |
127 signals: | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
128 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
129 symbolTableChanged (); |
13501 | 130 |
131 private: | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
132 OctaveLink (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
133 ~OctaveLink (); |
13501 | 134 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
135 /** Variable related member variables. */ |
13513
e19c454ed485
Added version script for Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
136 QSemaphore * m_symbolTableSemaphore; |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
137 QList < SymbolRecord > m_symbolTableBuffer; |
13501 | 138 |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
139 /** History related member variables. */ |
13518
bace956a3724
Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13517
diff
changeset
|
140 QStringListModel *m_historyModel; |
13513
e19c454ed485
Added version script for Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
141 QSemaphore *m_historySemaphore; |
13517
86adc9c4ec4b
History deactivated.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13513
diff
changeset
|
142 QStringList m_historyBuffer; |
13513
e19c454ed485
Added version script for Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
143 int m_previousHistoryLength; |
e19c454ed485
Added version script for Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13506
diff
changeset
|
144 static OctaveLink m_singleton; |
13501 | 145 }; |
146 #endif // OCTAVELINK_H |