annotate libgui/qterminal/libqterminal/QTerminal.cc @ 18678:6113e0c6920b

maint: Clean up extra spaces before/after parentheses.
author Rik <rik@octave.org>
date Fri, 25 Apr 2014 13:25:25 -0700
parents 6e81b59d657c
children
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
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17508
diff changeset
3 Copyright (C) 2012-2013 Michael Goffioul.
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17508
diff changeset
4 Copyright (C) 2012-2013 Jacob Dawid.
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
5
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
6 This file is part of QTerminal.
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
7
17795
0a8c35ae5ce1 maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents: 17744
diff changeset
8 This program is free software: you can redistribute it and/or modify
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
11 (at your option) any later version.
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
12
17795
0a8c35ae5ce1 maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents: 17744
diff changeset
13 This program is distributed in the hope that it will be useful,
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
16 GNU General Public License for more details.
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
17
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
17795
0a8c35ae5ce1 maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents: 17744
diff changeset
19 along with this program. If not,
0a8c35ae5ce1 maint: Fix various problems with GPL copyright statements.
Rik <rik@octave.org>
parents: 17744
diff changeset
20 see <http://www.gnu.org/licenses/>.
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
21
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
22 */
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
23
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
24 #include "QTerminal.h"
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
25
16639
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
26 #if defined (Q_OS_WIN32)
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
27 # include "win32/QWinTerminalImpl.h"
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
28 #else
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
29 # include "unix/QUnixTerminalImpl.h"
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
30 #endif
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
31
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
32 QTerminal *
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
33 QTerminal::create (QWidget *xparent)
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
34 {
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
35 #if defined (Q_OS_WIN32)
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
36 return new QWinTerminalImpl (xparent);
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
37 #else
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
38 return new QUnixTerminalImpl (xparent);
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
39 #endif
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
40 }
ba808cd9d86c simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents: 16620
diff changeset
41
16641
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
42 QList<QColor>
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
43 QTerminal::default_colors (void)
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
44 {
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
45 static QList<QColor> colors;
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
46
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
47 if (colors.isEmpty ())
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
48 {
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
49 colors << QColor(0,0,0)
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
50 << QColor(255,255,255)
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
51 << QColor(192,192,192)
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
52 << QColor(128,128,128);
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
53 }
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
54
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
55 return colors;
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
56 }
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
57
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
58 QStringList
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
59 QTerminal::color_names (void)
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
60 {
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
61 static QStringList names;
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
62
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
63 if (names.isEmpty ())
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
64 {
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
65 names << QObject::tr ("foreground")
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
66 << QObject::tr ("background")
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
67 << QObject::tr ("selection")
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
68 << QObject::tr ("cursor");
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
69 }
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
70
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
71 return names;
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
72 }
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
73
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
74 void
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
75 QTerminal::notice_settings (const QSettings *settings)
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
76 {
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
77 // QSettings pointer is checked before emitting.
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
78
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
79 // Set terminal font:
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
80 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
81 term_font.setStyleHint (QFont::TypeWriter);
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
82 term_font.setFamily
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
83 (settings->value ("terminal/fontName", "Courier New").toString ());
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
84 term_font.setPointSize (settings->value ("terminal/fontSize", 10).toInt ());
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
85 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
86
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
87 QString cursorType
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
88 = settings->value ("terminal/cursorType", "ibeam").toString ();
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
89
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
90 bool cursorBlinking
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
91 = settings->value ("terminal/cursorBlinking", true).toBool ();
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
92
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
93 if (cursorType == "ibeam")
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
94 setCursorType (QTerminal::IBeamCursor, cursorBlinking);
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
95 else if (cursorType == "block")
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
96 setCursorType (QTerminal::BlockCursor, cursorBlinking);
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
97 else if (cursorType == "underline")
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
98 setCursorType (QTerminal::UnderlineCursor, cursorBlinking);
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
99
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
100 bool cursorUseForegroundColor
16640
0ee7b4d1b940 * QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16639
diff changeset
101 = settings->value ("terminal/cursorUseForegroundColor", true).toBool ();
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
102
16641
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
103 QList<QColor> colors = default_colors ();
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
104
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
105 setForegroundColor
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
106 (settings->value ("terminal/color_f",
16641
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
107 QVariant (colors.at (0))).value<QColor> ());
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
108
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
109 setBackgroundColor
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
110 (settings->value ("terminal/color_b",
16641
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
111 QVariant (colors.at (1))).value<QColor> ());
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
112
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
113 setSelectionColor
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
114 (settings->value ("terminal/color_s",
16641
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
115 QVariant (colors.at (2))).value<QColor> ());
16620
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
116
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
117 setCursorColor
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
118 (cursorUseForegroundColor,
818eef7b2618 allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
119 settings->value ("terminal/color_c",
16641
64f9a3e301d3 don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents: 16640
diff changeset
120 QVariant (colors.at (3))).value<QColor> ());
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18610
diff changeset
121 setScrollBufferSize (settings->value ("terminal/history_buffer",1000).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
122 }