1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "terminalsettings.h"
#include "terminaltr.h"
#include <utils/environment.h>
#include <utils/hostosinfo.h>
#include <utils/theme/theme.h>
using namespace Utils;
namespace Terminal {
static QString defaultFontFamily()
{
if (HostOsInfo::isMacHost())
return QLatin1String("Menlo");
if (Utils::HostOsInfo::isAnyUnixHost())
return QLatin1String("Monospace");
return QLatin1String("Consolas");
}
static int defaultFontSize()
{
if (Utils::HostOsInfo::isMacHost())
return 12;
if (Utils::HostOsInfo::isAnyUnixHost())
return 9;
return 10;
}
static QString defaultShell()
{
if (HostOsInfo::isWindowsHost())
return qtcEnvironmentVariable("COMSPEC");
QString defaultShell = qtcEnvironmentVariable("SHELL");
if (FilePath::fromUserInput(defaultShell).isExecutableFile())
return defaultShell;
Utils::FilePath shPath = Utils::Environment::systemEnvironment().searchInPath("sh");
return shPath.nativePath();
}
TerminalSettings &TerminalSettings::instance()
{
static TerminalSettings settings;
return settings;
}
void setupColor(TerminalSettings *settings,
ColorAspect &color,
const QString &label,
const QColor &defaultColor)
{
color.setSettingsKey(label);
color.setDefaultValue(defaultColor);
color.setToolTip(Tr::tr("The color used for %1.").arg(label));
settings->registerAspect(&color);
}
TerminalSettings::TerminalSettings()
{
setAutoApply(false);
setSettingsGroup("Terminal");
enableTerminal.setSettingsKey("EnableTerminal");
enableTerminal.setLabelText(Tr::tr("Use internal terminal"));
enableTerminal.setToolTip(
Tr::tr("If enabled, use the internal terminal when \"Run In Terminal\" is "
"enabled and for \"Open Terminal here\"."));
enableTerminal.setDefaultValue(true);
font.setSettingsKey("FontFamily");
font.setLabelText(Tr::tr("Family:"));
font.setHistoryCompleter("Terminal.Fonts.History");
font.setToolTip(Tr::tr("The font family used in the terminal."));
font.setDefaultValue(defaultFontFamily());
fontSize.setSettingsKey("FontSize");
fontSize.setLabelText(Tr::tr("Size:"));
fontSize.setToolTip(Tr::tr("The font size used in the terminal. (in points)"));
fontSize.setDefaultValue(defaultFontSize());
fontSize.setRange(1, 100);
allowBlinkingCursor.setSettingsKey("AllowBlinkingCursor");
allowBlinkingCursor.setLabelText(Tr::tr("Allow blinking cursor"));
allowBlinkingCursor.setToolTip(Tr::tr("Allow the cursor to blink."));
allowBlinkingCursor.setDefaultValue(false);
shell.setSettingsKey("ShellPath");
shell.setLabelText(Tr::tr("Shell path:"));
shell.setExpectedKind(PathChooser::ExistingCommand);
shell.setDisplayStyle(StringAspect::PathChooserDisplay);
shell.setHistoryCompleter("Terminal.Shell.History");
shell.setToolTip(Tr::tr("The shell executable to be started."));
shell.setDefaultValue(defaultShell());
shellArguments.setSettingsKey("ShellArguments");
shellArguments.setLabelText(Tr::tr("Shell arguments:"));
shellArguments.setDisplayStyle(StringAspect::LineEditDisplay);
shellArguments.setHistoryCompleter("Terminal.Shell.History");
shellArguments.setToolTip(Tr::tr("The arguments to be passed to the shell."));
if (!HostOsInfo::isWindowsHost())
shellArguments.setDefaultValue(QString("-l"));
sendEscapeToTerminal.setSettingsKey("SendEscapeToTerminal");
sendEscapeToTerminal.setLabelText(Tr::tr("Send escape key to terminal"));
sendEscapeToTerminal.setToolTip(
Tr::tr("If enabled, pressing the escape key will send it to the terminal "
"instead of closing the terminal."));
sendEscapeToTerminal.setDefaultValue(false);
audibleBell.setSettingsKey("AudibleBell");
audibleBell.setLabelText(Tr::tr("Audible bell"));
audibleBell.setToolTip(Tr::tr("If enabled, the terminal will beep when a bell "
"character is received."));
audibleBell.setDefaultValue(true);
registerAspect(&font);
registerAspect(&fontSize);
registerAspect(&shell);
registerAspect(&allowBlinkingCursor);
registerAspect(&enableTerminal);
registerAspect(&sendEscapeToTerminal);
registerAspect(&audibleBell);
registerAspect(&shellArguments);
setupColor(this,
foregroundColor,
"Foreground",
Utils::creatorTheme()->color(Theme::TerminalForeground));
setupColor(this,
backgroundColor,
"Background",
Utils::creatorTheme()->color(Theme::TerminalBackground));
setupColor(this,
selectionColor,
"Selection",
Utils::creatorTheme()->color(Theme::TerminalSelection));
setupColor(this,
findMatchColor,
"Find matches",
Utils::creatorTheme()->color(Theme::TerminalFindMatch));
setupColor(this, colors[0], "0", Utils::creatorTheme()->color(Theme::TerminalAnsi0));
setupColor(this, colors[8], "8", Utils::creatorTheme()->color(Theme::TerminalAnsi8));
setupColor(this, colors[1], "1", Utils::creatorTheme()->color(Theme::TerminalAnsi1));
setupColor(this, colors[9], "9", Utils::creatorTheme()->color(Theme::TerminalAnsi9));
setupColor(this, colors[2], "2", Utils::creatorTheme()->color(Theme::TerminalAnsi2));
setupColor(this, colors[10], "10", Utils::creatorTheme()->color(Theme::TerminalAnsi10));
setupColor(this, colors[3], "3", Utils::creatorTheme()->color(Theme::TerminalAnsi3));
setupColor(this, colors[11], "11", Utils::creatorTheme()->color(Theme::TerminalAnsi11));
setupColor(this, colors[4], "4", Utils::creatorTheme()->color(Theme::TerminalAnsi4));
setupColor(this, colors[12], "12", Utils::creatorTheme()->color(Theme::TerminalAnsi12));
setupColor(this, colors[5], "5", Utils::creatorTheme()->color(Theme::TerminalAnsi5));
setupColor(this, colors[13], "13", Utils::creatorTheme()->color(Theme::TerminalAnsi13));
setupColor(this, colors[6], "6", Utils::creatorTheme()->color(Theme::TerminalAnsi6));
setupColor(this, colors[14], "14", Utils::creatorTheme()->color(Theme::TerminalAnsi14));
setupColor(this, colors[7], "7", Utils::creatorTheme()->color(Theme::TerminalAnsi7));
setupColor(this, colors[15], "15", Utils::creatorTheme()->color(Theme::TerminalAnsi15));
}
} // namespace Terminal
|