Mercurial > jwe > qt-gui-with-push-parser
annotate gui-main.h @ 4:0e154787183d
new interpreter and qt_interpreter objects
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 22 May 2019 17:30:46 -0400 |
parents | b97ffa8e4019 |
children | 54edd85237ab |
rev | line source |
---|---|
2
b97ffa8e4019
multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents:
1
diff
changeset
|
1 #if ! defined (calc_gui_main_h) |
b97ffa8e4019
multiple inclusion guards in .h files
John W. Eaton <jwe@octave.org>
parents:
1
diff
changeset
|
2 #define calc_gui_main_h 1 |
0 | 3 |
4 #include <iostream> | |
5 #include <sstream> | |
6 #include <string> | |
7 | |
8 #include <cstdlib> | |
9 #include <cstring> | |
10 | |
11 #include <QApplication> | |
12 #include <QTextDocument> | |
13 #include <QTextEdit> | |
14 | |
4
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
15 #include "qt-interpreter.h" |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
16 |
0 | 17 namespace gui |
18 { | |
19 class command_window : public QTextEdit | |
20 { | |
21 Q_OBJECT | |
22 | |
23 public: | |
24 | |
25 command_window (QWidget *p = nullptr); | |
26 | |
27 virtual ~command_window (void) = default; | |
28 | |
29 // Accept an input line, parse and possibly execute it. | |
30 | |
31 void accept (const std::string& line); | |
32 | |
33 // Redisplay current command line. | |
34 | |
35 void redisplay (void); | |
36 | |
37 void insert_at_end (const std::string& text); | |
38 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
39 void emit_error (const std::string& msg); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
40 |
0 | 41 void emit_result (double value); |
42 | |
43 signals: | |
44 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
45 void input_char_available (int key); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
46 |
0 | 47 void result_available (double value); |
48 | |
49 public slots: | |
50 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
51 void handle_input_char (int key); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
52 |
0 | 53 void handle_result (double value); |
54 | |
55 protected: | |
56 | |
57 void keyPressEvent (QKeyEvent *event); | |
58 | |
59 int do_arrow_key (int arrow_key); | |
60 | |
61 // Retrieve a command from the history list and insert it on the | |
62 // current command. | |
63 | |
64 void history (bool up); | |
65 | |
66 void erase_line (void); | |
67 | |
68 void insert_at_cursor (const std::string& text); | |
69 | |
70 void insert_line (const std::string& prompt, const std::string& line); | |
71 | |
72 int set_mark (void); | |
73 | |
74 void insert_result (double value); | |
75 | |
76 void scroll_to_bottom (void); | |
77 | |
78 // Child widgets: | |
79 | |
80 QTextDocument *m_buffer; | |
81 | |
4
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
82 calc::qt_interpreter *m_interpreter; |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
83 |
0 | 84 int beg_mark; |
85 int prompt_mark; | |
86 }; | |
87 | |
88 extern int main (int argc, char **argv); | |
89 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
90 extern void emit_error (const std::string& msg); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
91 |
0 | 92 extern void emit_result (double value); |
4
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
93 |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
94 extern int available_char; |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
95 extern command_window *calc_interaction_window; |
0 | 96 } |
97 | |
98 #endif |