Mercurial > jwe > qt-gui-with-push-parser
comparison gui-main.h @ 0:dff751fb985c
initial revision
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 13 May 2019 09:48:06 -0500 |
parents | |
children | 08df60a01bc1 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:dff751fb985c |
---|---|
1 #if ! defined (gui_main_h) | |
2 #define gui_main_h 1 | |
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 | |
15 namespace gui | |
16 { | |
17 class command_window : public QTextEdit | |
18 { | |
19 Q_OBJECT | |
20 | |
21 public: | |
22 | |
23 command_window (QWidget *p = nullptr); | |
24 | |
25 virtual ~command_window (void) = default; | |
26 | |
27 // Accept an input line, parse and possibly execute it. | |
28 | |
29 void accept (const std::string& line); | |
30 | |
31 // Redisplay current command line. | |
32 | |
33 void redisplay (void); | |
34 | |
35 void insert_at_end (const std::string& text); | |
36 | |
37 void emit_result (double value); | |
38 | |
39 signals: | |
40 | |
41 void result_available (double value); | |
42 | |
43 public slots: | |
44 | |
45 void handle_result (double value); | |
46 | |
47 protected: | |
48 | |
49 void keyPressEvent (QKeyEvent *event); | |
50 | |
51 int do_arrow_key (int arrow_key); | |
52 | |
53 // Retrieve a command from the history list and insert it on the | |
54 // current command. | |
55 | |
56 void history (bool up); | |
57 | |
58 void erase_line (void); | |
59 | |
60 void insert_at_cursor (const std::string& text); | |
61 | |
62 void insert_line (const std::string& prompt, const std::string& line); | |
63 | |
64 int set_mark (void); | |
65 | |
66 void insert_result (double value); | |
67 | |
68 void scroll_to_bottom (void); | |
69 | |
70 // Child widgets: | |
71 | |
72 QTextDocument *m_buffer; | |
73 | |
74 int beg_mark; | |
75 int prompt_mark; | |
76 }; | |
77 | |
78 extern int main (int argc, char **argv); | |
79 | |
80 extern void emit_result (double value); | |
81 } | |
82 | |
83 #endif |