36 #include <QApplication>
38 #include <QtCore/QHash>
40 #include <QtCore/QRegExp>
41 #include <QtCore/QTextStream>
42 #include <QtCore/QThread>
44 #include <QtCore/QTime>
53 _currentScreen(nullptr),
56 _keyTranslator(nullptr),
58 _bracketedPasteMode(false)
102 connect(window , SIGNAL(selectionChanged()),
106 window , SLOT(notifyOutputChanged()) );
115 QListIterator<ScreenWindow*> windowIter(
_windows);
117 while (windowIter.hasNext())
119 delete windowIter.next();
139 QListIterator<ScreenWindow*> windowIter(
_windows);
140 while ( windowIter.hasNext() )
177 setCodec( QTextCodec::codecForName(
"utf8") );
179 setCodec( QTextCodec::codecForLocale() );
235 if (!ev->text().isEmpty())
241 emit
sendData(ev->text().toUtf8(),ev->text().length());
268 QString unicodeText =
_decoder->toUnicode(text,length);
271 for (
int i=0;i<unicodeText.length();i++)
294 #define BULK_TIMEOUT1 10
295 #define BULK_TIMEOUT2 40
329 Q_ASSERT( lines > 0 );
330 Q_ASSERT( columns > 0 );
348 for ( ushort i = 0 ; i < length ; i++ )
360 if ( entry ==
nullptr || entry[0] != length )
364 for (
int i = 0 ; i < length ; i++ )
366 if ( entry[i+1] != unicodePoints[i] )
396 ushort* buffer =
new ushort[length+1];
398 for (
int i = 0 ; i < length ; i++ )
399 buffer[i+1] = unicodePoints[i];
431 while ( iter.hasNext() )
434 delete[] iter.value();
@ 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.
virtual void receiveChar(int ch)
Processes an incoming character.
void usesMouseChanged(bool usesMouse)
virtual void sendMouseEvent(int buttons, int column, int line, int eventType)
Converts information about a mouse event into an xterm-compatible escape sequence and emits the chara...
const QTextCodec * _codec
bool programUsesMouse() const
Returns true if the active terminal program wants mouse input events.
void bracketedPasteModeChanged(bool bracketedPasteMode)
virtual void sendKeyEvent(QKeyEvent *)
Interprets a key press event and emits the sendData() signal with the resulting character stream.
void receiveData(const char *buffer, int len)
Processes an incoming stream of characters.
void programUsesMouseChanged(bool usesMouse)
This is emitted when the program running in the shell indicates whether or not it is interested in mo...
Emulation()
Constructs a new terminal emulation.
void bufferedUpdate()
Schedules an update of attached views.
int lineCount()
Returns the total number of lines, including those stored in the history.
const KeyboardTranslator * _keyTranslator
void programBracketedPasteModeChanged(bool bracketedPasteMode)
QString keyBindings()
Returns the name of the emulation's current key bindings.
const HistoryType & history()
Returns the history store used by this emulation.
void useUtf8Request(bool)
Requests that the pty used by the terminal process be set to UTF 8 mode.
ScreenWindow * createWindow()
Creates a new window onto the output from this emulation.
void imageSizeChanged(int lineCount, int columnCount)
Emitted when the program running in the terminal changes the screen size.
const QTextCodec * codec()
Returns the codec used to decode incoming characters.
void sendData(const char *data, int len)
Emitted when a buffer of data is ready to send to the standard input of 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.
QList< ScreenWindow * > _windows
bool programBracketedPasteMode() const
void setScreen(int index)
Sets the active screen.
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.
virtual void writeToStream(TerminalCharacterDecoder *decoder, int startLine, int endLine)
Copies the output history from startLine to endLine into stream, using decoder to convert the termina...
void outputChanged()
Emitted when the contents of the screen image change.
void stateSet(int state)
Emitted when the activity state of the emulation is set.
virtual char getErase() const
TODO Document me.
void setCodec(const QTextCodec *)
Sets the codec used to decode incoming characters.
virtual void sendString(const char *string, int length=-1)=0
Sends a string of characters to the foreground terminal process.
bool utf8()
Convenience method.
A table which stores sequences of unicode characters, referenced by hash keys.
ushort * lookupExtendedChar(ushort hash, ushort &length) const
Looks up and returns a pointer to a sequence of unicode characters which was added to the table using...
static ExtendedCharTable instance
The global ExtendedCharTable instance.
ushort extendedCharHash(ushort *unicodePoints, ushort length) const
ushort createExtendedChar(ushort *unicodePoints, ushort length)
Adds a sequences of unicode characters to the table and returns a hash code which can be used later t...
QHash< ushort, ushort * > extendedCharTable
ExtendedCharTable()
Constructs a new character table.
bool extendedCharMatch(ushort hash, ushort *unicodePoints, ushort length) const
const KeyboardTranslator * findTranslator(const QString &name)
Returns the keyboard translator with the given name or 0 if no translator with that name exists.
static KeyboardTranslatorManager * instance()
Returns the global KeyboardTranslatorManager instance.
QString name() const
Returns the name of this keyboard translator.
Provides a window onto a section of a terminal screen.
void setScreen(Screen *screen)
Sets the screen which this window looks onto.
An image of characters with associated attributes.
void resizeImage(int new_lines, int new_columns)
Resizes the image to a new fixed size of new_lines by new_columns.
int getColumns()
Return the number of columns.
void setScroll(const HistoryType &, bool copyPreviousScroll=true)
Sets the type of storage used to keep lines in the history.
void setBusySelecting(bool busy)
void writeToStream(TerminalCharacterDecoder *decoder, int from, int to)
Copies part of the output to a stream.
void BackSpace()
Moves the cursor one column to the left and erases the character at the new cursor position.
void Return()
Moves the cursor to the beginning of the current line.
int getHistLines()
Return the number of lines in the history buffer.
void NewLine()
Moves the cursor down one line, if the MODE_NewLine mode flag is enabled then the cursor is returned ...
void Tabulate(int n=1)
Moves the cursor n tab-stops to the right.
void resetScrolledLines()
Resets the count of the number of lines that the image has been scrolled up or down by,...
void resetDroppedLines()
Resets the count of the number of lines dropped from the history.
const HistoryType & getScroll()
Returns the type of storage used to keep lines in the history.
void ShowCharacter(unsigned short c)
Displays a new character at the current cursor position.
int getLines()
Return the number of lines.
Base class for terminal character decoders.
std::string hash(hash_fptr hash_fcn, const std::string &str, int result_buf_len)