GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
|
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. | |
void | run () |
Starts the terminal session. |
Signals | |
void | bellRequest (const QString &message) |
Emitted when a bell event occurs in the session. | |
void | changeBackgroundColorRequest (const QColor &) |
Requests that the background color of views on this session should be changed. | |
void | changeTabTextColorRequest (int) |
Requests that the color the text for any tabs associated with this session should be changed;. | |
void | finished () |
Emitted when the terminal process exits. | |
void | openUrlRequest (const QString &url) |
TODO: Document me. | |
void | profileChangeCommandReceived (const QString &text) |
Emitted when a profile change command is received from the terminal. | |
void | profileChanged (const QString &profile) |
Emitted when the session's profile has changed. | |
void | receivedData (const QString &text) |
Emitted when output is received from the terminal process. | |
void | resizeRequest (const QSize &size) |
Emitted when the terminal process requests a change in the size of the terminal window. | |
void | started () |
Emitted when the terminal process starts. | |
void | stateChanged (int state) |
Emitted when the activity state of this session changes. | |
void | titleChanged () |
Emitted when the session's title has changed. |
Public Member Functions | |
TerminalModel (KPty *kpty) | |
Constructs a new session. | |
~TerminalModel () | |
void | addView (TerminalView *widget) |
Adds a new view for this session. | |
void | clearHistory () |
Clears the history store used by this session. | |
Emulation * | emulation () const |
Returns the terminal emulation instance being used to encode / decode characters to / from the process. | |
bool | hasDarkBackground () const |
Returns true if the session has a dark background. | |
const HistoryType & | historyType () const |
Returns the type of history store used by this session. | |
bool | isMonitorActivity () const |
Returns true if monitoring for activity is enabled. | |
bool | isMonitorSilence () const |
Returns true if monitoring for inactivity (silence) in the session is enabled. | |
QString | keyBindings () const |
Returns the name of the key bindings used by this session. | |
QString | profileKey () const |
Returns the profile key associated with this session. | |
void | refresh () |
Attempts to get the shell program to redraw the current display area. | |
void | removeView (TerminalView *widget) |
Removes a view from this session. | |
void | sendText (const QString &text) const |
Sends text to the current foreground terminal program. | |
void | setAddToUtmp (bool) |
Specifies whether a utmp entry should be created for the pty used by this session. | |
void | setAutoClose (bool b) |
Specifies whether to close the session automatically when the terminal process terminates. | |
void | setCodec (QTextCodec *codec) |
Sets the text codec used by this session's terminal emulation. | |
void | setDarkBackground (bool darkBackground) |
Sets whether the session has a dark background or not. | |
void | setHistoryType (const HistoryType &type) |
Sets the type of history store used by this session. | |
void | setKeyBindings (const QString &id) |
Sets the key bindings used by this session. | |
void | setMonitorActivity (bool) |
Enables monitoring for activity in the session. | |
void | setMonitorSilence (bool) |
Enables monitoring for silence in the session. | |
void | setMonitorSilenceSeconds (int seconds) |
See setMonitorSilence() | |
void | setProfileKey (const QString &profileKey) |
Sets the profile associated with this session. | |
void | setSize (const QSize &size) |
Emits a request to resize the session to accommodate the specified window size. | |
QSize | size () |
Returns the terminal session's window size in lines and columns. | |
QList< TerminalView * > | views () const |
Returns the views connected to this session. |
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 308 of file TerminalModel.cpp.
References _emulation.
Definition at line 218 of file TerminalModel.cpp.
References _monitorActivity, _monitorSilence, _monitorTimer, _notifiedActivity, _silenceSeconds, bellRequest(), NOTIFYACTIVITY, NOTIFYBELL, NOTIFYNORMAL, NOTIFYSILENCE, and stateChanged().
Referenced by setMonitorActivity(), setMonitorSilence(), and TerminalModel().
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::programUsesMouse(), 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.
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 350 of file TerminalModel.cpp.
References _emulation, and Emulation::clearHistory().
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 297 of file TerminalModel.cpp.
References _autoClose, and _wantedClose.
Referenced by removeView().
Definition at line 320 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 325 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 345 of file TerminalModel.cpp.
References _emulation, and Emulation::history().
bool TerminalModel::isMonitorActivity | ( | ) | const |
Returns true if monitoring for activity is enabled.
Definition at line 356 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 358 of file TerminalModel.cpp.
References _monitorSilence.
QString TerminalModel::keyBindings | ( | ) | const |
Returns the name of the key bindings used by this session.
|
privateslot |
Definition at line 194 of file TerminalModel.cpp.
References _monitorSilence, _notifiedActivity, NOTIFYNORMAL, NOTIFYSILENCE, and stateChanged().
Referenced by TerminalModel().
Definition at line 253 of file TerminalModel.cpp.
References setSize().
Definition at line 397 of file TerminalModel.cpp.
References _emulation, Emulation::receiveData(), and receivedData().
Referenced by TerminalModel().
Definition at line 249 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 318 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 293 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 162 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().
Starts the terminal session.
This creates the terminal process and connects the teletype to it.
Definition at line 189 of file TerminalModel.cpp.
References started().
Referenced by QUnixTerminalImpl::initialize().
Definition at line 156 of file TerminalModel.cpp.
References _kpty, KPty::masterFd(), and void().
Referenced by TerminalModel().
void TerminalModel::sendText | ( | const QString & | text | ) | const |
Sends text
to the current foreground terminal program.
Definition at line 303 of file TerminalModel.cpp.
References _emulation, and Emulation::sendText().
Referenced by QUnixTerminalImpl::sendText().
Specifies whether a utmp entry should be created for the pty used by this session.
Definition at line 392 of file TerminalModel.cpp.
References _addToUtmp.
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().
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 340 of file TerminalModel.cpp.
References _emulation, and Emulation::setHistory().
Referenced by QUnixTerminalImpl::initialize().
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 335 of file TerminalModel.cpp.
References _emulation, and Emulation::setKeyBindings().
Referenced by QUnixTerminalImpl::initialize().
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 360 of file TerminalModel.cpp.
References _monitorActivity, _notifiedActivity, activityStateSet(), and NOTIFYNORMAL.
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 368 of file TerminalModel.cpp.
References _monitorSilence, _monitorTimer, _silenceSeconds, activityStateSet(), and NOTIFYNORMAL.
Definition at line 384 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 313 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 408 of file TerminalModel.cpp.
References resizeRequest().
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().
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 258 of file TerminalModel.cpp.
References _emulation, _kpty, _views, TerminalView::columns(), TerminalView::lines(), Emulation::setImageSize(), and KPty::setWinSize().
Referenced by onViewSizeChange().
Definition at line 147 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 addView(), clearHistory(), emulation(), historyType(), onReceiveBlock(), removeView(), sendText(), setHistoryType(), setKeyBindings(), TerminalModel(), updateTerminalSize(), and ~TerminalModel().
|
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 sendData(), TerminalModel(), 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 activityStateSet(), setMonitorSilence(), setMonitorSilenceSeconds(), and TerminalModel().
|
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 61 of file TerminalModel.h.
|
readwrite |
Definition at line 62 of file TerminalModel.h.