Mercurial > octave
annotate libgui/qterminal/libqterminal/QTerminal.cc @ 23404:314ac710f2ae
highlight error messages in gui and provide links to open files (bug #35619)
* QTerminal.cc (handleCustomContextMenuReques): use method via selecting the
message only in windows
* Filter.cpp (Filter::HotSpot::type(), Filter::HotSpot::setType): make Type
a type in Filter, not in HotSpot;
(RegExpFilter::RegExpFilter) create a filter with the corresponding type
instead of different filters for different types;
(RegExpFilter::HotSpot::HotSpot): A found hot spot is created with the types
of the filter that found that hot spot;
(RegExpFilter::process): remove some old debug message, which were already
commented out, call newHotSpot with type as new parameter;
(RegExpFilter::newHotSpot, UrlFilter::newHotSpot): new parameter type;
(UrlFilter::process): derive this method for UrlFilter, too, allowing
to connect signals for opening files later on;
(UrlFilter::HotSpot::HotSpot): no extra action here, get type from filter;
(UrlFilter::HotSpot::urlType): add new url type;
(UrlFilter::HotSpot::activate): depending on link type, open link as before
or call method for opening the file mentioned in the link;
(UrlFilter::ErrorLinkRegExp): const defined reg. expression for error link;
(UrlFilter::UrlFilter): set reg. expression depending on type;
(UrlFilter::HotSpot::actions): in a case of a file link, only prepare
an open, but no copy action for the context menu;
(UrlFilter::request_open_file): method emitting the signal to the main window
for opening the desired file at desired line;
* Filter.h: make Filter class inherit from QObject for using singals, move
enum Type from HotSpot to Filter and add the types Error and ErrorLink,
Filter and Filter::HotSpot ctors with type parameter, add file opening
signal to RegExpFilter and FilterObject, add Q_OBJECT directives, add
method to FilterObject returning the instance variable _urlObject, add
new urlType ErrorLink, add own process method and open file slot to
UrlFilter, FilterObject: open file slot only emitting open file singal
* QUnixTerminalImpl.cpp (ctor): initialize instance variable _parent;
(initialize): add new filters for errors and for links to related files,
connect latters signal to the appropriate main windows slot;
* QUnixTerminalImpl.h: add instance variable _parent for signal connections
* TerminalView.cpp (paintFilters): underline Link and ErrorLink, draw
rectangle with transparency for Error and LinkError;
(mousePressEvent, mouseMoveEvent): treat Link and ErrorLink the same way
author | Torsten <mttl@mailbox.org> |
---|---|
date | Mon, 17 Apr 2017 21:28:55 +0200 |
parents | fee531225679 |
children | 9c24aae7515f |
rev | line source |
---|---|
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
1 /* |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
2 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
3 Copyright (C) 2012-2017 Michael Goffioul. |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22250
diff
changeset
|
4 Copyright (C) 2012-2016 Jacob Dawid. |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
5 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
6 This file is part of QTerminal. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
7 |
17795
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8 This program is free software: you can redistribute it and/or modify |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
9 it under the terms of the GNU General Public License as published by |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
11 (at your option) any later version. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
12 |
17795
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
13 This program is distributed in the hope that it will be useful, |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
16 GNU General Public License for more details. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
17 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
17795
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
19 along with this program. If not, |
0a8c35ae5ce1
maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
20 see <http://www.gnu.org/licenses/>. |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
21 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
22 */ |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
23 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
24 #include "QTerminal.h" |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
25 |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
26 #if defined (Q_OS_WIN32) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
27 # include "win32/QWinTerminalImpl.h" |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
28 #else |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
29 # include "unix/QUnixTerminalImpl.h" |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
30 #endif |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
31 |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
32 QTerminal * |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
33 QTerminal::create (QWidget *xparent) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
34 { |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
35 #if defined (Q_OS_WIN32) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
36 return new QWinTerminalImpl (xparent); |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
37 #else |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
38 return new QUnixTerminalImpl (xparent); |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
39 #endif |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
40 } |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
41 |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
42 QList<QColor> |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
43 QTerminal::default_colors (void) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
44 { |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
45 static QList<QColor> colors; |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
46 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
47 if (colors.isEmpty ()) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
48 { |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
49 colors << QColor(0,0,0) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
50 << QColor(255,255,255) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
51 << QColor(192,192,192) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
52 << QColor(128,128,128); |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
53 } |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
54 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
55 return colors; |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
56 } |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
57 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
58 QStringList |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
59 QTerminal::color_names (void) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
60 { |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
61 static QStringList names; |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
62 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
63 if (names.isEmpty ()) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
64 { |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
65 names << QObject::tr ("foreground") |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
66 << QObject::tr ("background") |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
67 << QObject::tr ("selection") |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
68 << QObject::tr ("cursor"); |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
69 } |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
70 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
71 return names; |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
72 } |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
73 |
19943
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19697
diff
changeset
|
74 // slot for disabling the interrupt action when terminal loses focus |
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19697
diff
changeset
|
75 void |
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19697
diff
changeset
|
76 QTerminal::set_global_shortcuts (bool focus_out) |
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19697
diff
changeset
|
77 { |
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19697
diff
changeset
|
78 if (focus_out) |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
79 { |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
80 _interrupt_action->setShortcut (QKeySequence ()); |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
81 _nop_action->setShortcut (QKeySequence ()); |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
82 } |
19943
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19697
diff
changeset
|
83 else |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
84 { |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
85 _interrupt_action->setShortcut ( |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
20995
diff
changeset
|
86 QKeySequence (Qt::ControlModifier | Qt::Key_C)); |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
87 _nop_action->setShortcut ( |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
20995
diff
changeset
|
88 QKeySequence (Qt::ControlModifier | Qt::Key_D)); |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
89 } |
19943
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19697
diff
changeset
|
90 } |
88233ac3f3ea
fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents:
19697
diff
changeset
|
91 |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
92 // slot for the terminal's context menu |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
93 void |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
94 QTerminal::handleCustomContextMenuRequested (const QPoint& at) |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
95 { |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
96 QClipboard * cb = QApplication::clipboard (); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
97 QString selected_text = selectedText(); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
98 bool has_selected_text = ! selected_text.isEmpty (); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
99 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
100 _edit_action->setVisible (false); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
101 |
23404
314ac710f2ae
highlight error messages in gui and provide links to open files (bug #35619)
Torsten <mttl@mailbox.org>
parents:
23403
diff
changeset
|
102 #if defined (Q_OS_WIN32) |
314ac710f2ae
highlight error messages in gui and provide links to open files (bug #35619)
Torsten <mttl@mailbox.org>
parents:
23403
diff
changeset
|
103 // include this when in windows because there is no filter for |
314ac710f2ae
highlight error messages in gui and provide links to open files (bug #35619)
Torsten <mttl@mailbox.org>
parents:
23403
diff
changeset
|
104 // detecting links and error messages yet |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
105 if (has_selected_text) |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
106 { |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
107 QRegExp file ("(?:[ \\t]+)(\\S+) at line (\\d+) column (?:\\d+)"); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
108 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
109 int pos = file.indexIn (selected_text); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
110 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
111 if (pos > -1) |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
112 { |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
113 QString file_name = file.cap (1); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
114 QString line = file.cap (2); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
115 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
116 _edit_action->setVisible (true); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
117 _edit_action->setText (tr ("Edit %1 at line %2") |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
118 .arg (file_name).arg (line)); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
119 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
120 QStringList data; |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
121 data << file_name << line; |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
122 _edit_action->setData (data); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
123 } |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
124 } |
23404
314ac710f2ae
highlight error messages in gui and provide links to open files (bug #35619)
Torsten <mttl@mailbox.org>
parents:
23403
diff
changeset
|
125 #endif |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
126 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
127 _paste_action->setEnabled (cb->text().length() > 0); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
128 _copy_action->setEnabled (has_selected_text); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
129 |
23403
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
130 // Get the actions of any hotspots the filters may have found |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
131 QList<QAction*> actions = get_hotspot_actions (at); |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
132 if (actions.length ()) |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
133 _contextMenu->addSeparator (); |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
134 for (int i = 0; i < actions.length (); i++) |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
135 _contextMenu->addAction (actions.at(i)); |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
136 |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
137 // Finally, show the context menu |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
138 _contextMenu->exec (mapToGlobal (at)); |
23403
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
139 |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
140 // Cleaning up, remove actions of the hotspot |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
141 for (int i = 0; i < actions.length (); i++) |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
142 _contextMenu->removeAction (actions.at(i)); |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
143 } |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
144 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
145 // slot for edit files in error messages |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
146 void |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
147 QTerminal::edit_file () |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
148 { |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
149 QString file = _edit_action->data ().toStringList ().at (0); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
150 int line = _edit_action->data ().toStringList ().at (1).toInt (); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
151 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
152 emit edit_mfile_request (file,line); |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
153 } |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
154 |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
155 void |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
156 QTerminal::notice_settings (const QSettings *settings) |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
157 { |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
158 // QSettings pointer is checked before emitting. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
159 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
160 // Set terminal font: |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
161 QFont term_font = QFont (); |
17508
a28c3fb15ad8
Set style hint to ensure a monospaced font in the gui terminal
Torsten <ttl@justmail.de>
parents:
16641
diff
changeset
|
162 term_font.setStyleHint (QFont::TypeWriter); |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
163 term_font.setFamily |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
164 (settings->value ("terminal/fontName", "Courier New").toString ()); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
165 term_font.setPointSize (settings->value ("terminal/fontSize", 10).toInt ()); |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
166 setTerminalFont (term_font); |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
167 |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
168 QString cursorType |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
169 = settings->value ("terminal/cursorType", "ibeam").toString (); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
170 |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
171 bool cursorBlinking |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
172 = settings->value ("terminal/cursorBlinking", true).toBool (); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
173 |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
174 if (cursorType == "ibeam") |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
175 setCursorType (QTerminal::IBeamCursor, cursorBlinking); |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
176 else if (cursorType == "block") |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
177 setCursorType (QTerminal::BlockCursor, cursorBlinking); |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
178 else if (cursorType == "underline") |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
179 setCursorType (QTerminal::UnderlineCursor, cursorBlinking); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
180 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
181 bool cursorUseForegroundColor |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
182 = settings->value ("terminal/cursorUseForegroundColor", true).toBool (); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
183 |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
184 QList<QColor> colors = default_colors (); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
185 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
186 setForegroundColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
187 (settings->value ("terminal/color_f", |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
188 QVariant (colors.at (0))).value<QColor> ()); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
189 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
190 setBackgroundColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
191 (settings->value ("terminal/color_b", |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
192 QVariant (colors.at (1))).value<QColor> ()); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
193 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
194 setSelectionColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
195 (settings->value ("terminal/color_s", |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
196 QVariant (colors.at (2))).value<QColor> ()); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
197 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
198 setCursorColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
199 (cursorUseForegroundColor, |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
200 settings->value ("terminal/color_c", |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
201 QVariant (colors.at (3))).value<QColor> ()); |
18678
6113e0c6920b
maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents:
18610
diff
changeset
|
202 setScrollBufferSize (settings->value ("terminal/history_buffer",1000).toInt () ); |
19690
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
18678
diff
changeset
|
203 |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
204 // check whether Copy shortcut is Ctrl-C |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
205 QKeySequence sc; |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
206 sc = QKeySequence (settings->value ("shortcuts/main_edit:copy").toString ()); |
19690
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
18678
diff
changeset
|
207 |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
208 // if sc is empty, shortcuts are not yet in the settings (take the default) |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
209 if (sc.isEmpty ()) // QKeySequence::Copy as second argument in |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
210 sc = QKeySequence::Copy; // settings->value () does not work! |
20146
f5e65f806123
fix checking copy shortcut in terminal when no setting available (bug #44968)
Torsten <ttl@justmail.de>
parents:
19943
diff
changeset
|
211 |
19690
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
18678
diff
changeset
|
212 // dis- or enable extra interrupt action |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
20995
diff
changeset
|
213 bool extra_ir_action = (sc != QKeySequence (Qt::ControlModifier | Qt::Key_C)); |
19690
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
18678
diff
changeset
|
214 _interrupt_action->setEnabled (extra_ir_action); |
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
18678
diff
changeset
|
215 has_extra_interrupt (extra_ir_action); |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
216 |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
217 // check whether shortcut Ctrl-D is in use by the main-window |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
218 bool ctrld = settings->value ("shortcuts/main_ctrld",false).toBool (); |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
219 _nop_action->setEnabled (! ctrld); |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
220 } |