annotate libgui/qterminal/libqterminal/QTerminal.h @ 16658:591cb51c18a3

always handle CTRL-C as interrupt on windows systems * QTerminal.h (QTerminal::QTerminal): Don't set shortcuts for copy and paste. * octave-qt-link.cc (octave_qt_link::do_pre_input_event, octave_qt_link::do_post_input_event): Don't enable/disable processed input on Windows systems.
author John W. Eaton <jwe@octave.org>
date Tue, 14 May 2013 02:49:24 -0400
parents de1f8e4b6b9b
children 0495339998f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15651
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
1 /*
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
2
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
3 Copyright (C) 2012 Michael Goffioul.
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
4 Copyright (C) 2012 Jacob Dawid.
15647
a044a259c423 Renamed SessionModel in TerminalModel.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15646
diff changeset
5
15651
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
6 This file is part of QTerminal.
15631
9712f29c97de Compiles again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
7
15651
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
8 Foobar is free software: you can redistribute it and/or modify
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
9 it under the terms of the GNU General Public License as published by
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
11 (at your option) any later version.
15631
9712f29c97de Compiles again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
12
15651
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
13 QTerminal is distributed in the hope that it will be useful,
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
16 GNU General Public License for more details.
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
17
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
18 You should have received a copy of the GNU General Public License
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
19 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
20
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
21 */
15631
9712f29c97de Compiles again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
22
15651
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
23 #ifndef QTERMINAL_H
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
24 #define QTERMINAL_H
15649
c22fa57226b2 Fixed bug with ECHOCTL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15648
diff changeset
25
16469
c89699ca005a ensure QSettings is declared for QTerminal.h
John W. Eaton <jwe@octave.org>
parents: 16413
diff changeset
26 #include <QSettings>
16648
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
27 #include <QKeySequence>
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
28 #include <QWidget>
16641
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
29 #include <QStringList>
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
30 #include <QColor>
16641
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
31 #include <QList>
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
32 #include <QMenu>
15662
5758e0013246 Enable compilation on Win32-native platform.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15658
diff changeset
33
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
34 class QTerminal : public QWidget
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
35 {
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
36 Q_OBJECT
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
37
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
38 public:
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
39
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
40 static QTerminal *create (QWidget *xparent = 0);
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
41
16641
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
42 static QList<QColor> default_colors (void);
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
43
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
44 static QStringList color_names (void);
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
45
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
46 virtual ~QTerminal (void) { }
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
47
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
48 virtual void setTerminalFont(const QFont& font) = 0;
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
49
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
50 virtual void setSize(int h, int v) = 0;
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
51
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
52 virtual void sendText(const QString& text) = 0;
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
53
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
54 enum CursorType
15658
eaa7da75d202 Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15652
diff changeset
55 {
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
56 UnderlineCursor,
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
57 BlockCursor,
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
58 IBeamCursor
15658
eaa7da75d202 Added QTerminalInteface class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15652
diff changeset
59 };
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
60
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
61 virtual void setCursorType (CursorType type, bool blinking)
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
62 {
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
63 // Provide empty default impl in order to avoid conflicts with the
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
64 // win impl.
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
65
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
66 Q_UNUSED (type);
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
67 Q_UNUSED (blinking);
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
68 }
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
69
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
70 virtual void setBackgroundColor (const QColor& color) = 0;
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
71
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
72 virtual void setForegroundColor (const QColor& color) = 0;
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
73
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
74 virtual void setSelectionColor (const QColor& color) = 0;
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
75
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
76 virtual void setCursorColor (bool useForegroundColor,
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
77 const QColor& color) = 0;
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
78
16648
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
79 signals:
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
80
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
81 void report_status_message (const QString&);
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
82
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
83 public slots:
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
84
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
85 virtual void copyClipboard (void) = 0;
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
86
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
87 virtual void pasteClipboard (void) = 0;
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15894
diff changeset
88
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
89 virtual void handleCustomContextMenuRequested (const QPoint& at)
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
90 {
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
91 _contextMenu->move (mapToGlobal (at));
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
92 _contextMenu->show ();
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
93 }
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
94
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
95 void notice_settings (const QSettings *settings);
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
96
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
97 protected:
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
98
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
99 QTerminal (QWidget *xparent = 0) : QWidget (xparent)
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
100 {
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
101 setContextMenuPolicy (Qt::CustomContextMenu);
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
102
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
103 _contextMenu = new QMenu (this);
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
104
16649
de1f8e4b6b9b more copy/paste tweaks
John W. Eaton <jwe@octave.org>
parents: 16648
diff changeset
105 QAction *copyAction
de1f8e4b6b9b more copy/paste tweaks
John W. Eaton <jwe@octave.org>
parents: 16648
diff changeset
106 = _contextMenu->addAction (tr ("Copy"),
de1f8e4b6b9b more copy/paste tweaks
John W. Eaton <jwe@octave.org>
parents: 16648
diff changeset
107 this, SLOT (copyClipboard ()));
de1f8e4b6b9b more copy/paste tweaks
John W. Eaton <jwe@octave.org>
parents: 16648
diff changeset
108
de1f8e4b6b9b more copy/paste tweaks
John W. Eaton <jwe@octave.org>
parents: 16648
diff changeset
109 QAction *pasteAction
de1f8e4b6b9b more copy/paste tweaks
John W. Eaton <jwe@octave.org>
parents: 16648
diff changeset
110 = _contextMenu->addAction (tr ("Paste"),
de1f8e4b6b9b more copy/paste tweaks
John W. Eaton <jwe@octave.org>
parents: 16648
diff changeset
111 this, SLOT (pasteClipboard ()));
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
112
16648
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
113 connect (this, SIGNAL (customContextMenuRequested (QPoint)),
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
114 this, SLOT (handleCustomContextMenuRequested (QPoint)));
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
115
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
116 connect (this, SIGNAL (report_status_message (const QString&)),
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
117 xparent, SLOT (report_status_message (const QString&)));
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
118
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
119 connect (xparent, SIGNAL (settings_changed (const QSettings *)),
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
120 this, SLOT (notice_settings (const QSettings *)));
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
121
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
122 connect (xparent, SIGNAL (copyClipboard_signal ()),
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
123 this, SLOT (copyClipboard ()));
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
124
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
125 connect (xparent, SIGNAL (pasteClipboard_signal ()),
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16641
diff changeset
126 this, SLOT (pasteClipboard ()));
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
127 }
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
128
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
129 private:
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
130
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
131 QMenu *_contextMenu;
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
132 };
15631
9712f29c97de Compiles again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
133
15651
845cebf281aa Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 15650
diff changeset
134 #endif // QTERMINAL_H