annotate libgui/qterminal/libqterminal/QTerminal.cc @ 27648:2952471e29a7

eliminate global access to resource_manager in qterminal widget * QTerminal.h, QTerminal.cc (QTerminal::create): Accept reference to octave_qobject. Change all uses. Call construct to set up signal/slot connections and context menu after creating object. (QTerminal::construct): New function. Move body of QTerminal constructor here. * libgui/qterminal/module.mk: Use full list of CPPFLAGS for interpreter directories.
author John W. Eaton <jwe@octave.org>
date Wed, 06 Nov 2019 14:29:42 -0500
parents 0495b64288f7
children 959a63d1ede6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
27648
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
24 #include <QKeySequence>
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
25 #include <QWidget>
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
26 #include <QStringList>
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
27 #include <QColor>
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
28 #include <QList>
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
29 #include <QMenu>
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
30 #include <QClipboard>
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
31 #include <QApplication>
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
32 #include <QAction>
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
33
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27288
diff changeset
34 #include "gui-preferences-cs.h"
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
35 #include "gui-preferences-sc.h"
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27288
diff changeset
36 #include "gui-preferences-global.h"
27648
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
37 #include "octave-qobject.h"
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
38 #include "resource-manager.h"
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27288
diff changeset
39
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
40 #include "QTerminal.h"
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
41 #if defined (Q_OS_WIN32)
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
42 # include "win32/QWinTerminalImpl.h"
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
43 #else
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
44 # include "unix/QUnixTerminalImpl.h"
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
45 #endif
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
46
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
47 QTerminal *
27648
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
48 QTerminal::create (octave::base_qobject& oct_qobj, QWidget *xparent)
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
49 {
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
50 #if defined (Q_OS_WIN32)
27648
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
51 QTerminal *terminal = new QWinTerminalImpl (xparent);
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
52 #else
27648
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
53 QTerminal *terminal = new QUnixTerminalImpl (xparent);
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
54 #endif
27648
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
55
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
56 // FIXME: this function should probably be called from or part of the
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
57 // QTerminal constructor, but I think that would mean some major
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
58 // surgery because then the constructor for QTerminal and the derived
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
59 // Unix- and Windows-specific versions would need access to the
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
60 // base_qobject object, or the design would have to change significantly.
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
61
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
62 terminal->construct (oct_qobj, xparent);
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
63
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
64 return terminal;
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
65 }
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
66
19943
88233ac3f3ea fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents: 19697
diff changeset
67 // 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
68 void
88233ac3f3ea fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents: 19697
diff changeset
69 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
70 {
88233ac3f3ea fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents: 19697
diff changeset
71 if (focus_out)
20987
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20146
diff changeset
72 {
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20146
diff changeset
73 _interrupt_action->setShortcut (QKeySequence ());
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20146
diff changeset
74 _nop_action->setShortcut (QKeySequence ());
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20146
diff changeset
75 }
19943
88233ac3f3ea fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents: 19697
diff changeset
76 else
20987
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20146
diff changeset
77 {
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
78 _interrupt_action->setShortcut
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
79 (QKeySequence (Qt::ControlModifier | Qt::Key_C));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
80
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
81 _nop_action->setShortcut
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
82 (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
83 }
19943
88233ac3f3ea fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents: 19697
diff changeset
84 }
88233ac3f3ea fix issue with ctrl-c for copying when editor has focus and is docked
Torsten <ttl@justmail.de>
parents: 19697
diff changeset
85
20995
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
86 // 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
87 void
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
88 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
89 {
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
90 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
91 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
92 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
93
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
94 _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
95 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
96 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
97 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
98
23404
314ac710f2ae highlight error messages in gui and provide links to open files (bug #35619)
Torsten <mttl@mailbox.org>
parents: 23403
diff changeset
99 #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
100 // 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
101 // 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
102 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
103 {
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
104 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
105
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
106 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
107
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
108 if (pos > -1)
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
109 {
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
110 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
111 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
112
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
113 _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
114 _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
115 .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
116
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
117 QStringList data;
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
118 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
119 _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
120 }
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
121 }
23404
314ac710f2ae highlight error messages in gui and provide links to open files (bug #35619)
Torsten <mttl@mailbox.org>
parents: 23403
diff changeset
122 #endif
20995
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
123
27288
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
124 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
125 {
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
126 QRegExp expr (".*\b*(\\w+)\b*.*");
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
127
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
128 int pos = expr.indexIn (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
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 if (pos > -1)
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
131 {
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
132 QString expr_found = expr.cap (1);
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
133
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
134 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
135 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
136 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
137
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
138 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
139 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
140 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
141
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
142 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
143 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
144 .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
145 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
146 }
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
147 }
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
148
20995
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
149 _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
150 _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
151 _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
152
23403
fee531225679 make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents: 23219
diff changeset
153 // 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
154 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
155 if (actions.length ())
fee531225679 make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents: 23219
diff changeset
156 _contextMenu->addSeparator ();
fee531225679 make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents: 23219
diff changeset
157 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
158 _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
159
fee531225679 make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents: 23219
diff changeset
160 // 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
161 _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
162
fee531225679 make url in the console window clickable under linux (bug #41076)
Torsten <mttl@mailbox.org>
parents: 23219
diff changeset
163 // 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
164 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
165 _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
166 }
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
167
25813
d98d7df9fd15 updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents: 25054
diff changeset
168 // 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
169 void
d98d7df9fd15 updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents: 25054
diff changeset
170 QTerminal::run_selection ()
d98d7df9fd15 updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents: 25054
diff changeset
171 {
d98d7df9fd15 updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents: 25054
diff changeset
172 QStringList commands = selectedText ().split (QRegExp ("[\r\n]"),
d98d7df9fd15 updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents: 25054
diff changeset
173 QString::SkipEmptyParts);
d98d7df9fd15 updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents: 25054
diff changeset
174 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
175 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
176
d98d7df9fd15 updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents: 25054
diff changeset
177 }
d98d7df9fd15 updated context menus in editor and console window (bug #46884)
Torsten <mttl@mailbox.org>
parents: 25054
diff changeset
178
20995
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
179 // 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
180 void
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
181 QTerminal::edit_file ()
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
182 {
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
183 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
184 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
185
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
186 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
187 }
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20987
diff changeset
188
27288
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
189 // 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
190 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
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 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
193
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
194 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
195 }
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
196
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
197 // 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
198 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
199 {
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
200 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
201
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
202 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
203 }
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 // 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
206 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
207 {
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
208 QString expr = m_doc_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
209
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
210 emit show_doc_signal (expr);
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
211 }
0a2e5c808709 allow editing and showing help on selected text in console (bug #41276)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27276
diff changeset
212
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
213 void
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
214 QTerminal::notice_settings (const 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
215 {
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
216 if (! settings)
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
217 return;
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
218
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 // Set terminal font:
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
220 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
221 term_font.setStyleHint (QFont::TypeWriter);
26008
38a881b8fbec do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents: 25869
diff changeset
222 QString default_font = settings->value (global_mono_font.key, global_mono_font.def).toString ();
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
223 term_font.setFamily
26008
38a881b8fbec do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents: 25869
diff changeset
224 (settings->value (cs_font.key, default_font).toString ());
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
225 term_font.setPointSize
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
226 (settings->value (cs_font_size.key, cs_font_size.def).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
227 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
228
25869
462066384af3 fix minimum size of console widget in gui (bug54620)
Torsten <mttl@mailbox.org>
parents: 25813
diff changeset
229 QFontMetrics metrics (term_font);
462066384af3 fix minimum size of console widget in gui (bug54620)
Torsten <mttl@mailbox.org>
parents: 25813
diff changeset
230 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
231
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
232 QString cursor_type
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
233 = settings->value (cs_cursor.key, cs_cursor.def).toString ();
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
234
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
235 bool cursor_blinking;
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
236 if (settings->contains (global_cursor_blinking.key))
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
237 cursor_blinking = settings->value (global_cursor_blinking.key,
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
238 global_cursor_blinking.def).toBool ();
23810
9c24aae7515f allow cursor flashing to be configured globally in gui (bug #51460)
Torsten <mttl@mailbox.org>
parents: 23404
diff changeset
239 else
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
240 cursor_blinking = settings->value (cs_cursor_blinking.key,
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
241 cs_cursor_blinking.def).toBool ();
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
242
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
243 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
244 {
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
245 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
246 {
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
247 setCursorType ((CursorType) ct, cursor_blinking);
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
248 break;
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
249 }
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
250 }
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
251
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
252 bool cursorUseForegroundColor
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
253 = settings->value (cs_cursor_use_fgcol.key, cs_cursor_use_fgcol.def).toBool ();
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
254
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
255 setForegroundColor
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
256 (settings->value (cs_colors[0].key, cs_colors[0].def).value<QColor> ());
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
257
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
258 setBackgroundColor
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
259 (settings->value (cs_colors[1].key, cs_colors[1].def).value<QColor> ());
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
260
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
261 setSelectionColor
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
262 (settings->value (cs_colors[2].key, cs_colors[2].def).value<QColor> ());
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
263
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
264 setCursorColor (cursorUseForegroundColor,
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
265 settings->value (cs_colors[3].key, cs_colors[3].def).value<QColor> ());
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
266
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
267 setScrollBufferSize (settings->value (cs_hist_buffer.key,
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
268 cs_hist_buffer.def).toInt ());
19690
bd1369a2a651 add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents: 18678
diff changeset
269
20987
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20146
diff changeset
270 // 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
271 QKeySequence sc;
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
272 sc = QKeySequence (settings->value (sc_main_edit_copy.key,
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
273 sc_main_edit_copy.def).toString ());
19690
bd1369a2a651 add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents: 18678
diff changeset
274
20987
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20146
diff changeset
275 // 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
276 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
277 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
278
19690
bd1369a2a651 add extra action for interrupting with Ctrl-C (bug #44204)
Torsten <ttl@justmail.de>
parents: 18678
diff changeset
279 // dis- or enable extra interrupt action
22250
2fd4f1a3f4a8 allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents: 20995
diff changeset
280 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
281 _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
282 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
283
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20146
diff changeset
284 // check whether shortcut Ctrl-D is in use by the main-window
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27560
diff changeset
285 bool ctrld = settings->value (sc_main_ctrld.key, sc_main_ctrld.def).toBool ();
20987
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20146
diff changeset
286 _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
287 }
27648
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
288
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
289 void
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
290 QTerminal::construct (octave::base_qobject& oct_qobj, QWidget *xparent)
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
291 {
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
292 octave::resource_manager& rmgr = oct_qobj.get_resource_manager ();
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 // context menu
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
295 setContextMenuPolicy (Qt::CustomContextMenu);
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
296
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
297 _contextMenu = new QMenu (this);
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
298
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
299 _copy_action
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
300 = _contextMenu->addAction (rmgr.icon ("edit-copy"), tr ("Copy"), this,
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
301 SLOT (copyClipboard ()));
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 _paste_action
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
304 = _contextMenu->addAction (rmgr.icon ("edit-paste"), tr ("Paste"), this,
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
305 SLOT (pasteClipboard ()));
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 _contextMenu->addSeparator ();
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
308
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
309 _selectall_action
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
310 = _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
311
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
312 _run_selection_action
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
313 = _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
314 SLOT (run_selection ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
315
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
316 m_edit_selected_action
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
317 = _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
318 SLOT (edit_selected ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
319 m_help_selected_action
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
320 = _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
321 SLOT (help_on_expression ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
322 m_doc_selected_action
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
323 = _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
324 SLOT (doc_on_expression ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
325
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
326 _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
327
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
328 _contextMenu->addSeparator ();
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
329
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
330 _contextMenu->addAction (tr ("Clear Window"), parent (),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
331 SLOT (handle_clear_command_window_request ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
332
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
333 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
334 this, SLOT (handleCustomContextMenuRequested (QPoint)));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
335
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
336 connect (this, SIGNAL (report_status_message (const QString&)),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
337 xparent, SLOT (report_status_message (const QString&)));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
338
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
339 connect (this, SIGNAL (show_doc_signal (const QString&)),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
340 xparent, SLOT (handle_show_doc (const QString&)));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
341
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
342 connect (this, SIGNAL (edit_mfile_request (const QString&, int)),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
343 xparent, SLOT (edit_mfile (const QString&, int)));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
344
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
345 connect (this, SIGNAL (execute_command_in_terminal_signal (const QString&)),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
346 xparent, SLOT (execute_command_in_terminal (const QString&)));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
347
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
348 connect (xparent, SIGNAL (settings_changed (const gui_settings *)),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
349 this, SLOT (notice_settings (const gui_settings *)));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
350
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
351 connect (xparent, SIGNAL (init_terminal_size_signal ()),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
352 this, SLOT (init_terminal_size ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
353
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
354 connect (xparent, SIGNAL (copyClipboard_signal ()),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
355 this, SLOT (copyClipboard ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
356
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
357 connect (xparent, SIGNAL (pasteClipboard_signal ()),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
358 this, SLOT (pasteClipboard ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
359
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
360 connect (xparent, SIGNAL (selectAll_signal ()),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
361 this, SLOT (selectAll ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
362
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
363 // extra interrupt action
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
364 _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
365 addAction (_interrupt_action);
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
366
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
367 _interrupt_action->setShortcut
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
368 (QKeySequence (Qt::ControlModifier + Qt::Key_C));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
369
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
370 connect (_interrupt_action, SIGNAL (triggered ()),
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
371 this, SLOT (terminal_interrupt ()));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
372
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
373 // 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
374 _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
375 addAction (_nop_action);
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
376
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
377 _nop_action->setShortcut (QKeySequence (Qt::ControlModifier + Qt::Key_D));
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
378 }