GNU Octave  6.2.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"
38 
39 namespace octave
40 {
41  class base_qobject;
42 }
43 
44 class QMenu;
45 class QAction;
46 
47 class QTerminal : public QWidget
48 {
49  Q_OBJECT
50 
51 public:
52 
53  static QTerminal *
54  create (octave::base_qobject& oct_qobj, QWidget *xparent = nullptr);
55 
56  virtual ~QTerminal (void) = default;
57 
58  virtual void setTerminalFont (const QFont& font) = 0;
59 
60  virtual void setSize (int h, int v) = 0;
61 
62  virtual void sendText (const QString& text) = 0;
63 
64  virtual QString selectedText () = 0;
65 
66  virtual void has_extra_interrupt (bool extra) = 0;
67 
68  virtual QList<QAction*> get_hotspot_actions (const QPoint&)
69  { return QList<QAction*> (); }
70 
72  {
76  };
77 
78  virtual void setCursorType (CursorType type, bool blinking)
79  {
80  // Provide empty default impl in order to avoid conflicts with the
81  // win impl.
82 
83  Q_UNUSED (type);
84  Q_UNUSED (blinking);
85  }
86 
87  virtual void setBackgroundColor (const QColor& color) = 0;
88 
89  virtual void setForegroundColor (const QColor& color) = 0;
90 
91  virtual void setSelectionColor (const QColor& color) = 0;
92 
93  virtual void setCursorColor (bool useForegroundColor,
94  const QColor& color) = 0;
95 
96  virtual void setScrollBufferSize(int value=1000) = 0;
97 
98 signals:
99 
100  void report_status_message (const QString&);
101 
102  void interrupt_signal (void);
103 
104  void edit_mfile_request (const QString&, int);
105 
106  void show_doc_signal (const QString&);
107 
108  void execute_command_in_terminal_signal (const QString&);
109 
110 public slots:
111 
112  virtual void copyClipboard (void) = 0;
113 
114  virtual void pasteClipboard (void) = 0;
115 
116  virtual void selectAll (void) = 0;
117 
118  virtual void handleCustomContextMenuRequested (const QPoint& at);
119 
120  void notice_settings (const gui_settings *settings);
121 
122  virtual void init_terminal_size (void) { }
123 
124  void terminal_interrupt (void) { emit interrupt_signal (); }
125 
126  void set_global_shortcuts (bool focus_out);
127 
128  void run_selection (void);
129 
130  void edit_file (void);
131 
132  void edit_selected (void);
133 
134  void help_on_expression (void);
135 
136  void doc_on_expression (void);
137 
138  virtual void handle_visibility_changed (bool) { };
139 
140 protected:
141 
142  QTerminal (QWidget *xparent = nullptr) : QWidget (xparent) { }
143 
144  void construct (octave::base_qobject& oct_qobj, QWidget *xparent);
145 
146 private:
147 
149  QAction * _copy_action;
150  QAction * _paste_action;
151  QAction * _selectall_action;
152  QAction * _edit_action;
157 
159  QAction *_nop_action;
160 };
161 
162 #endif // QTERMINAL_H
void doc_on_expression(void)
Definition: QTerminal.cc:214
void interrupt_signal(void)
void report_status_message(const QString &)
virtual void handle_visibility_changed(bool)
Definition: QTerminal.h:138
QAction * m_help_selected_action
Definition: QTerminal.h:155
virtual QString selectedText()=0
QAction * _edit_action
Definition: QTerminal.h:152
QAction * _paste_action
Definition: QTerminal.h:150
void run_selection(void)
Definition: QTerminal.cc:174
QAction * _run_selection_action
Definition: QTerminal.h:153
virtual void setSize(int h, int v)=0
void help_on_expression(void)
Definition: QTerminal.cc:206
QMenu * _contextMenu
Definition: QTerminal.h:148
virtual void setCursorType(CursorType type, bool blinking)
Definition: QTerminal.h:78
virtual void pasteClipboard(void)=0
virtual void setBackgroundColor(const QColor &color)=0
@ IBeamCursor
Definition: QTerminal.h:73
@ UnderlineCursor
Definition: QTerminal.h:75
@ BlockCursor
Definition: QTerminal.h:74
virtual QList< QAction * > get_hotspot_actions(const QPoint &)
Definition: QTerminal.h:68
void notice_settings(const gui_settings *settings)
Definition: QTerminal.cc:222
virtual void init_terminal_size(void)
Definition: QTerminal.h:122
QAction * _interrupt_action
Definition: QTerminal.h:158
void edit_mfile_request(const QString &, int)
virtual void setSelectionColor(const QColor &color)=0
virtual void handleCustomContextMenuRequested(const QPoint &at)
Definition: QTerminal.cc:92
virtual void has_extra_interrupt(bool extra)=0
QAction * _selectall_action
Definition: QTerminal.h:151
virtual void setTerminalFont(const QFont &font)=0
QAction * _copy_action
Definition: QTerminal.h:149
void set_global_shortcuts(bool focus_out)
Definition: QTerminal.cc:73
virtual void setCursorColor(bool useForegroundColor, const QColor &color)=0
virtual void copyClipboard(void)=0
void terminal_interrupt(void)
Definition: QTerminal.h:124
QAction * _nop_action
Definition: QTerminal.h:159
QAction * m_doc_selected_action
Definition: QTerminal.h:156
virtual void setForegroundColor(const QColor &color)=0
void construct(octave::base_qobject &oct_qobj, QWidget *xparent)
Definition: QTerminal.cc:295
void execute_command_in_terminal_signal(const QString &)
void edit_file(void)
Definition: QTerminal.cc:189
QAction * m_edit_selected_action
Definition: QTerminal.h:154
QTerminal(QWidget *xparent=nullptr)
Definition: QTerminal.h:142
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:198
virtual void sendText(const QString &text)=0
virtual ~QTerminal(void)=default
static QTerminal * create(octave::base_qobject &oct_qobj, QWidget *xparent=nullptr)
Definition: QTerminal.cc:52
Base class for Octave interfaces that use Qt.