Mercurial > octave
diff libgui/src/command-widget.h @ 31067:5261a81765b0
merge input and output of exp. terminal widget into one widget
* command-widget.cc (command_widget): remove obsolete elements, use
new class console as terminal, update initializations;
(init_command_prompt): display the first prompt, this function is
called when the interpreter is ready (via main_window);
(update_prompt): prompt is a QString now;
(insert_interpreter_output): use m_console instead of m_output_display;
(accept_input_line): moved to console;
(process_input_line): string of input line is passed as argument,
a new prompt is provided when interpreter is ready
(notice_settings): update for m_console, remove color and configuration
of obsolete line edit
(console::console): initializations, create and set QTextDocument;
(console::new_command_line): Prepare a new command line with prompt;
(console::accept_command_line): get input string and pass it to
m_command_widget for processing;
(console::append_block): append a text block to the document;
(console::keyPressEvent): re-implement key event for filtering
return, on which accept_input_line is called
* command-widget.h: new class console, update some function arguments
* main-window.cc (handle_octave_ready) call init_command_prompt of
terminal_dock_widget
* terminal-dock-widget.cc (init_command_prompt): new function calling
related function of the command widget
* terminal-dock-widget.h: new function init_command_prompt
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sat, 04 Jun 2022 21:52:20 +0200 |
parents | 796f54d4ddbf |
children | 0b402f523f09 |
line wrap: on
line diff
--- a/libgui/src/command-widget.h Sat Jun 04 00:12:55 2022 +0200 +++ b/libgui/src/command-widget.h Sat Jun 04 21:52:20 2022 +0200 @@ -27,6 +27,7 @@ #define octave_command_widget_h 1 #include <QWidget> +#include <QTextEdit> #include "octave-qobject.h" #include "gui-settings.h" @@ -34,11 +35,40 @@ class QLabel; class QLineEdit; class QStrung; -class QTextBrowser; +class QTextEdit; namespace octave { class base_qobject; + class command_widget; + + class console : public QTextEdit + { + Q_OBJECT + + public: + + console (command_widget *p); + + public slots: + + void new_command_line (void); + + protected: + + void keyPressEvent (QKeyEvent *e); + + private: + + void accept_command_line (void); + + void append_block (void); + + int m_command_block_number; + command_widget *m_command_widget; + QTextDocument *m_document; + + }; class command_widget : public QWidget { @@ -48,6 +78,10 @@ command_widget (base_qobject& oct_qobj, QWidget *p); + void init_command_prompt (); + + QString prompt (void); + signals: void clear_line_edit (void); @@ -59,25 +93,23 @@ void interpreter_event (const fcn_callback& fcn); void interpreter_event (const meth_callback& meth); + void new_command_line_signal (void); + public slots: + void process_input_line (const QString& input_line); + void update_prompt (const QString& prompt); void insert_interpreter_output (const QString& msg); void notice_settings (const gui_settings *settings); - protected slots: - - void accept_input_line (void); - private: bool m_incomplete_parse; - QLabel *m_prompt; - QLineEdit *m_line_edit; - QTextBrowser *m_output_display; - QColor m_input_color; + QString m_prompt; + console *m_console; }; }