annotate libgui/src/command-widget.h @ 29787:b4d2fa28d1d4

allow terminal window to be opened from command line * command-widget.h, command-widget.cc (command_widget::update_prompt): New slot. (command_widget::insert_interpreter_output): Now public. (command_widget::command_widget): Don't connect to signals from parent object here. * octave-qobject.h, octave-qobject.cc (base_qobject::m_terminal_widget): New data member. (base_qobject::terminal_widget): New function. Make (command_widget, QTerminal)/base_qobject signal/slot connections here instead of in main_window constructor. (base_qobject::show_terminal_window): New slot. (base_qobject::base_qobject): Connect qt_interpreter_events::show_terminal_window_signal to base_qobject::show_terminal_window slot. (base_qobject::~base_qobject): Close and delete terminal widget. * main-window.h, main-window.cc (main_window::main_window): Acquire m_command_window from base_qobject instead of constructing here. * terminal-dock-widget.cc (terminal_dock_widget::terminal_dock_widget): Make dock widget/terminal widget signal/slot connections here instead of in main window constructor. Call make_window if parent object is nullptr. * event-manager.h, event-manager.cc (F__event_manager_show_terminal_window__): New function. (interpreter_events::show_terminal_window): New virtual function. (event_manager::show_terminal_window): New function. * qt-interpreter-events.h, qt-interpreter-events.cc (qt_interpreter_events::show_terminal_window): New signal (qt_interpreter_events::show_terminal_window): New function.
author John W. Eaton <jwe@octave.org>
date Sat, 19 Jun 2021 14:34:07 -0400
parents 63c515ff762f
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 ////////////////////////////////////////////////////////////////////////
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 //
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 // Copyright (C) 2021 The Octave Project Developers
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 //
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 // distribution or <https://octave.org/copyright/>.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 //
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 // This file is part of Octave.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 //
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 // under the terms of the GNU General Public License as published by
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 // (at your option) any later version.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 //
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 // GNU General Public License for more details.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 //
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 // You should have received a copy of the GNU General Public License
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 // along with Octave; see the file COPYING. If not, see
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 // <https://www.gnu.org/licenses/>.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 //
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 ////////////////////////////////////////////////////////////////////////
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if ! defined (octave_command_widget_h)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #define octave_command_widget_h 1
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <QWidget>
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "octave-qobject.h"
29525
d6b2d9f9e1e0 use terminal settings for the experimental command widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29503
diff changeset
32 #include "gui-settings.h"
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 class QLabel;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 class QLineEdit;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 class QStrung;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 class QTextBrowser;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 namespace octave
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 class base_qobject;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 class command_widget : public QWidget
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 Q_OBJECT
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 public:
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 command_widget (base_qobject& oct_qobj, QWidget *p);
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 signals:
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 void clear_line_edit (void);
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54
29786
63c515ff762f eliminate more signal connections to parent objects
John W. Eaton <jwe@octave.org>
parents: 29525
diff changeset
55 void interpreter_pause (void);
63c515ff762f eliminate more signal connections to parent objects
John W. Eaton <jwe@octave.org>
parents: 29525
diff changeset
56 void interpreter_resume (void);
63c515ff762f eliminate more signal connections to parent objects
John W. Eaton <jwe@octave.org>
parents: 29525
diff changeset
57 void interpreter_stop (void);
63c515ff762f eliminate more signal connections to parent objects
John W. Eaton <jwe@octave.org>
parents: 29525
diff changeset
58
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 void interpreter_event (const fcn_callback& fcn);
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 void interpreter_event (const meth_callback& meth);
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
29525
d6b2d9f9e1e0 use terminal settings for the experimental command widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29503
diff changeset
62 public slots:
d6b2d9f9e1e0 use terminal settings for the experimental command widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29503
diff changeset
63
29787
b4d2fa28d1d4 allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents: 29786
diff changeset
64 void update_prompt (const QString& prompt);
b4d2fa28d1d4 allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents: 29786
diff changeset
65
b4d2fa28d1d4 allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents: 29786
diff changeset
66 void insert_interpreter_output (const QString& msg);
b4d2fa28d1d4 allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents: 29786
diff changeset
67
29525
d6b2d9f9e1e0 use terminal settings for the experimental command widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29503
diff changeset
68 void notice_settings (const gui_settings *settings);
d6b2d9f9e1e0 use terminal settings for the experimental command widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29503
diff changeset
69
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 protected slots:
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 void accept_input_line (void);
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 private:
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 bool m_incomplete_parse;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 QLabel *m_prompt;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 QLineEdit *m_line_edit;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 QTextBrowser *m_output_display;
29525
d6b2d9f9e1e0 use terminal settings for the experimental command widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29503
diff changeset
80 QColor m_input_color;
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 };
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 #endif