Represents a terminal session consisting of a pseudo-teletype and a terminal emulation. More...
#include "TerminalModel.h"
Public Slots | |
void | close () |
Closes the terminal session. More... | |
void | run () |
Starts the terminal session. More... | |
Signals | |
void | bellRequest (const QString &message) |
Emitted when a bell event occurs in the session. More... | |
void | changeBackgroundColorRequest (const QColor &) |
Requests that the background color of views on this session should be changed. More... | |
void | changeTabTextColorRequest (int) |
Requests that the color the text for any tabs associated with this session should be changed;. More... | |
void | finished () |
Emitted when the terminal process exits. More... | |
void | openUrlRequest (const QString &url) |
TODO: Document me. More... | |
void | profileChangeCommandReceived (const QString &text) |
Emitted when a profile change command is received from the terminal. More... | |
void | profileChanged (const QString &profile) |
Emitted when the session's profile has changed. More... | |
void | receivedData (const QString &text) |
Emitted when output is received from the terminal process. More... | |
void | resizeRequest (const QSize &size) |
Emitted when the terminal process requests a change in the size of the terminal window. More... | |
void | started () |
Emitted when the terminal process starts. More... | |
void | stateChanged (int state) |
Emitted when the activity state of this session changes. More... | |
void | titleChanged () |
Emitted when the session's title has changed. More... | |
Public Member Functions | |
TerminalModel (KPty *kpty) | |
Constructs a new session. More... | |
~TerminalModel () | |
void | addView (TerminalView *widget) |
Adds a new view for this session. More... | |
void | clearHistory () |
Clears the history store used by this session. More... | |
Emulation * | emulation () const |
Returns the terminal emulation instance being used to encode / decode characters to / from the process. More... | |
bool | hasDarkBackground () const |
Returns true if the session has a dark background. More... | |
const HistoryType & | historyType () const |
Returns the type of history store used by this session. More... | |
bool | isMonitorActivity () const |
Returns true if monitoring for activity is enabled. More... | |
bool | isMonitorSilence () const |
Returns true if monitoring for inactivity (silence) in the session is enabled. More... | |
QString | keyBindings () const |
Returns the name of the key bindings used by this session. More... | |
QString | profileKey () const |
Returns the profile key associated with this session. More... | |
void | refresh () |
Attempts to get the shell program to redraw the current display area. More... | |
void | removeView (TerminalView *widget) |
Removes a view from this session. More... | |
void | sendText (const QString &text) const |
Sends text to the current foreground terminal program. More... | |
void | setAddToUtmp (bool) |
Specifies whether a utmp entry should be created for the pty used by this session. More... | |
void | setAutoClose (bool b) |
Specifies whether to close the session automatically when the terminal process terminates. More... | |
void | setCodec (QTextCodec *codec) |
Sets the text codec used by this session's terminal emulation. More... | |
void | setDarkBackground (bool darkBackground) |
Sets whether the session has a dark background or not. More... | |
void | setHistoryType (const HistoryType &type) |
Sets the type of history store used by this session. More... | |
void | setKeyBindings (const QString &id) |
Sets the key bindings used by this session. More... | |
void | setMonitorActivity (bool) |
Enables monitoring for activity in the session. More... | |
void | setMonitorSilence (bool) |
Enables monitoring for silence in the session. More... | |
void | setMonitorSilenceSeconds (int seconds) |
See setMonitorSilence() More... | |
void | setProfileKey (const QString &profileKey) |
Sets the profile associated with this session. More... | |
void | setSize (const QSize &size) |
Emits a request to resize the session to accommodate the specified window size. More... | |
QSize | size () |
Returns the terminal session's window size in lines and columns. More... | |
QList< TerminalView * > | views () const |
Returns the views connected to this session. More... | |
Properties | |
QString | keyBindings |
QSize | size |
Private Slots | |
void | activityStateSet (int) |
void | done (int) |
void | monitorTimerDone () |
void | onEmulationSizeChange (int lines, int columns) |
void | onReceiveBlock (const char *buffer, int len) |
void | onViewSizeChange (int height, int width) |
void | sendData (const char *buf, int len) |
void | viewDestroyed (QObject *view) |
Private Member Functions | |
void | updateTerminalSize () |
WId | windowId () const |
Private Attributes | |
bool | _addToUtmp |
bool | _autoClose |
Emulation * | _emulation |
bool | _fullScripting |
bool | _hasDarkBackground |
KPty * | _kpty |
int | _masterFd |
bool | _masterMode |
QColor | _modifiedBackground |
bool | _monitorActivity |
bool | _monitorSilence |
QTimer * | _monitorTimer |
bool | _notifiedActivity |
QString | _profileKey |
SelfListener * | _selfListener |
PseudoTerminal * | _shellProcess |
int | _silenceSeconds |
int | _slaveFd |
int | _uniqueIdentifier |
QList< TerminalView * > | _views |
bool | _wantedClose |
Represents a terminal session consisting of a pseudo-teletype and a terminal emulation.
The pseudo-teletype (or PTY) handles I/O between the terminal process and Konsole. The terminal emulation ( Emulation and subclasses ) processes the output stream from the PTY and produces a character image which is then shown on views connected to the session.
Each Session can be connected to one or more views by using the addView() method. The attached views can then display output from the program running in the terminal or send input to the program in the terminal in the form of keypresses and mouse activity.
Definition at line 57 of file TerminalModel.h.
TerminalModel::TerminalModel | ( | KPty * | kpty | ) |
Constructs a new session.
To start the terminal process, call the run() method, after specifying the program and arguments using setProgram() and setArguments()
If no program or arguments are specified explicitly, the Session falls back to using the program specified in the SHELL environment variable.
Definition at line 45 of file TerminalModel.cpp.
References _emulation, _kpty, _monitorTimer, _selfListener, activityStateSet(), changeTabTextColorRequest(), KPty::masterFd(), monitorTimerDone(), onReceiveBlock(), profileChangeCommandReceived(), and sendData().
TerminalModel::~TerminalModel | ( | ) |
Definition at line 313 of file TerminalModel.cpp.
References _emulation.
|
privateslot |
Definition at line 223 of file TerminalModel.cpp.
References _monitorActivity, _monitorSilence, _monitorTimer, _notifiedActivity, _silenceSeconds, bellRequest(), NOTIFYACTIVITY, NOTIFYBELL, NOTIFYNORMAL, NOTIFYSILENCE, octave::state, and stateChanged().
Referenced by TerminalModel(), setMonitorActivity(), and setMonitorSilence().
void TerminalModel::addView | ( | TerminalView * | widget | ) |
Adds a new view for this session.
The viewing widget will display the output from the terminal and input from the viewing widget (key presses, mouse activity etc.) will be sent to the terminal.
Views can be removed using removeView(). The session is automatically closed when the last view is removed.
Definition at line 111 of file TerminalModel.cpp.
References _emulation, _views, Emulation::createWindow(), onViewSizeChange(), Emulation::programBracketedPasteMode(), Emulation::programUsesMouse(), TerminalView::setBracketedPasteMode(), TerminalView::setScreenWindow(), TerminalView::setUsesMouse(), and viewDestroyed().
Referenced by QUnixTerminalImpl::initialize().
|
signal |
Emitted when a bell event occurs in the session.
Referenced by activityStateSet().
|
signal |
Requests that the background color of views on this session should be changed.
|
signal |
Requests that the color the text for any tabs associated with this session should be changed;.
TODO: Document what the parameter does
Referenced by TerminalModel().
void TerminalModel::clearHistory | ( | ) |
Clears the history store used by this session.
Definition at line 355 of file TerminalModel.cpp.
References _emulation, and Emulation::clearHistory().
Referenced by QUnixTerminalImpl::setScrollBufferSize().
|
slot |
Closes the terminal session.
This sends a hangup signal (SIGHUP) to the terminal process and causes the done(Session*) signal to be emitted.
Definition at line 302 of file TerminalModel.cpp.
References _autoClose, and _wantedClose.
Referenced by removeView().
|
privateslot |
Definition at line 325 of file TerminalModel.cpp.
References finished().
Emulation * TerminalModel::emulation | ( | ) | const |
Returns the terminal emulation instance being used to encode / decode characters to / from the process.
Definition at line 330 of file TerminalModel.cpp.
References _emulation.
Referenced by setCodec().
|
signal |
Emitted when the terminal process exits.
Referenced by done().
bool TerminalModel::hasDarkBackground | ( | ) | const |
Returns true if the session has a dark background.
Definition at line 96 of file TerminalModel.cpp.
References _hasDarkBackground.
const HistoryType & TerminalModel::historyType | ( | ) | const |
Returns the type of history store used by this session.
Definition at line 350 of file TerminalModel.cpp.
References _emulation, and Emulation::history().
bool TerminalModel::isMonitorActivity | ( | ) | const |
Returns true if monitoring for activity is enabled.
Definition at line 361 of file TerminalModel.cpp.
References _monitorActivity.
bool TerminalModel::isMonitorSilence | ( | ) | const |
Returns true if monitoring for inactivity (silence) in the session is enabled.
Definition at line 363 of file TerminalModel.cpp.
References _monitorSilence.
QString TerminalModel::keyBindings | ( | ) | const |
Returns the name of the key bindings used by this session.
Definition at line 335 of file TerminalModel.cpp.
References _emulation, and Emulation::keyBindings().
|
privateslot |
Definition at line 199 of file TerminalModel.cpp.
References _monitorSilence, _notifiedActivity, NOTIFYNORMAL, NOTIFYSILENCE, and stateChanged().
Referenced by TerminalModel().
|
privateslot |
Definition at line 258 of file TerminalModel.cpp.
References setSize().
|
privateslot |
Definition at line 402 of file TerminalModel.cpp.
References _emulation, len, Emulation::receiveData(), and receivedData().
Referenced by TerminalModel().
|
privateslot |
Definition at line 254 of file TerminalModel.cpp.
References updateTerminalSize().
Referenced by addView().
|
signal |
TODO: Document me.
|
signal |
Emitted when a profile change command is received from the terminal.
text | The text of the command. This is a string of the form "PropertyName=Value;PropertyName=Value ..." |
Referenced by TerminalModel().
|
signal |
Emitted when the session's profile has changed.
Referenced by setProfileKey().
QString TerminalModel::profileKey | ( | ) | const |
Returns the profile key associated with this session.
This can be passed to the SessionManager to obtain the current profile settings.
Definition at line 323 of file TerminalModel.cpp.
References _profileKey.
|
signal |
Emitted when output is received from the terminal process.
Referenced by onReceiveBlock().
void TerminalModel::refresh | ( | ) |
Attempts to get the shell program to redraw the current display area.
This can be used after clearing the screen, for example, to get the shell to redraw the prompt line.
Definition at line 298 of file TerminalModel.cpp.
void TerminalModel::removeView | ( | TerminalView * | widget | ) |
Removes a view from this session.
When the last view is removed, the session will be closed automatically.
widget
will no longer display output from or send input to the terminal
Definition at line 167 of file TerminalModel.cpp.
References _emulation, _views, and close().
Referenced by viewDestroyed().
|
signal |
Emitted when the terminal process requests a change in the size of the terminal window.
size | The requested window size in terms of lines and columns. |
Referenced by setSize().
|
slot |
Starts the terminal session.
This creates the terminal process and connects the teletype to it.
Definition at line 194 of file TerminalModel.cpp.
References started().
Referenced by QUnixTerminalImpl::initialize().
|
privateslot |
Definition at line 161 of file TerminalModel.cpp.
References _kpty, len, and KPty::masterFd().
Referenced by TerminalModel().
void TerminalModel::sendText | ( | const QString & | text | ) | const |
Sends text
to the current foreground terminal program.
Definition at line 308 of file TerminalModel.cpp.
References _emulation, and Emulation::sendText().
Referenced by QUnixTerminalImpl::sendText().
void TerminalModel::setAddToUtmp | ( | bool | set | ) |
Specifies whether a utmp entry should be created for the pty used by this session.
Definition at line 397 of file TerminalModel.cpp.
References _addToUtmp.
|
inline |
Specifies whether to close the session automatically when the terminal process terminates.
Definition at line 191 of file TerminalModel.h.
References _autoClose.
Referenced by QUnixTerminalImpl::initialize().
void TerminalModel::setCodec | ( | QTextCodec * | codec | ) |
Sets the text codec used by this session's terminal emulation.
Definition at line 101 of file TerminalModel.cpp.
References emulation(), and Emulation::setCodec().
Referenced by QUnixTerminalImpl::initialize().
void TerminalModel::setDarkBackground | ( | bool | darkBackground | ) |
Sets whether the session has a dark background or not.
The session uses this information to set the COLORFGBG variable in the process's environment, which allows the programs running in the terminal to determine whether the background is light or dark and use appropriate colors by default.
This has no effect once the session is running.
Definition at line 92 of file TerminalModel.cpp.
References _hasDarkBackground.
Referenced by QUnixTerminalImpl::initialize().
void TerminalModel::setHistoryType | ( | const HistoryType & | type | ) |
Sets the type of history store used by this session.
Lines of output produced by the terminal are added to the history store. The type of history store used affects the number of lines which can be remembered before they are lost and the storage (in memory, on-disk etc.) used.
Definition at line 345 of file TerminalModel.cpp.
References _emulation, and Emulation::setHistory().
Referenced by QUnixTerminalImpl::initialize(), and QUnixTerminalImpl::setScrollBufferSize().
void TerminalModel::setKeyBindings | ( | const QString & | id | ) |
Sets the key bindings used by this session.
The bindings specify how input key sequences are translated into the character stream which is sent to the terminal.
id | The name of the key bindings to use. The names of available key bindings can be determined using the KeyboardTranslatorManager class. |
Definition at line 340 of file TerminalModel.cpp.
References _emulation, and Emulation::setKeyBindings().
Referenced by QUnixTerminalImpl::initialize().
void TerminalModel::setMonitorActivity | ( | bool | _monitor | ) |
Enables monitoring for activity in the session.
This will cause notifySessionState() to be emitted with the NOTIFYACTIVITY state flag when output is received from the terminal.
Definition at line 365 of file TerminalModel.cpp.
References _monitorActivity, _notifiedActivity, activityStateSet(), and NOTIFYNORMAL.
void TerminalModel::setMonitorSilence | ( | bool | _monitor | ) |
Enables monitoring for silence in the session.
This will cause notifySessionState() to be emitted with the NOTIFYSILENCE state flag when output is not received from the terminal for a certain period of time, specified with setMonitorSilenceSeconds()
Definition at line 373 of file TerminalModel.cpp.
References _monitorSilence, _monitorTimer, _silenceSeconds, activityStateSet(), and NOTIFYNORMAL.
void TerminalModel::setMonitorSilenceSeconds | ( | int | seconds | ) |
Definition at line 389 of file TerminalModel.cpp.
References _monitorSilence, _monitorTimer, and _silenceSeconds.
void TerminalModel::setProfileKey | ( | const QString & | profileKey | ) |
Sets the profile associated with this session.
profileKey | A key which can be used to obtain the current profile settings from the SessionManager |
Definition at line 318 of file TerminalModel.cpp.
References _profileKey, and profileChanged().
void TerminalModel::setSize | ( | const QSize & | size | ) |
Emits a request to resize the session to accommodate the specified window size.
size | The size in lines and columns to request. |
Definition at line 413 of file TerminalModel.cpp.
References resizeRequest(), and size.
Referenced by onEmulationSizeChange().
QSize TerminalModel::size | ( | ) |
Returns the terminal session's window size in lines and columns.
|
signal |
Emitted when the terminal process starts.
Referenced by run().
|
signal |
Emitted when the activity state of this session changes.
state | The new state of the session. This may be one of NOTIFYNORMAL, NOTIFYSILENCE or NOTIFYACTIVITY |
Referenced by activityStateSet(), and monitorTimerDone().
|
signal |
Emitted when the session's title has changed.
|
private |
Definition at line 263 of file TerminalModel.cpp.
References _emulation, _kpty, _views, TerminalView::columns(), TerminalView::lines(), Emulation::setImageSize(), and KPty::setWinSize().
Referenced by onViewSizeChange().
|
privateslot |
Definition at line 152 of file TerminalModel.cpp.
References _views, and removeView().
Referenced by addView().
QList< TerminalView * > TerminalModel::views | ( | ) | const |
Returns the views connected to this session.
Definition at line 106 of file TerminalModel.cpp.
References _views.
|
private |
|
private |
Definition at line 353 of file TerminalModel.h.
Referenced by setAddToUtmp().
|
private |
Definition at line 347 of file TerminalModel.h.
Referenced by close(), and setAutoClose().
|
private |
Definition at line 339 of file TerminalModel.h.
Referenced by TerminalModel(), ~TerminalModel(), addView(), clearHistory(), emulation(), historyType(), keyBindings(), onReceiveBlock(), removeView(), sendText(), setHistoryType(), setKeyBindings(), and updateTerminalSize().
|
private |
Definition at line 354 of file TerminalModel.h.
|
private |
Definition at line 367 of file TerminalModel.h.
Referenced by hasDarkBackground(), and setDarkBackground().
|
private |
Definition at line 360 of file TerminalModel.h.
Referenced by TerminalModel(), sendData(), and updateTerminalSize().
|
private |
Definition at line 356 of file TerminalModel.h.
|
private |
Definition at line 346 of file TerminalModel.h.
|
private |
Definition at line 363 of file TerminalModel.h.
|
private |
Definition at line 343 of file TerminalModel.h.
Referenced by activityStateSet(), isMonitorActivity(), and setMonitorActivity().
|
private |
Definition at line 344 of file TerminalModel.h.
Referenced by activityStateSet(), isMonitorSilence(), monitorTimerDone(), setMonitorSilence(), and setMonitorSilenceSeconds().
|
private |
Definition at line 349 of file TerminalModel.h.
Referenced by TerminalModel(), activityStateSet(), setMonitorSilence(), and setMonitorSilenceSeconds().
|
private |
Definition at line 345 of file TerminalModel.h.
Referenced by activityStateSet(), monitorTimerDone(), and setMonitorActivity().
|
private |
Definition at line 365 of file TerminalModel.h.
Referenced by profileKey(), and setProfileKey().
|
private |
Definition at line 359 of file TerminalModel.h.
Referenced by TerminalModel().
|
private |
Definition at line 338 of file TerminalModel.h.
|
private |
Definition at line 351 of file TerminalModel.h.
Referenced by activityStateSet(), setMonitorSilence(), and setMonitorSilenceSeconds().
|
private |
Definition at line 357 of file TerminalModel.h.
|
private |
Definition at line 336 of file TerminalModel.h.
|
private |
Definition at line 341 of file TerminalModel.h.
Referenced by addView(), removeView(), updateTerminalSize(), viewDestroyed(), and views().
|
private |
Definition at line 348 of file TerminalModel.h.
Referenced by close().
|
readwrite |
Definition at line 1 of file TerminalModel.h.
|
readwrite |
Definition at line 1 of file TerminalModel.h.
Referenced by setSize().