45
43
class ProfileGroup;
48
* Represents a terminal set-up which can be used to
46
* Represents a terminal set-up which can be used to
49
47
* set the initial state of new terminal sessions or applied
50
48
* to existing sessions. Profiles consist of a number of named
51
49
* properties, which can be retrieved using property() and
55
53
* Profiles support a simple form of inheritance. When a new Profile
56
54
* is constructed, a pointer to a parent profile can be passed to
57
55
* the constructor. When querying a particular property of a profile
58
* using property(), the profile will return its own value for that
56
* using property(), the profile will return its own value for that
59
57
* property if one has been set or otherwise it will return the
60
* parent's value for that property.
58
* parent's value for that property.
62
60
* Profiles can be loaded from disk using ProfileReader instances
63
61
* and saved to disk using ProfileWriter instances.
87
85
/** (QString) The descriptive name of this profile. */
89
/** (QString) Title of this profile that will be displayed. */
91
/** (QString) The name of the icon associated with this profile. This
92
* is used in menus and tabs to represent the profile.
87
/** (QString) The name of the icon associated with this profile. This
88
* is used in menus and tabs to represent the profile.
95
91
/** (QString) The command to execute ( excluding arguments ) when creating a new terminal
99
95
/** (QStringList) The arguments which are passed to the program specified by
100
96
* the Command property when creating a new terminal session using this profile.
103
99
/** (QStringList) Additional environment variables ( in the form of NAME=VALUE pairs )
104
100
* which are passed to the program specified by the Command property
105
* when creating a new terminal session using this profile.
101
* when creating a new terminal session using this profile.
108
/** (QString) The initial working directory for sessions created using this profile. */
104
/** (QString) The initial working directory for sessions created using this profile. */
110
106
/** (QString) The format used for tab titles when running normal commands. */
111
107
LocalTabTitleFormat,
112
/** (QString) The format used for tab titles when the session is running
113
* a remote command (eg. SSH) */
108
/** (QString) The format used for tab titles when the session is running
109
* a remote command (eg. SSH) */
114
110
RemoteTabTitleFormat,
115
111
/** (bool) Specifies whether the menu bar should be shown in the main application window. */
113
/** (bool) Specifies whether show hint for terminal size after resizing the application window. */
114
ShowTerminalSizeHint,
115
/** (bool) Specifies whether the geometry information is saved when window is closed. */
117
116
SaveGeometryOnExit,
118
117
/** (TabBarModeEnum) Specifies when the tab bar should be shown in
119
* the main application window. */
118
* the main application window. */
121
120
/** (QFont) The font to use in terminal displays using this profile. */
124
* The name of the color scheme to use in terminal displays using this profile.
125
* Color schemes are managed by the ColorSchemeManager class.
123
* The name of the color scheme to use in terminal displays using this profile.
124
* Color schemes are managed by the ColorSchemeManager class.
128
/** (QString) The name of the key bindings.
129
* Key bindings are managed by the KeyboardTranslatorManager class.
127
/** (QString) The name of the key bindings.
128
* Key bindings are managed by the KeyboardTranslatorManager class.
132
131
/** (HistoryModeEnum) Specifies the storage type used for keeping the output produced
138
137
* Only applicable if the HistoryMode property is FixedSizeHistory
141
/** (ScrollBarPositionEnum) Specifies the position of the scroll bar in
140
/** (ScrollBarPositionEnum) Specifies the position of the scroll bar in
142
141
* terminal displays using this profile.
144
143
ScrollBarPosition,
148
147
BlinkingTextEnabled,
149
148
/** (bool) Specifies whether the flow control keys ( typically Ctrl+S , Ctrl+Q )
150
149
* have any effect. Also known as Xon/Xoff
152
151
FlowControlEnabled,
153
/** (bool) Specifies whether programs running in the terminal are allowed to
154
* resize the terminal display.
152
/** (bool) Specifies whether programs running in the terminal are allowed to
153
* resize the terminal display.
156
155
AllowProgramsToResizeWindow,
157
/** (bool) Specifies whether the cursor blinks ( in a manner similar
156
/** (bool) Specifies whether the cursor blinks ( in a manner similar
158
157
* to text editing applications )
160
159
BlinkingCursorEnabled,
163
162
* color to match the character underneath it.
165
164
UseCustomCursorColor,
166
/** (CursorShapeEnum) The shape used by terminal displays to represent the cursor. */
165
/** (CursorShapeEnum) The shape used by terminal displays to represent the cursor. */
168
167
/** (QColor) The color used by terminal displays to draw the cursor. Only applicable
169
* if the UseCustomCursorColor property is true. */
168
* if the UseCustomCursorColor property is true. */
170
169
CustomCursorColor,
171
170
/** (QString) A string consisting of the characters used to delimit words when
172
171
* selecting text in the terminal display.
175
174
/** (TabBarPositionEnum) Position of the tab-bar relative to the terminal displays. */
177
/** (bool) If true, the triple click selects from current word onwards. Otherwise
178
* selects whole line.
176
/** (NewTabBehaviorEnum) Specifies where the newly created tab should be placed. */
178
/** (TripleClickModeEnum) Specifies which part of current line should be
179
* selected with triple click action.
181
182
/** (bool) If true, text that matches a link or an email address is underlined when
187
188
/** (bool) Whether fonts should be aliased or not */
189
/** (bool) Whether new sessions should be started in the same directory as the
190
* currently active session. */
192
190
/** (bool) Whether character with intense colors should be rendered in bold font
193
191
* or just in bright color. */
193
/** (bool) Whether new sessions should be started in the same directory as the
194
* currently active session. */
194
195
StartInCurrentSessionDir,
195
196
/** (bool) Whether a 'New Tab' and 'Close Tab' buttons should be shown on the tab bar */
196
197
ShowNewAndCloseTabButtons,
198
/** (int) Specifies the threshold of detected silence in seconds. */
197
200
/** Index of profile in the File Menu
198
201
* In future, format will be #.#.# to account for levels
204
* This enum describes the available modes for showing or hiding the tab bar.
207
* This enum describes the available modes for showing or hiding the tab bar.
206
209
enum TabBarModeEnum
228
* This enum describes the modes available to remember lines of output produced
231
* This enum describes where newly created tab should be placed.
233
enum NewTabBehaviorEnum
235
/** Put newly created tab at the end. */
236
PutNewTabAtTheEnd = 0,
237
/** Put newly created tab right after current tab. */
238
PutNewTabAfterCurrentTab = 1
242
* This enum describes the modes available to remember lines of output produced
231
245
enum HistoryModeEnum
235
249
/** A fixed number of lines of output are remembered. Once the limit is reached, the oldest
236
250
* lines are lost. */
237
251
FixedSizeHistory = 1,
238
/** All output is remembered for the duration of the session.
252
/** All output is remembered for the duration of the session.
239
253
* Typically this means that lines are recorded to
240
254
* a file as they are scrolled off-screen.
266
280
UnderlineCursor = 2
283
/** This enum describes the behavior of triple click action . */
284
enum TripleClickModeEnum
286
/** Select the whole line underneath the cursor. */
288
/** Select from the current cursor position to the end of the line. */
289
SelectForwardsFromCursor = 1
270
293
* Constructs a new profile
288
311
void clone(Ptr profile, bool differentOnly = true);
291
314
* Changes the parent profile. When calling the property() method,
292
315
* if the specified property has not been set for this profile,
293
316
* the parent's value for the property will be returned instead.
301
324
const GroupPtr asGroup() const;
302
325
GroupPtr asGroup();
305
328
* Returns the current value of the specified @p property, cast to type T.
306
329
* Internally properties are stored using the QVariant type and cast to T
307
330
* using QVariant::value<T>();
313
336
template <class T>
314
337
T property(Property property) const;
316
339
/** Sets the value of the specified @p property to @p value. */
317
340
virtual void setProperty(Property property,const QVariant& value);
318
341
/** Returns true if the specified property has been set in this Profile instance. */
324
347
/** Returns true if no properties have been set in this Profile instance. */
325
348
bool isEmpty() const;
328
351
* Returns true if this is a 'hidden' profile which should not be displayed
329
352
* in menus or saved to disk.
331
* This is used for the fallback profile, in case there are no profiles on
354
* This is used for the fallback profile, in case there are no profiles on
332
355
* disk which can be loaded, or for overlay profiles created to handle
333
356
* command-line arguments which change profile properties.
347
370
/** Convenience method for property<QString>(Profile::Name) */
348
371
QString name() const { return property<QString>(Profile::Name); }
350
373
/** Convenience method for property<QString>(Profile::Directory) */
351
374
QString defaultWorkingDirectory() const
352
375
{ return property<QString>(Profile::Directory); }
375
398
int menuIndexAsInt() const;
377
/** Return a list of all properties names and their type
400
/** Return a list of all properties names and their type
378
401
* (for use with -p option).
380
403
const QStringList propertiesInfoList() const;
383
* Returns true if @p name has been associated with an element
384
* from the Property enum or false otherwise.
386
static bool isNameRegistered(const QString& name);
389
* Returns the element from the Property enum associated with the
406
* Returns the element from the Property enum associated with the
390
407
* specified @p name.
392
409
* @param name The name of the property to look for, this is case insensitive.
394
411
static Property lookupByName(const QString& name);
396
* Returns the string names associated with the specified @p property from
397
* the Property enum, in the order the associations were created using
400
static QList<QString> namesForProperty(Property property);
403
* Returns the primary name for the specified @p property.
404
* TODO More documentation
406
static QString primaryNameForProperty(Property property);
409
414
struct PropertyInfo;
427
432
static QHash<QString,PropertyInfo> _propertyInfoByName;
428
433
static QHash<Property,PropertyInfo> _infoByProperty;
430
435
// Describes a property. Each property has a name and group
431
436
// which is used when saving/loading the profile.
432
437
struct PropertyInfo
461
466
{ return property != Name && property != Path; }
465
470
* A profile which contains a number of default settings for various properties.
466
471
* This can be used as a parent for other profiles or a fallback in case
467
472
* a profile cannot be loaded from disk.
472
477
FallbackProfile();
476
481
* A composite profile which allows a group of profiles to be treated as one.
477
482
* When setting a property, the new value is applied to all profiles in the group.
478
483
* When reading a property, if all profiles in the group have the same value
494
499
ProfileGroup(Profile::Ptr parent = Profile::Ptr());
496
501
/** Add a profile to the group. Calling setProperty() will update this profile.
497
* When creating a group, add the profiles to the group then call updateValues() to
502
* When creating a group, add the profiles to the group then call updateValues() to
498
503
* make the group's property values reflect the profiles currently in the group. */
499
504
void addProfile(Profile::Ptr profile)
500
505
{ _profiles.append(profile); }
508
513
QList<Profile::Ptr> profiles() const
509
514
{ return _profiles; }
512
* Updates the property values in this ProfileGroup to match those from
513
* the group's profiles()
517
* Updates the property values in this ProfileGroup to match those from
518
* the group's profiles()
515
520
* For each available property, if each profile in the group has the same value then
516
521
* the ProfileGroup will use that value for the property. Otherwise the value for the property
550
555
virtual ~ProfileReader() {}
551
556
/** Returns a list of paths to profiles which this reader can read. */
552
557
virtual QStringList findProfiles() { return QStringList(); }
554
* Attempts to read a profile from @p path and
559
* Attempts to read a profile from @p path and
555
560
* save the property values described into @p profile.
557
562
* Returns true if the profile was successfully read or false otherwise.
586
591
virtual ~ProfileWriter() {}
588
* Returns a suitable path-name for writing
593
* Returns a suitable path-name for writing
589
594
* @p profile to. The path-name should be accepted by
590
595
* the corresponding ProfileReader class.
632
637
* Parses an input string consisting of property names
633
* and assigned values and returns a table of
638
* and assigned values and returns a table of
634
639
* properties and values.
636
641
QHash<Profile::Property,QVariant> parse(const QString& input);