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)) );
134 connect(
_emulation , SIGNAL(programBracketedPasteModeChanged(
bool)) ,
135 widget , SLOT(setBracketedPasteMode(
bool)) );
143 QObject::connect( widget ,SIGNAL(changedContentSizeSignal(
int,
int)),
this,
146 QObject::connect( widget ,SIGNAL(destroyed(
QObject*)) ,
this ,
156 Q_ASSERT(
_views.contains(display) );
171 disconnect(widget,
nullptr,
this,
nullptr);
181 disconnect( widget,
nullptr,
_emulation,
nullptr);
184 disconnect(
_emulation ,
nullptr , widget ,
nullptr);
188 if (
_views.count() == 0 )
260 setSize( QSize(lines,columns) );
265 QListIterator<TerminalView*> viewIter(
_views);
273 const int VIEW_LINES_THRESHOLD = 2;
274 const int VIEW_COLUMNS_THRESHOLD = 2;
277 while ( viewIter.hasNext() )
280 if ( view->isHidden() ==
false &&
281 view->
lines() >= VIEW_LINES_THRESHOLD &&
282 view->
columns() >= VIEW_COLUMNS_THRESHOLD )
284 minLines = (minLines == -1) ? view->
lines() : qMin( minLines , view->
lines() );
285 minColumns = (minColumns == -1) ? view->
columns() : qMin( minColumns , view->
columns() );
290 if ( minLines > 0 && minColumns > 0 )
415 if ((
size.width() <= 1) || (
size.height() <= 1))
@ NOTIFYBELL
The terminal program has triggered a bell event to get the user's attention.
@ NOTIFYACTIVITY
The emulation is currently receiving data from its terminal input.
@ NOTIFYNORMAL
The emulation is currently receiving user input.
Base class for terminal emulation back-ends.
bool programUsesMouse() const
Returns true if the active terminal program wants mouse input events.
void receiveData(const char *buffer, int len)
Processes an incoming stream of characters.
QString keyBindings()
Returns the name of the emulation's current key bindings.
const HistoryType & history()
Returns the history store used by this emulation.
ScreenWindow * createWindow()
Creates a new window onto the output from this emulation.
virtual void sendText(const QString &text)=0
Interprets a sequence of characters and sends the result to the terminal.
QSize imageSize()
Returns the size of the screen image which the emulation produces.
virtual void setImageSize(int lines, int columns)
Change the size of the emulation's image.
bool programBracketedPasteMode() const
void clearHistory()
Clears the history scroll.
void setKeyBindings(const QString &name)
Sets the key bindings used to key events ( received through sendKeyEvent() ) into character streams t...
void setHistory(const HistoryType &)
Sets the history store used by this emulation.
void setCodec(const QTextCodec *)
Sets the codec used to decode incoming characters.
Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY,...
bool setWinSize(int lines, int columns)
Change the logical (screen) size of the pty.
void onReceiveBlock(const char *buffer, int len)
void setProfileKey(const QString &profileKey)
Sets the profile associated with this session.
void bellRequest(const QString &message)
Emitted when a bell event occurs in the session.
TerminalModel(KPty *kpty)
Constructs a new session.
void setCodec(QTextCodec *codec)
Sets the text codec used by this session's terminal emulation.
void profileChangeCommandReceived(const QString &text)
Emitted when a profile change command is received from the terminal.
Emulation * emulation() const
Returns the terminal emulation instance being used to encode / decode characters to / from the proces...
void updateTerminalSize()
QList< TerminalView * > _views
void viewDestroyed(QObject *view)
void setMonitorSilence(bool)
Enables monitoring for silence in the session.
void sendText(const QString &text) const
Sends text to the current foreground terminal program.
void run()
Starts the terminal session.
void resizeRequest(const QSize &size)
Emitted when the terminal process requests a change in the size of the terminal window.
QList< TerminalView * > views() const
Returns the views connected to this session.
void activityStateSet(int)
void sendData(const char *buf, int len)
void addView(TerminalView *widget)
Adds a new view for this session.
void stateChanged(int state)
Emitted when the activity state of this session changes.
void onViewSizeChange(int height, int width)
void receivedData(const QString &text)
Emitted when output is received from the terminal process.
void refresh()
Attempts to get the shell program to redraw the current display area.
const HistoryType & historyType() const
Returns the type of history store used by this session.
void onEmulationSizeChange(int lines, int columns)
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.
void setMonitorActivity(bool)
Enables monitoring for activity in the session.
void setKeyBindings(const QString &id)
Sets the key bindings used by this session.
void started()
Emitted when the terminal process starts.
void changeTabTextColorRequest(int)
Requests that the color the text for any tabs associated with this session should be changed;.
QString profileKey() const
Returns the profile key associated with this session.
void setAddToUtmp(bool)
Specifies whether a utmp entry should be created for the pty used by this session.
void clearHistory()
Clears the history store used by this session.
void setDarkBackground(bool darkBackground)
Sets whether the session has a dark background or not.
void setSize(const QSize &size)
Emits a request to resize the session to accommodate the specified window size.
void removeView(TerminalView *widget)
Removes a view from this session.
bool hasDarkBackground() const
Returns true if the session has a dark background.
void profileChanged(const QString &profile)
Emitted when the session's profile has changed.
void close()
Closes the terminal session.
void finished()
Emitted when the terminal process exits.
void setMonitorSilenceSeconds(int seconds)
See setMonitorSilence()
SelfListener * _selfListener
void setHistoryType(const HistoryType &type)
Sets the type of history store used by this session.
A widget which displays output from a terminal emulation and sends input keypresses and mouse activit...
void setUsesMouse(bool usesMouse)
Sets whether the program whoose output is being displayed in the view is interested in mouse events.
void setScreenWindow(ScreenWindow *window)
Sets the terminal screen section which is displayed in this widget.
int columns()
Returns the number of characters of text which can be displayed on each line in the widget.
int lines()
Returns the number of lines of text which can be displayed in the widget.
void setBracketedPasteMode(bool bracketedPasteMode)
Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
static uint32_t state[624]