34 #include <QApplication> 35 #include <QtCore/QByteRef> 36 #include <QtCore/QDir> 37 #include <QtCore/QFile> 38 #include <QtCore/QRegExp> 39 #include <QtCore/QStringList> 46 _shellProcess(nullptr)
48 , _monitorActivity(
false)
49 , _monitorSilence(
false)
50 , _notifiedActivity(
false)
55 , _fullScripting(
false)
56 , _hasDarkBackground(
false)
75 this, SLOT(
onReceiveBlock(
const char*,
int)), Qt::BlockingQueuedConnection);
78 ,
this,SLOT(
sendData(
const char*,
int)));
113 Q_ASSERT( !
_views.contains(widget) );
120 connect( widget , SIGNAL(keyPressedSignal(QKeyEvent*)) ,
_emulation ,
121 SLOT(sendKeyEvent(QKeyEvent*)) );
122 connect( widget , SIGNAL(mouseSignal(
int,
int,
int,
int)) ,
_emulation ,
123 SLOT(sendMouseEvent(
int,
int,
int,
int)) );
124 connect( widget , SIGNAL(sendStringToEmu(
const char*)) ,
_emulation ,
125 SLOT(sendString(
const char*)) );
129 connect(
_emulation , SIGNAL(programUsesMouseChanged(
bool)) , widget ,
130 SLOT(setUsesMouse(
bool)) );
138 QObject::connect( widget ,SIGNAL(changedContentSizeSignal(
int,
int)),
this,
141 QObject::connect( widget ,SIGNAL(destroyed(
QObject*)) ,
this ,
151 Q_ASSERT(
_views.contains(display) );
166 disconnect(widget,
nullptr,
this,
nullptr);
176 disconnect( widget,
nullptr,
_emulation,
nullptr);
179 disconnect(
_emulation ,
nullptr , widget ,
nullptr);
183 if (
_views.count() == 0 )
255 setSize( QSize(lines,columns) );
260 QListIterator<TerminalView*> viewIter(
_views);
268 const int VIEW_LINES_THRESHOLD = 2;
269 const int VIEW_COLUMNS_THRESHOLD = 2;
272 while ( viewIter.hasNext() )
275 if ( view->isHidden() ==
false &&
276 view->
lines() >= VIEW_LINES_THRESHOLD &&
277 view->
columns() >= VIEW_COLUMNS_THRESHOLD )
279 minLines = (minLines == -1) ? view->
lines() : qMin( minLines , view->
lines() );
280 minColumns = (minColumns == -1) ? view->
columns() : qMin( minColumns , view->
columns() );
285 if ( minLines > 0 && minColumns > 0 )
410 if ((
size.width() <= 1) || (
size.height() <= 1))
QList< TerminalView * > views() const
Returns the views connected to this session.
void onViewSizeChange(int height, int width)
void stateChanged(int state)
Emitted when the activity state of this session changes.
void addView(TerminalView *widget)
Adds a new view for this session.
void resizeRequest(const QSize &size)
Emitted when the terminal process requests a change in the size of the terminal window.
void setScreenWindow(ScreenWindow *window)
Sets the terminal screen section which is displayed in this widget.
void onReceiveBlock(const char *buffer, int len)
void viewDestroyed(QObject *view)
SelfListener * _selfListener
void run()
Starts the terminal session.
void clearHistory()
Clears the history store used by this session.
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.
int columns()
Returns the number of characters of text which can be displayed on each line in the widget...
void sendData(const char *buf, int len)
Base class for terminal emulation back-ends.
void setKeyBindings(const QString &id)
Sets the key bindings used by this session.
virtual void setImageSize(int lines, int columns)
Change the size of the emulation's image.
void bellRequest(const QString &message)
Emitted when a bell event occurs in the session.
QSize imageSize()
Returns the size of the screen image which the emulation produces.
void finished()
Emitted when the terminal process exits.
int lines()
Returns the number of lines of text which can be displayed in the widget.
const HistoryType & historyType() const
Returns the type of history store used by this session.
void setHistoryType(const HistoryType &type)
Sets the type of history store used by this session.
TerminalModel(KPty *kpty)
Constructs a new session.
QString keyBindings() const
Returns the name of the key bindings used by this session.
virtual void sendText(const QString &text)=0
Interprets a sequence of characters and sends the result to the terminal.
void onEmulationSizeChange(int lines, int columns)
QString keyBindings()
Returns the name of the emulation's current key bindings.
void close()
Closes the terminal session.
void refresh()
Attempts to get the shell program to redraw the current display area.
bool programUsesMouse() const
Returns true if the active terminal program wants mouse input events.
bool setWinSize(int lines, int columns)
Change the logical (screen) size of the pty.
void updateTerminalSize()
void clearHistory()
Clears the history scroll.
Emulation * emulation() const
Returns the terminal emulation instance being used to encode / decode characters to / from the proces...
void profileChangeCommandReceived(const QString &text)
Emitted when a profile change command is received from the terminal.
QString profileKey() const
Returns the profile key associated with this session.
void removeView(TerminalView *widget)
Removes a view from this session.
bool hasDarkBackground() const
Returns true if the session has a dark background.
The emulation is currently receiving user input.
The terminal program has triggered a bell event to get the user's attention.
const HistoryType & history()
Returns the history store used by this emulation.
QList< TerminalView * > _views
void setSize(const QSize &size)
Emits a request to resize the session to accommodate the specified window size.
void started()
Emitted when the terminal process starts.
void setAddToUtmp(bool)
Specifies whether a utmp entry should be created for the pty used by this session.
void setDarkBackground(bool darkBackground)
Sets whether the session has a dark background or not.
void setMonitorSilence(bool)
Enables monitoring for silence in the session.
static uint32_t state[624]
ScreenWindow * createWindow()
Creates a new window onto the output from this emulation.
void changeTabTextColorRequest(int)
Requests that the color the text for any tabs associated with this session should be changed;...
void setCodec(QTextCodec *codec)
Sets the text codec used by this session's terminal emulation.
void setMonitorSilenceSeconds(int seconds)
See setMonitorSilence()
bool isMonitorSilence() const
Returns true if monitoring for inactivity (silence) in the session is enabled.
The emulation is currently receiving data from its terminal input.
void setCodec(const QTextCodec *)
Sets the codec used to decode incoming characters.
void setProfileKey(const QString &profileKey)
Sets the profile associated with this session.
Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
bool isMonitorActivity() const
Returns true if monitoring for activity is enabled.
void setMonitorActivity(bool)
Enables monitoring for activity in the session.
void setUsesMouse(bool usesMouse)
Sets whether the program whoose output is being displayed in the view is interested in mouse events...
void receiveData(const char *buffer, int len)
Processes an incoming stream of characters.
void setHistory(const HistoryType &)
Sets the history store used by this emulation.
A widget which displays output from a terminal emulation and sends input keypresses and mouse activit...
void activityStateSet(int)
void setKeyBindings(const QString &name)
Sets the key bindings used to key events ( received through sendKeyEvent() ) into character streams t...
Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY...
QSize size()
Returns the terminal session's window size in lines and columns.
void sendText(const QString &text) const
Sends text to the current foreground terminal program.