GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Slots | Signals | Public Member Functions | Properties | Private Slots | Private Member Functions | Private Attributes | List of all members
TerminalModel Class Reference

Represents a terminal session consisting of a pseudo-teletype and a terminal emulation. More...

#include "TerminalModel.h"

Inheritance diagram for TerminalModel:
Inheritance graph
[legend]
Collaboration diagram for TerminalModel:
Collaboration graph
[legend]

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.
Emulationemulation () 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 HistoryTypehistoryType () 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

Detailed Description

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

void TerminalModel::activityStateSet ( int  state)
privateslot
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().

void TerminalModel::bellRequest ( const QString &  message)
signal

Emitted when a bell event occurs in the session.

Referenced by activityStateSet().

void TerminalModel::changeBackgroundColorRequest ( const QColor &  )
signal

Requests that the background color of views on this session should be changed.

void TerminalModel::changeTabTextColorRequest ( int  )
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 350 of file TerminalModel.cpp.

References _emulation, and Emulation::clearHistory().

void TerminalModel::close ( void  )
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 297 of file TerminalModel.cpp.

References _autoClose, and _wantedClose.

Referenced by removeView().

void TerminalModel::done ( int  )
privateslot

Definition at line 320 of file TerminalModel.cpp.

References finished().

Referenced by ddaspk(), ddasrt(), and ddassl().

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().

void TerminalModel::finished ( )
signal

Emitted when the terminal process exits.

Referenced by done().

bool TerminalModel::hasDarkBackground ( ) const

Returns true if the session has a dark background.

See setDarkBackground()

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.

void TerminalModel::monitorTimerDone ( )
privateslot

Definition at line 194 of file TerminalModel.cpp.

References _monitorSilence, _notifiedActivity, NOTIFYNORMAL, NOTIFYSILENCE, and stateChanged().

Referenced by TerminalModel().

void TerminalModel::onEmulationSizeChange ( int  lines,
int  columns 
)
privateslot

Definition at line 253 of file TerminalModel.cpp.

References setSize().

void TerminalModel::onReceiveBlock ( const char buffer,
int  len 
)
privateslot

Definition at line 397 of file TerminalModel.cpp.

References _emulation, Emulation::receiveData(), and receivedData().

Referenced by TerminalModel().

void TerminalModel::onViewSizeChange ( int  height,
int  width 
)
privateslot

Definition at line 249 of file TerminalModel.cpp.

References updateTerminalSize().

Referenced by addView().

void TerminalModel::openUrlRequest ( const QString &  url)
signal

TODO: Document me.

void TerminalModel::profileChangeCommandReceived ( const QString &  text)
signal

Emitted when a profile change command is received from the terminal.

Parameters
textThe text of the command. This is a string of the form "PropertyName=Value;PropertyName=Value ..."

Referenced by TerminalModel().

void TerminalModel::profileChanged ( const QString &  profile)
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.

void TerminalModel::receivedData ( const QString &  text)
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().

void TerminalModel::resizeRequest ( const QSize &  size)
signal

Emitted when the terminal process requests a change in the size of the terminal window.

Parameters
sizeThe requested window size in terms of lines and columns.

Referenced by setSize().

void TerminalModel::run ( void  )
slot

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().

void TerminalModel::sendData ( const char buf,
int  len 
)
privateslot

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().

void TerminalModel::setAddToUtmp ( bool  set)

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.

void TerminalModel::setAutoClose ( bool  b)
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 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.

Parameters
idThe 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().

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 360 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 368 of file TerminalModel.cpp.

References _monitorSilence, _monitorTimer, _silenceSeconds, activityStateSet(), and NOTIFYNORMAL.

void TerminalModel::setMonitorSilenceSeconds ( int  seconds)

See setMonitorSilence()

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.

Parameters
profileKeyA 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.

Parameters
sizeThe 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.

void TerminalModel::started ( )
signal

Emitted when the terminal process starts.

Referenced by run().

void TerminalModel::stateChanged ( int  state)
signal

Emitted when the activity state of this session changes.

Parameters
stateThe new state of the session. This may be one of NOTIFYNORMAL, NOTIFYSILENCE or NOTIFYACTIVITY

Referenced by activityStateSet(), and monitorTimerDone().

void TerminalModel::titleChanged ( )
signal

Emitted when the session's title has changed.

void TerminalModel::updateTerminalSize ( )
private
void TerminalModel::viewDestroyed ( QObject view)
privateslot

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.

WId TerminalModel::windowId ( ) const
private

Member Data Documentation

bool TerminalModel::_addToUtmp
private

Definition at line 353 of file TerminalModel.h.

Referenced by setAddToUtmp().

bool TerminalModel::_autoClose
private

Definition at line 347 of file TerminalModel.h.

Referenced by close(), and setAutoClose().

Emulation* TerminalModel::_emulation
private
bool TerminalModel::_fullScripting
private

Definition at line 354 of file TerminalModel.h.

bool TerminalModel::_hasDarkBackground
private

Definition at line 367 of file TerminalModel.h.

Referenced by hasDarkBackground(), and setDarkBackground().

KPty* TerminalModel::_kpty
private

Definition at line 360 of file TerminalModel.h.

Referenced by sendData(), TerminalModel(), and updateTerminalSize().

int TerminalModel::_masterFd
private

Definition at line 356 of file TerminalModel.h.

bool TerminalModel::_masterMode
private

Definition at line 346 of file TerminalModel.h.

QColor TerminalModel::_modifiedBackground
private

Definition at line 363 of file TerminalModel.h.

bool TerminalModel::_monitorActivity
private

Definition at line 343 of file TerminalModel.h.

Referenced by activityStateSet(), isMonitorActivity(), and setMonitorActivity().

bool TerminalModel::_monitorSilence
private
QTimer* TerminalModel::_monitorTimer
private
bool TerminalModel::_notifiedActivity
private

Definition at line 345 of file TerminalModel.h.

Referenced by activityStateSet(), monitorTimerDone(), and setMonitorActivity().

QString TerminalModel::_profileKey
private

Definition at line 365 of file TerminalModel.h.

Referenced by profileKey(), and setProfileKey().

SelfListener* TerminalModel::_selfListener
private

Definition at line 359 of file TerminalModel.h.

Referenced by TerminalModel().

PseudoTerminal* TerminalModel::_shellProcess
private

Definition at line 338 of file TerminalModel.h.

int TerminalModel::_silenceSeconds
private

Definition at line 351 of file TerminalModel.h.

Referenced by activityStateSet(), setMonitorSilence(), and setMonitorSilenceSeconds().

int TerminalModel::_slaveFd
private

Definition at line 357 of file TerminalModel.h.

int TerminalModel::_uniqueIdentifier
private

Definition at line 336 of file TerminalModel.h.

QList<TerminalView*> TerminalModel::_views
private

Definition at line 341 of file TerminalModel.h.

Referenced by addView(), removeView(), updateTerminalSize(), viewDestroyed(), and views().

bool TerminalModel::_wantedClose
private

Definition at line 348 of file TerminalModel.h.

Referenced by close().

Property Documentation

QString TerminalModel::keyBindings
readwrite

Definition at line 61 of file TerminalModel.h.

QSize TerminalModel::size
readwrite

Definition at line 62 of file TerminalModel.h.


The documentation for this class was generated from the following files: