Mercurial > octave
annotate libgui/qterminal/libqterminal/QTerminal.cc @ 33265:421c45e180ce
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Thu, 28 Mar 2024 16:26:44 +0100 |
parents | 49128bdb9eb2 7cef76b2d1da |
children | 28c7f3195d3a |
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 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26008
diff
changeset
|
3 Copyright (C) 2012-2019 Michael Goffioul. |
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26008
diff
changeset
|
4 Copyright (C) 2012-2019 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, |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23810
diff
changeset
|
20 see <https://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 |
27659
d4f1abfaf3a5
* Qterminal.cc: Include config.h.
John W. Eaton <jwe@octave.org>
parents:
27658
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
d4f1abfaf3a5
* Qterminal.cc: Include config.h.
John W. Eaton <jwe@octave.org>
parents:
27658
diff
changeset
|
25 # include "config.h" |
d4f1abfaf3a5
* Qterminal.cc: Include config.h.
John W. Eaton <jwe@octave.org>
parents:
27658
diff
changeset
|
26 #endif |
d4f1abfaf3a5
* Qterminal.cc: Include config.h.
John W. Eaton <jwe@octave.org>
parents:
27658
diff
changeset
|
27 |
32000
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
28 #include <QAction> |
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
29 #include <QApplication> |
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
30 #include <QClipboard> |
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
31 #include <QColor> |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
32 #include <QKeySequence> |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
33 #include <QList> |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
34 #include <QMenu> |
32000
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
35 #include <QRegularExpression> |
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
36 #include <QStringList> |
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
37 #include <QWidget> |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
38 |
27724
19e80f22aa47
provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27686
diff
changeset
|
39 #include "gui-preferences-global.h" |
27560
3fcc650de22f
split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
27288
diff
changeset
|
40 #include "gui-preferences-cs.h" |
27583
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
41 #include "gui-preferences-sc.h" |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
29783
diff
changeset
|
42 #include "gui-settings.h" |
27560
3fcc650de22f
split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
27288
diff
changeset
|
43 |
31697
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
44 #include "builtin-defun-decls.h" |
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
45 #include "interpreter.h" |
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
46 |
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
|
47 #include "QTerminal.h" |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
48 #if defined (Q_OS_WIN32) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
49 # include "win32/QWinTerminalImpl.h" |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
50 #else |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
51 # include "unix/QUnixTerminalImpl.h" |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
52 #endif |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
53 |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
54 QTerminal * |
31698
276a992d0c08
remove more uses of base_qobject and octave-qobject.h
John W. Eaton <jwe@octave.org>
parents:
31697
diff
changeset
|
55 QTerminal::create (QWidget *p) |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
56 { |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
57 #if defined (Q_OS_WIN32) |
31698
276a992d0c08
remove more uses of base_qobject and octave-qobject.h
John W. Eaton <jwe@octave.org>
parents:
31697
diff
changeset
|
58 QTerminal *terminal = new QWinTerminalImpl (p); |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
59 #else |
31698
276a992d0c08
remove more uses of base_qobject and octave-qobject.h
John W. Eaton <jwe@octave.org>
parents:
31697
diff
changeset
|
60 QTerminal *terminal = new QUnixTerminalImpl (p); |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
61 #endif |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
62 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
63 // FIXME: this function should probably be called from or part of the |
31698
276a992d0c08
remove more uses of base_qobject and octave-qobject.h
John W. Eaton <jwe@octave.org>
parents:
31697
diff
changeset
|
64 // QTerminal constructor? |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
65 |
31698
276a992d0c08
remove more uses of base_qobject and octave-qobject.h
John W. Eaton <jwe@octave.org>
parents:
31697
diff
changeset
|
66 terminal->construct (); |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
67 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
68 return terminal; |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
69 } |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
70 |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
71 // 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
|
72 void |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
73 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
|
74 { |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
79 _edit_action->setVisible (false); |
27288
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
80 m_edit_selected_action->setVisible (false); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
81 m_help_selected_action->setVisible (false); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
82 m_doc_selected_action->setVisible (false); |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
83 |
23404
314ac710f2ae
highlight error messages in gui and provide links to open files (bug #35619)
Torsten <mttl@mailbox.org>
parents:
23403
diff
changeset
|
84 #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
|
85 // 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
|
86 // 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
|
87 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
|
88 { |
32000
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
89 QRegularExpression file {"(?:[ \\t]+)(\\S+) at line (\\d+) column (?:\\d+)"}; |
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
90 QRegularExpressionMatch match = file.match (selected_text); |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
91 |
32000
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
92 if (match.hasMatch ()) |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
93 { |
32000
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
94 QString file_name = match.captured (1); |
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
95 QString line = match.captured (2); |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
96 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
97 _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
|
98 _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
|
99 .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
|
100 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
101 QStringList data; |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
102 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
|
103 _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
|
104 } |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
105 } |
23404
314ac710f2ae
highlight error messages in gui and provide links to open files (bug #35619)
Torsten <mttl@mailbox.org>
parents:
23403
diff
changeset
|
106 #endif |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
107 |
27288
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
108 if (has_selected_text) |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
109 { |
33264
7cef76b2d1da
gui: Use first word for options in right-click menu of command window widget (bug #65518).
Markus Mützel <markus.muetzel@gmx.de>
parents:
32000
diff
changeset
|
110 QRegularExpression expr {"(\\w+)"}; |
32000
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
111 QRegularExpressionMatch match = expr.match (selected_text); |
27288
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
112 |
32000
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
113 if (match.hasMatch ()) |
27288
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
114 { |
32000
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
115 QString expr_found = match.captured (1); |
27288
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
116 |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
117 m_edit_selected_action->setVisible (true); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
118 m_edit_selected_action->setText (tr ("Edit %1").arg (expr_found)); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
119 m_edit_selected_action->setData (expr_found); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
120 |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
121 m_help_selected_action->setVisible (true); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
122 m_help_selected_action->setText (tr ("Help on %1").arg (expr_found)); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
123 m_help_selected_action->setData (expr_found); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
124 |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
125 m_doc_selected_action->setVisible (true); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
126 m_doc_selected_action->setText (tr ("Documentation on %1") |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
127 .arg (expr_found)); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
128 m_doc_selected_action->setData (expr_found); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
129 } |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
130 } |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
131 |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
132 _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
|
133 _copy_action->setEnabled (has_selected_text); |
27288
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
134 _run_selection_action->setVisible (has_selected_text); |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
135 |
23403
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
136 // 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
|
137 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
|
138 if (actions.length ()) |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
139 _contextMenu->addSeparator (); |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
140 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
|
141 _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
|
142 |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
143 // 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
|
144 _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
|
145 |
fee531225679
make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents:
23219
diff
changeset
|
146 // 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
|
147 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
|
148 _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
|
149 } |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
150 |
25813
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
151 // slot for running the selected code |
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
152 void |
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
153 QTerminal::run_selection () |
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
154 { |
32000
20bf7bf8c95d
Replace remaining deprecated QRegExp by QRegularExpression.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31995
diff
changeset
|
155 QStringList commands = selectedText ().split (QRegularExpression {"[\r\n]"}, |
29049
461bd8b9ce91
use Qt::SplitBehavior enum and values if available
John W. Eaton <jwe@octave.org>
parents:
27818
diff
changeset
|
156 #if defined (HAVE_QT_SPLITBEHAVIOR_ENUM) |
461bd8b9ce91
use Qt::SplitBehavior enum and values if available
John W. Eaton <jwe@octave.org>
parents:
27818
diff
changeset
|
157 Qt::SkipEmptyParts); |
461bd8b9ce91
use Qt::SplitBehavior enum and values if available
John W. Eaton <jwe@octave.org>
parents:
27818
diff
changeset
|
158 #else |
25813
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
159 QString::SkipEmptyParts); |
29049
461bd8b9ce91
use Qt::SplitBehavior enum and values if available
John W. Eaton <jwe@octave.org>
parents:
27818
diff
changeset
|
160 #endif |
25813
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
161 for (int i = 0; i < commands.size (); i++) |
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
162 emit execute_command_in_terminal_signal (commands.at (i)); |
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
163 |
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
164 } |
d98d7df9fd15
updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents:
25054
diff
changeset
|
165 |
20995
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
166 // 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
|
167 void |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
168 QTerminal::edit_file () |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
169 { |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
170 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
|
171 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
|
172 |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
173 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
|
174 } |
aab7a3c7168e
edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents:
20987
diff
changeset
|
175 |
27288
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
176 // slot for edit selected function names |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
177 void QTerminal::edit_selected () |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
178 { |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
179 QString file = m_edit_selected_action->data ().toString (); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
180 |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
181 emit edit_mfile_request (file,0); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
182 } |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
183 |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
184 // slot for showing help on selected epxression |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
185 void QTerminal::help_on_expression () |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
186 { |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
187 QString expr = m_help_selected_action->data ().toString (); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
188 |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
189 emit execute_command_in_terminal_signal ("help " + expr); |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
190 } |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
191 |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
192 // slot for showing documentation on selected epxression |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
193 void QTerminal::doc_on_expression () |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
194 { |
31697
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
195 std::string expr = m_doc_selected_action->data ().toString ().toStdString (); |
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
196 |
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
197 emit interpreter_event |
33034
49128bdb9eb2
use explicit lambda-expression captures (bug #65318)
John W. Eaton <jwe@octave.org>
parents:
32832
diff
changeset
|
198 ([expr] (octave::interpreter& interp) |
31697
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
199 { |
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
200 // INTERPRETER THREAD |
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
201 |
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
202 octave::F__event_manager_show_documentation__ (interp, ovl (expr)); |
dd904ce6f53f
use interpreter event to display documentation in terminal and editor widgets
John W. Eaton <jwe@octave.org>
parents:
31690
diff
changeset
|
203 }); |
27288
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
204 } |
0a2e5c808709
allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27276
diff
changeset
|
205 |
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
|
206 void |
32832
f3c1a77bcc6b
maint: Replace (void) in function declarations with () where possible
Arun Giridhar <arungiridhar@gmail.com>
parents:
32000
diff
changeset
|
207 QTerminal::notice_settings () |
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
|
208 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
29783
diff
changeset
|
209 octave::gui_settings settings; |
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
|
210 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
211 // Set terminal font: |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
212 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
|
213 term_font.setStyleHint (QFont::TypeWriter); |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
214 QString default_font = settings.string_value (global_mono_font); |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
215 term_font.setFamily |
31702
aae24eaf89ad
update gui_pref class to match recent changes to sc_pref class
John W. Eaton <jwe@octave.org>
parents:
31698
diff
changeset
|
216 (settings.value (cs_font.settings_key (), default_font).toString ()); |
27583
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
217 term_font.setPointSize |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
218 (settings.int_value (cs_font_size)); |
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
|
219 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
|
220 |
25869
462066384af3
fix minimum size of console widget in gui (bug54620)
Torsten <mttl@mailbox.org>
parents:
25813
diff
changeset
|
221 QFontMetrics metrics (term_font); |
462066384af3
fix minimum size of console widget in gui (bug54620)
Torsten <mttl@mailbox.org>
parents:
25813
diff
changeset
|
222 setMinimumSize (metrics.maxWidth ()*16, metrics.height ()*3); |
462066384af3
fix minimum size of console widget in gui (bug54620)
Torsten <mttl@mailbox.org>
parents:
25813
diff
changeset
|
223 |
27583
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
224 QString cursor_type |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
225 = settings.string_value (cs_cursor); |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
226 |
27583
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
227 bool cursor_blinking; |
31702
aae24eaf89ad
update gui_pref class to match recent changes to sc_pref class
John W. Eaton <jwe@octave.org>
parents:
31698
diff
changeset
|
228 if (settings.contains (global_cursor_blinking.settings_key ())) |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
229 cursor_blinking = settings.bool_value (global_cursor_blinking); |
23810
9c24aae7515f
allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents:
23404
diff
changeset
|
230 else |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
231 cursor_blinking = settings.bool_value (cs_cursor_blinking); |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
232 |
27583
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
233 for (int ct = IBeamCursor; ct <= UnderlineCursor; ct++) |
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
234 { |
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
235 if (cursor_type.toStdString () == cs_cursor_types[ct]) |
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
236 { |
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
237 setCursorType ((CursorType) ct, cursor_blinking); |
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
238 break; |
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
239 } |
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
240 } |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
241 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
242 bool cursorUseForegroundColor |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
243 = settings.bool_value (cs_cursor_use_fgcol); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
244 |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
245 int mode = settings.int_value (cs_color_mode); |
29484
bed2fd5b8263
allow a second color theme for the console window (dark mode)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29393
diff
changeset
|
246 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
29783
diff
changeset
|
247 setForegroundColor (settings.color_value (cs_colors[0], mode)); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
248 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
29783
diff
changeset
|
249 setBackgroundColor (settings.color_value (cs_colors[1], mode)); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
250 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
29783
diff
changeset
|
251 setSelectionColor (settings.color_value (cs_colors[2], mode)); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
252 |
27583
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
253 setCursorColor (cursorUseForegroundColor, |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
29783
diff
changeset
|
254 settings.color_value (cs_colors[3], mode)); |
27583
315c35e6037c
use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27560
diff
changeset
|
255 |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
256 setScrollBufferSize (settings.int_value (cs_hist_buffer)); |
19690
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
18678
diff
changeset
|
257 |
27724
19e80f22aa47
provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27686
diff
changeset
|
258 // If the Copy shortcut is Ctrl+C, then the Copy action also emits |
19e80f22aa47
provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27686
diff
changeset
|
259 // a signal for interrupting the current code executed by the worker. |
19e80f22aa47
provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27686
diff
changeset
|
260 // If the Copy shortcut is not Ctrl+C, an extra interrupt action is |
19e80f22aa47
provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27686
diff
changeset
|
261 // set up for emitting the interrupt signal. |
19690
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
18678
diff
changeset
|
262 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
29783
diff
changeset
|
263 QString sc = settings.sc_value (sc_main_edit_copy); |
20146
f5e65f806123
fix checking copy shortcut in terminal when no setting available (bug #44968)
Torsten <ttl@justmail.de>
parents:
19943
diff
changeset
|
264 |
29393
ca1cc1bca9cb
fix interrupting the interpreter in the gui command window (bug #60079)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29150
diff
changeset
|
265 // Dis- or enable extra interrupt action: We need an extra option when |
ca1cc1bca9cb
fix interrupting the interpreter in the gui command window (bug #60079)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29150
diff
changeset
|
266 // copy shortcut is not Ctrl-C or when global shortcuts (like copy) are |
ca1cc1bca9cb
fix interrupting the interpreter in the gui command window (bug #60079)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29150
diff
changeset
|
267 // disabled. |
27724
19e80f22aa47
provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27686
diff
changeset
|
268 bool extra_ir_action |
29393
ca1cc1bca9cb
fix interrupting the interpreter in the gui command window (bug #60079)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29150
diff
changeset
|
269 = (sc != QKeySequence (Qt::ControlModifier | Qt::Key_C).toString ()) |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
270 || settings.bool_value (sc_prevent_rl_conflicts); |
27724
19e80f22aa47
provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27686
diff
changeset
|
271 |
19690
bd1369a2a651
add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents:
18678
diff
changeset
|
272 _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
|
273 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
|
274 |
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
275 // check whether shortcut Ctrl-D is in use by the main-window |
31709
3a23b89bd21d
define some convenience functions to reduce clutter
John W. Eaton <jwe@octave.org>
parents:
31702
diff
changeset
|
276 bool ctrld = settings.bool_value (sc_main_ctrld); |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20146
diff
changeset
|
277 _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
|
278 } |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
279 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
280 void |
32832
f3c1a77bcc6b
maint: Replace (void) in function declarations with () where possible
Arun Giridhar <arungiridhar@gmail.com>
parents:
32000
diff
changeset
|
281 QTerminal::construct () |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
282 { |
31621
0645ea65ca6b
handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
283 octave::gui_settings settings; |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
284 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
285 // context menu |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
286 setContextMenuPolicy (Qt::CustomContextMenu); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
287 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
288 _contextMenu = new QMenu (this); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
289 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
290 _copy_action |
31621
0645ea65ca6b
handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
291 = _contextMenu->addAction (settings.icon ("edit-copy"), tr ("Copy"), this, |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
292 SLOT (copyClipboard ())); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
293 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
294 _paste_action |
31621
0645ea65ca6b
handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
295 = _contextMenu->addAction (settings.icon ("edit-paste"), tr ("Paste"), this, |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
296 SLOT (pasteClipboard ())); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
297 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
298 _contextMenu->addSeparator (); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
299 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
300 _selectall_action |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
301 = _contextMenu->addAction (tr ("Select All"), this, SLOT (selectAll ())); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
302 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
303 _run_selection_action |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
304 = _contextMenu->addAction (tr ("Run Selection"), this, |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
305 SLOT (run_selection ())); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
306 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
307 m_edit_selected_action |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
308 = _contextMenu->addAction (tr ("Edit selection"), this, |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
309 SLOT (edit_selected ())); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
310 m_help_selected_action |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
311 = _contextMenu->addAction (tr ("Help on selection"), this, |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
312 SLOT (help_on_expression ())); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
313 m_doc_selected_action |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
314 = _contextMenu->addAction (tr ("Documentation on selection"), this, |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
315 SLOT (doc_on_expression ())); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
316 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
317 _edit_action = _contextMenu->addAction (tr (""), this, SLOT (edit_file ())); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
318 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
319 _contextMenu->addSeparator (); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
320 |
29783
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29691
diff
changeset
|
321 _contextMenu->addAction (tr ("Clear Window"), this, |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29691
diff
changeset
|
322 SIGNAL (clear_command_window_request ())); |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
323 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
324 connect (this, SIGNAL (customContextMenuRequested (QPoint)), |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
325 this, SLOT (handleCustomContextMenuRequested (QPoint))); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
326 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
327 // extra interrupt action |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
328 _interrupt_action = new QAction (this); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
329 addAction (_interrupt_action); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
330 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
331 _interrupt_action->setShortcut |
31995
49d21a7b25a8
Replace deprecated QKeyCombination::operator+ by QKeyCombination::operator|.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31709
diff
changeset
|
332 (QKeySequence (Qt::ControlModifier | Qt::Key_C)); |
29393
ca1cc1bca9cb
fix interrupting the interpreter in the gui command window (bug #60079)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29150
diff
changeset
|
333 _interrupt_action->setShortcutContext (Qt::WidgetWithChildrenShortcut); |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
334 |
29393
ca1cc1bca9cb
fix interrupting the interpreter in the gui command window (bug #60079)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29150
diff
changeset
|
335 bool ok = connect (_interrupt_action, SIGNAL (triggered ()), |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
336 this, SLOT (terminal_interrupt ())); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
337 |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
338 // dummy (nop) action catching Ctrl-D in terminal, no connection |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
339 _nop_action = new QAction (this); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
340 addAction (_nop_action); |
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
341 |
31995
49d21a7b25a8
Replace deprecated QKeyCombination::operator+ by QKeyCombination::operator|.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31709
diff
changeset
|
342 _nop_action->setShortcut (QKeySequence (Qt::ControlModifier | Qt::Key_D)); |
29393
ca1cc1bca9cb
fix interrupting the interpreter in the gui command window (bug #60079)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29150
diff
changeset
|
343 _nop_action->setShortcutContext (Qt::WidgetWithChildrenShortcut); |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
344 } |