GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
QTerminal.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2012-2019 Michael Goffioul.
4 Copyright (C) 2012-2019 Jacob Dawid.
5 
6 This file is part of QTerminal.
7 
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program. If not,
20 see <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifndef QTERMINAL_H
25 #define QTERMINAL_H
26 
27 #include <QColor>
28 #include <QList>
29 #include <QPoint>
30 #include <QString>
31 #include <QWidget>
32 
33 // For now, we need to use the following #include and using statement
34 // for the signal/slot macros. Could maybe change later when using
35 // Qt5-style signal/slot connections.
36 #include "gui-settings.h"
37 
38 using octave::gui_settings;
39 
40 namespace octave
41 {
42  class base_qobject;
43 }
44 
45 class QMenu;
46 class QAction;
47 
48 class QTerminal : public QWidget
49 {
50  Q_OBJECT
51 
52 public:
53 
54  static QTerminal *
55  create (octave::base_qobject& oct_qobj, QWidget *xparent);
56 
57  virtual ~QTerminal (void) = default;
58 
59  virtual void setTerminalFont (const QFont& font) = 0;
60 
61  virtual void setSize (int h, int v) = 0;
62 
63  virtual void sendText (const QString& text) = 0;
64 
65  virtual QString selectedText () = 0;
66 
67  virtual void has_extra_interrupt (bool extra) = 0;
68 
69  virtual QList<QAction*> get_hotspot_actions (const QPoint&)
70  { return QList<QAction*> (); }
71 
73  {
77  };
78 
79  virtual void setCursorType (CursorType type, bool blinking)
80  {
81  // Provide empty default impl in order to avoid conflicts with the
82  // win impl.
83 
84  Q_UNUSED (type);
85  Q_UNUSED (blinking);
86  }
87 
88  virtual void setBackgroundColor (const QColor& color) = 0;
89 
90  virtual void setForegroundColor (const QColor& color) = 0;
91 
92  virtual void setSelectionColor (const QColor& color) = 0;
93 
94  virtual void setCursorColor (bool useForegroundColor,
95  const QColor& color) = 0;
96 
97  virtual void setScrollBufferSize(int value=1000) = 0;
98 
99 signals:
100 
101  void report_status_message (const QString&);
102 
103  void interrupt_signal (void);
104 
105  void edit_mfile_request (const QString&, int);
106 
107  void show_doc_signal (const QString&);
108 
109  void execute_command_in_terminal_signal (const QString&);
110 
111  void request_edit_mfile_signal (const QString&, int);
112 
113  void request_open_file_signal (const QString&, const QString&, int);
114 
115  void set_screen_size_signal (int, int);
116 
118 
119 public slots:
120 
121  virtual void copyClipboard (void) = 0;
122 
123  virtual void pasteClipboard (void) = 0;
124 
125  virtual void selectAll (void) = 0;
126 
127  virtual void handleCustomContextMenuRequested (const QPoint& at);
128 
129  void notice_settings (const gui_settings *settings);
130 
131  virtual void init_terminal_size (void) { }
132 
133  void terminal_interrupt (void) { emit interrupt_signal (); }
134 
135  void run_selection (void);
136 
137  void edit_file (void);
138 
139  void edit_selected (void);
140 
141  void help_on_expression (void);
142 
143  void doc_on_expression (void);
144 
145  virtual void handle_visibility_changed (bool) { };
146 
147 protected:
148 
149  QTerminal (octave::base_qobject& oct_qobj, QWidget *xparent = nullptr)
150  : QWidget (xparent), m_octave_qobj (oct_qobj) { }
151 
152  void construct (octave::base_qobject& oct_qobj);
153 
154 private:
155 
156  octave::base_qobject& m_octave_qobj;
157 
159  QAction * _copy_action;
160  QAction * _paste_action;
161  QAction * _selectall_action;
162  QAction * _edit_action;
167 
169  QAction *_nop_action;
170 };
171 
172 #endif // QTERMINAL_H
void doc_on_expression(void)
Definition: QTerminal.cc:195
void interrupt_signal(void)
void report_status_message(const QString &)
virtual void handle_visibility_changed(bool)
Definition: QTerminal.h:145
QAction * m_help_selected_action
Definition: QTerminal.h:165
virtual QString selectedText()=0
QAction * _edit_action
Definition: QTerminal.h:162
QAction * _paste_action
Definition: QTerminal.h:160
void run_selection(void)
Definition: QTerminal.cc:155
QAction * _run_selection_action
Definition: QTerminal.h:163
virtual void setSize(int h, int v)=0
QTerminal(octave::base_qobject &oct_qobj, QWidget *xparent=nullptr)
Definition: QTerminal.h:149
void help_on_expression(void)
Definition: QTerminal.cc:187
octave::base_qobject & m_octave_qobj
Definition: QTerminal.h:156
QMenu * _contextMenu
Definition: QTerminal.h:158
virtual void setCursorType(CursorType type, bool blinking)
Definition: QTerminal.h:79
virtual void pasteClipboard(void)=0
void set_screen_size_signal(int, int)
void construct(octave::base_qobject &oct_qobj)
Definition: QTerminal.cc:277
virtual void setBackgroundColor(const QColor &color)=0
@ IBeamCursor
Definition: QTerminal.h:74
@ UnderlineCursor
Definition: QTerminal.h:76
@ BlockCursor
Definition: QTerminal.h:75
virtual QList< QAction * > get_hotspot_actions(const QPoint &)
Definition: QTerminal.h:69
void notice_settings(const gui_settings *settings)
Definition: QTerminal.cc:202
virtual void init_terminal_size(void)
Definition: QTerminal.h:131
QAction * _interrupt_action
Definition: QTerminal.h:168
void edit_mfile_request(const QString &, int)
virtual void setSelectionColor(const QColor &color)=0
void request_edit_mfile_signal(const QString &, int)
virtual void handleCustomContextMenuRequested(const QPoint &at)
Definition: QTerminal.cc:73
virtual void has_extra_interrupt(bool extra)=0
QAction * _selectall_action
Definition: QTerminal.h:161
virtual void setTerminalFont(const QFont &font)=0
QAction * _copy_action
Definition: QTerminal.h:159
virtual void setCursorColor(bool useForegroundColor, const QColor &color)=0
void request_open_file_signal(const QString &, const QString &, int)
virtual void copyClipboard(void)=0
void terminal_interrupt(void)
Definition: QTerminal.h:133
QAction * _nop_action
Definition: QTerminal.h:169
QAction * m_doc_selected_action
Definition: QTerminal.h:166
static QTerminal * create(octave::base_qobject &oct_qobj, QWidget *xparent)
Definition: QTerminal.cc:52
void clear_command_window_request(void)
virtual void setForegroundColor(const QColor &color)=0
void execute_command_in_terminal_signal(const QString &)
void edit_file(void)
Definition: QTerminal.cc:170
QAction * m_edit_selected_action
Definition: QTerminal.h:164
virtual void setScrollBufferSize(int value=1000)=0
void show_doc_signal(const QString &)
virtual void selectAll(void)=0
void edit_selected(void)
Definition: QTerminal.cc:179
virtual void sendText(const QString &text)=0
virtual ~QTerminal(void)=default
Base class for Octave interfaces that use Qt.