Mercurial > octave-nkf
annotate libgui/qterminal/libqterminal/QTerminal.cc @ 16640:0ee7b4d1b940
* QTerminal.cc: Style fixes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 12 May 2013 15:33:05 -0400 |
parents | ba808cd9d86c |
children | 64f9a3e301d3 |
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 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
3 Copyright (C) 2012 Michael Goffioul. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
4 Copyright (C) 2012 Jacob Dawid. |
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 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
8 Foobar is free software: you can redistribute it and/or modify |
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 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
13 QTerminal is distributed in the hope that it will be useful, |
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 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
19 along with Foobar. If not, see <http://www.gnu.org/licenses/>. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
20 |
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 #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
|
24 |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
25 #if defined (Q_OS_WIN32) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
26 # include "win32/QWinTerminalImpl.h" |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
27 #else |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
28 # include "unix/QUnixTerminalImpl.h" |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
29 #endif |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
30 |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
31 QTerminal * |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
32 QTerminal::create (QWidget *xparent) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
33 { |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
34 #if defined (Q_OS_WIN32) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
35 return new QWinTerminalImpl (xparent); |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
36 #else |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
37 return new QUnixTerminalImpl (xparent); |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
38 #endif |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
39 } |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
40 |
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
|
41 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
|
42 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
|
43 { |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
44 // 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
|
45 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
46 // Set terminal font: |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
47 QFont term_font = QFont (); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
48 term_font.setFamily |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
49 (settings->value ("terminal/fontName", "Courier New").toString ()); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
50 |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
51 term_font.setPointSize (settings->value ("terminal/fontSize", 10).toInt ()); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
52 |
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
|
53 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
|
54 |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
55 QString cursorType |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
56 = settings->value ("terminal/cursorType", "ibeam").toString (); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
57 |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
58 bool cursorBlinking |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
59 = settings->value ("terminal/cursorBlinking", true).toBool (); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
60 |
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
|
61 if (cursorType == "ibeam") |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
62 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
|
63 else if (cursorType == "block") |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
64 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
|
65 else if (cursorType == "underline") |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
66 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
|
67 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
68 bool cursorUseForegroundColor |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
69 = 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
|
70 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
71 // FIXME -- we shouldn't duplicate this information here and in the |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
72 // resource manager. |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
73 QList<QColor> default_colors; |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
74 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
75 default_colors << QColor(0,0,0) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
76 << QColor(255,255,255) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
77 << QColor(192,192,192) |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
78 << QColor(128,128,128); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
79 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
80 setForegroundColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
81 (settings->value ("terminal/color_f", |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
82 QVariant (default_colors.at (0))).value<QColor> ()); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
83 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
84 setBackgroundColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
85 (settings->value ("terminal/color_b", |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
86 QVariant (default_colors.at (1))).value<QColor> ()); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
87 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
88 setSelectionColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
89 (settings->value ("terminal/color_s", |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
90 QVariant (default_colors.at (2))).value<QColor> ()); |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
91 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
92 setCursorColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
93 (cursorUseForegroundColor, |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
94 settings->value ("terminal/color_c", |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
95 QVariant (default_colors.at (3))).value<QColor> ()); |
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
|
96 } |