Mercurial > jwe > qt-gui-with-push-parser
annotate gui-main.h @ 7:04867eba6428
function objects and signals/slots for errors and results
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 23 May 2019 09:27:09 -0400 |
parents | 54edd85237ab |
children | 7c4b04a6346d |
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 insert_at_end (const std::string& text); | |
36 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
37 void emit_error (const std::string& msg); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
38 |
0 | 39 void emit_result (double value); |
40 | |
41 signals: | |
42 | |
1
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
43 void input_char_available (int key); |
08df60a01bc1
debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents:
0
diff
changeset
|
44 |
7
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
5
diff
changeset
|
45 void accept_line_signal (const QString& line); |
0 | 46 |
7
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
5
diff
changeset
|
47 void redisplay_signal (void); |
5
54edd85237ab
use signal to send input to qt interpreter object
John W. Eaton <jwe@octave.org>
parents:
4
diff
changeset
|
48 |
0 | 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 |
7
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
5
diff
changeset
|
53 void handle_error (const QString& msg); |
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
5
diff
changeset
|
54 |
0 | 55 void handle_result (double value); |
56 | |
7
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
5
diff
changeset
|
57 void redisplay (void); |
04867eba6428
function objects and signals/slots for errors and results
John W. Eaton <jwe@octave.org>
parents:
5
diff
changeset
|
58 |
0 | 59 protected: |
60 | |
61 void keyPressEvent (QKeyEvent *event); | |
62 | |
63 int do_arrow_key (int arrow_key); | |
64 | |
65 // Retrieve a command from the history list and insert it on the | |
66 // current command. | |
67 | |
68 void history (bool up); | |
69 | |
70 void erase_line (void); | |
71 | |
72 void insert_at_cursor (const std::string& text); | |
73 | |
74 void insert_line (const std::string& prompt, const std::string& line); | |
75 | |
76 int set_mark (void); | |
77 | |
78 void insert_result (double value); | |
79 | |
80 void scroll_to_bottom (void); | |
81 | |
82 // Child widgets: | |
83 | |
84 QTextDocument *m_buffer; | |
85 | |
4
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
86 calc::qt_interpreter *m_interpreter; |
0e154787183d
new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents:
2
diff
changeset
|
87 |
0 | 88 int beg_mark; |
89 int prompt_mark; | |
90 }; | |
91 | |
92 extern int main (int argc, char **argv); | |
93 } | |
94 | |
95 #endif |