Mercurial > jwe > qt-gui-with-push-parser
annotate gui-main.h @ 5:54edd85237ab
use signal to send input to qt interpreter object
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 22 May 2019 18:07:37 -0400 |
parents | 0e154787183d |
children | 04867eba6428 |
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 | |
5
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
31 void accept_line (const std::string& line); |
0 | 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 | |
5
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
49 void accept_line_signal (const QString& line); |
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
50 |
0 | 51 public slots: |
52 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
53 void handle_input_char (int key); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
54 |
0 | 55 void handle_result (double value); |
56 | |
57 protected: | |
58 | |
59 void keyPressEvent (QKeyEvent *event); | |
60 | |
61 int do_arrow_key (int arrow_key); | |
62 | |
63 // Retrieve a command from the history list and insert it on the | |
64 // current command. | |
65 | |
66 void history (bool up); | |
67 | |
68 void erase_line (void); | |
69 | |
70 void insert_at_cursor (const std::string& text); | |
71 | |
72 void insert_line (const std::string& prompt, const std::string& line); | |
73 | |
74 int set_mark (void); | |
75 | |
76 void insert_result (double value); | |
77 | |
78 void scroll_to_bottom (void); | |
79 | |
80 // Child widgets: | |
81 | |
82 QTextDocument *m_buffer; | |
83 | |
4
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
84 calc::qt_interpreter *m_interpreter; |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
85 |
0 | 86 int beg_mark; |
87 int prompt_mark; | |
88 }; | |
89 | |
90 extern int main (int argc, char **argv); | |
91 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
92 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
|
93 |
0 | 94 extern void emit_result (double value); |
95 } | |
96 | |
97 #endif |