annotate libgui/src/terminal-dock-widget.cc @ 27919:1891570abac8

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2020.
author John W. Eaton <jwe@octave.org>
date Mon, 06 Jan 2020 22:29:51 -0500
parents b442ec6dda5c
children bd51beb6205e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
1 /*
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
2
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 Copyright (C) 2011-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27672
diff changeset
4
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27672
diff changeset
5 See the file COPYRIGHT.md in the top-level directory of this distribution
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27672
diff changeset
6 or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27672
diff changeset
7
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
8
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
9 This file is part of Octave.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
10
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24011
diff changeset
11 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24011
diff changeset
13 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
14 (at your option) any later version.
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
15
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
16 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
19 GNU General Public License for more details.
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
20
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
21 You should have received a copy of the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
22 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24011
diff changeset
23 <https://www.gnu.org/licenses/>.
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
24
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
25 */
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
26
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
27 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
28 # include "config.h"
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
29 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
30
24791
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
31 #include <QDesktopWidget>
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
32
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
33 #include "gui-preferences-cs.h"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
34 #include "gui-preferences-global.h"
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
35 #include "octave-qobject.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27281
diff changeset
36 #include "terminal-dock-widget.h"
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27281
diff changeset
37
25277
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
38 #include "quit.h"
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
39 #include "signal-wrappers.h"
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
40
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
41 #include "sighandlers.h"
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
42
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
43 namespace octave
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
44 {
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
45 terminal_dock_widget::terminal_dock_widget (QWidget *p,
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
46 base_qobject& oct_qobj)
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
47 : octave_dock_widget ("TerminalDockWidget", p, oct_qobj),
27648
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
48 m_terminal (QTerminal::create (oct_qobj, p))
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
49 {
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
50 m_terminal->setObjectName ("OctaveTerminal");
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
51 m_terminal->setFocusPolicy (Qt::StrongFocus);
17920
5c3f22dd0bbb raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents: 17790
diff changeset
52
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
53 setWindowIcon (QIcon (":/actions/icons/logo.png"));
25508
3edae6ba1fcd use a custom title bar widget for the main dock widgets
Torsten <mttl@mailbox.org>
parents: 25355
diff changeset
54 set_title (tr ("Command Window"));
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
55
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
56 setWidget (m_terminal);
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
57 setFocusProxy (m_terminal);
23808
2b1b2a795ba6 update clickable urls in terminal also when visible terminal has no focus
Torsten <mttl@mailbox.org>
parents: 23220
diff changeset
58
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
59 connect (m_terminal, SIGNAL (interrupt_signal (void)),
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
60 this, SLOT (terminal_interrupt (void)));
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
61
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
62 // Connect the visibility signal to the terminal for dis-/enabling timers
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
63 connect (this, SIGNAL (visibilityChanged (bool)),
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
64 m_terminal, SLOT (handle_visibility_changed (bool)));
24791
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
65
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
66 // Chose a reasonable size at startup in order to avoid truncated
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
67 // startup messages
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
68 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
69 gui_settings *settings = rmgr.get_settings ();
24791
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
70
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
71 QFont font = QFont ();
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
72 font.setStyleHint (QFont::TypeWriter);
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27648
diff changeset
73 QString default_font = settings->value (global_mono_font).toString ();
24791
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
74 font.setFamily
26008
38a881b8fbec do not use courier new as default font (bug #54086)
Torsten <mttl@mailbox.org>
parents: 25508
diff changeset
75 (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
76 font.setPointSize
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27648
diff changeset
77 (settings->value (cs_font_size).toInt ());
24791
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
78
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
79 QFontMetrics metrics(font);
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
80
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
81 int win_x = metrics.maxWidth()*80;
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
82 int win_y = metrics.height()*25;
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
83
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
84 int max_x = QApplication::desktop ()->screenGeometry (this).width ();
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
85 int max_y = QApplication::desktop ()->screenGeometry (this).height ();
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
86
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
87 if (win_x > max_x)
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
88 win_x = max_x;
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
89 if (win_y > max_y)
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
90 win_y = max_y;
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
91
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
92 setGeometry (0, 0, win_x, win_y);
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
93 }
24011
9107bae20480 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23808
diff changeset
94
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
95 terminal_dock_widget::~terminal_dock_widget (void)
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
96 {
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
97 delete m_terminal;
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
98 }
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
99
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
100 bool terminal_dock_widget::has_focus (void) const
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
101 {
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
102 QWidget *w = widget ();
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
103
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
104 return w->hasFocus ();
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
105 }
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
106
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
107 void terminal_dock_widget::terminal_interrupt (void)
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
108 {
25275
4adeabc1bbfe improve Ctrl-C interrupt handling in the GUI (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
109 // FIXME: Protect with mutex?
4adeabc1bbfe improve Ctrl-C interrupt handling in the GUI (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
110
4adeabc1bbfe improve Ctrl-C interrupt handling in the GUI (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
111 octave_signal_caught = 1;
4adeabc1bbfe improve Ctrl-C interrupt handling in the GUI (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
112 octave_interrupt_state++;
25277
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
113
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
114 // Send SIGINT to all other processes in our process group.
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
115 // This is needed to interrupt calls to system (), for example.
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
116
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
117 int sigint;
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
118 octave_get_sig_number ("SIGINT", &sigint);
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
119
692fbde19871 restore ability to interrupt subprocesses on Unixy systems (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25275
diff changeset
120 octave_kill_wrapper (0, sigint);
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
121 }
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
122 }