Mercurial > jwe > qt-gui-with-push-parser
view 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 |
line wrap: on
line source
#if ! defined (gui_main_h) #define gui_main_h 1 #include <iostream> #include <sstream> #include <string> #include <cstdlib> #include <cstring> #include <QApplication> #include <QTextDocument> #include <QTextEdit> namespace gui { class command_window : public QTextEdit { Q_OBJECT public: command_window (QWidget *p = nullptr); virtual ~command_window (void) = default; // Accept an input line, parse and possibly execute it. void accept (const std::string& line); // Redisplay current command line. void redisplay (void); void insert_at_end (const std::string& text); void emit_result (double value); signals: void result_available (double value); public slots: void handle_result (double value); protected: void keyPressEvent (QKeyEvent *event); int do_arrow_key (int arrow_key); // Retrieve a command from the history list and insert it on the // current command. void history (bool up); void erase_line (void); void insert_at_cursor (const std::string& text); void insert_line (const std::string& prompt, const std::string& line); int set_mark (void); void insert_result (double value); void scroll_to_bottom (void); // Child widgets: QTextDocument *m_buffer; int beg_mark; int prompt_mark; }; extern int main (int argc, char **argv); extern void emit_result (double value); } #endif