27 #include <QtCore/QTextStream>
35 using namespace Konsole;
51 #define loc(X,Y) ((Y)*_columns+(X))
64 _screenLinesSize(_lines),
76 _blockSelectionMode(false),
82 _lineProperties.
resize(_lines + 1);
83 for (
int i = 0; i < _lines + 1; i++)
93 delete[] _screenLines;
101 const int stop = _cuY < _topMargin ? 0 : _topMargin;
102 _cuX = qMin(_columns - 1, _cuX);
103 _cuY = qMax(stop, _cuY - n);
110 const int stop = _cuY > _bottomMargin ? _lines - 1 : _bottomMargin;
111 _cuX = qMin(_columns - 1, _cuX);
112 _cuY = qMin(stop, _cuY + n);
119 _cuX = qMin(_columns - 1, _cuX);
120 _cuX = qMax(0, _cuX - n);
127 _cuX = qMin(_columns - 1, _cuX + n);
133 if (top == 0) top = 1;
134 if (bot == 0) bot = _lines;
137 if (!(0 <= top && top < bot && bot < _lines)) {
153 return _bottomMargin;
159 if (_cuY == _bottomMargin)
161 else if (_cuY < _lines - 1)
168 if (_cuY == _topMargin)
184 const int p = qMax(0, qMin(_cuX + n - 1, _columns - 1));
185 clearImage(
loc(_cuX, _cuY),
loc(p, _cuY),
' ');
197 if (_cuX >= _screenLines[_cuY].count())
200 if (_cuX + n > _screenLines[_cuY].count())
201 n = _screenLines[_cuY].
count() - _cuX;
204 Q_ASSERT(_cuX + n <= _screenLines[_cuY].count());
206 _screenLines[_cuY].
remove(_cuX, n);
209 Character spaceWithCurrentAttrs(
' ', _effectiveForeground,
210 _effectiveBackground,
211 _effectiveRendition,
false);
213 for (
int i = 0; i < n; i++)
214 _screenLines[_cuY].append(spaceWithCurrentAttrs);
221 if (_screenLines[_cuY].size() < _cuX)
222 _screenLines[_cuY].
resize(_cuX);
226 if (_screenLines[_cuY].count() > _columns)
227 _screenLines[_cuY].
resize(_columns);
244 _currentModes[m] =
true;
255 _currentModes[m] =
false;
266 _savedModes[m] = _currentModes[m];
271 _currentModes[m] = _savedModes[m];
276 return _currentModes[m];
281 _savedState.cursorColumn = _cuX;
282 _savedState.cursorLine = _cuY;
283 _savedState.rendition = _currentRendition;
284 _savedState.foreground = _currentForeground;
285 _savedState.background = _currentBackground;
290 _cuX = qMin(_savedState.cursorColumn, _columns - 1);
291 _cuY = qMin(_savedState.cursorLine, _lines - 1);
292 _currentRendition = _savedState.rendition;
293 _currentForeground = _savedState.foreground;
294 _currentBackground = _savedState.background;
295 updateEffectiveRendition();
300 if ((new_lines == _lines) && (new_columns == _columns))
return;
302 if (_cuY > new_lines - 1) {
304 _bottomMargin = _lines - 1;
305 for (
int i = 0; i < _cuY - (new_lines - 1); i++) {
314 for (
int i = 0; i < qMin(_lines, new_lines + 1) ; i++)
315 newScreenLines[i] = _screenLines[i];
316 for (
int i = _lines; (i > 0) && (i < new_lines + 1); i++)
317 newScreenLines[i].resize(new_columns);
319 _lineProperties.
resize(new_lines + 1);
320 for (
int i = _lines; (i > 0) && (i < new_lines + 1); i++)
325 delete[] _screenLines;
326 _screenLines = newScreenLines;
327 _screenLinesSize = new_lines;
330 _columns = new_columns;
331 _cuX = qMin(_cuX, _columns - 1);
332 _cuY = qMin(_cuY, _lines - 1);
336 _bottomMargin = _lines - 1;
344 _bottomMargin = _lines - 1;
381 void Screen::reverseRendition(
Character& p)
const
390 void Screen::updateEffectiveRendition()
392 _effectiveRendition = _currentRendition;
394 _effectiveForeground = _currentBackground;
395 _effectiveBackground = _currentForeground;
397 _effectiveForeground = _currentForeground;
398 _effectiveBackground = _currentBackground;
401 if (_currentRendition &
RE_BOLD)
405 void Screen::copyFromHistory(
Character* dest,
int startLine,
int count)
const
407 Q_ASSERT(startLine >= 0 && count > 0 && startLine + count <= _history->
getLines());
409 for (
int line = startLine; line < startLine + count; line++) {
410 const int length = qMin(_columns, _history->
getLineLen(line));
411 const int destLineOffset = (line - startLine) * _columns;
413 _history->
getCells(line, 0, length, dest + destLineOffset);
415 for (
int column = length; column < _columns; column++)
419 if (_selBegin != -1) {
420 for (
int column = 0; column < _columns; column++) {
422 reverseRendition(dest[destLineOffset + column]);
429 void Screen::copyFromScreen(
Character* dest ,
int startLine ,
int count)
const
431 Q_ASSERT(startLine >= 0 && count > 0 && startLine + count <= _lines);
433 for (
int line = startLine; line < (startLine + count) ; line++) {
434 int srcLineStartIndex = line * _columns;
435 int destLineStartIndex = (line - startLine) * _columns;
437 for (
int column = 0; column < _columns; column++) {
438 int srcIndex = srcLineStartIndex + column;
439 int destIndex = destLineStartIndex + column;
445 reverseRendition(dest[destIndex]);
452 Q_ASSERT(startLine >= 0);
453 Q_ASSERT(endLine >= startLine && endLine < _history->
getLines() + _lines);
455 const int mergedLines = endLine - startLine + 1;
457 Q_ASSERT(size >= mergedLines * _columns);
460 const int linesInHistoryBuffer = qBound(0, _history->
getLines() - startLine, mergedLines);
461 const int linesInScreenBuffer = mergedLines - linesInHistoryBuffer;
464 if (linesInHistoryBuffer > 0)
465 copyFromHistory(dest, startLine, linesInHistoryBuffer);
468 if (linesInScreenBuffer > 0)
469 copyFromScreen(dest + linesInHistoryBuffer * _columns,
470 startLine + linesInHistoryBuffer - _history->
getLines(),
471 linesInScreenBuffer);
475 for (
int i = 0; i < mergedLines * _columns; i++)
476 reverseRendition(dest[i]);
480 int cursorIndex =
loc(_cuX, _cuY + linesInHistoryBuffer);
487 Q_ASSERT(startLine >= 0);
488 Q_ASSERT(endLine >= startLine && endLine < _history->
getLines() + _lines);
490 const int mergedLines = endLine - startLine + 1;
491 const int linesInHistory = qBound(0, _history->
getLines() - startLine, mergedLines);
492 const int linesInScreen = mergedLines - linesInHistory;
498 for (
int line = startLine; line < startLine + linesInHistory; line++) {
507 const int firstScreenLine = startLine + linesInHistory - _history->
getLines();
508 for (
int line = firstScreenLine; line < firstScreenLine + linesInScreen; line++) {
509 result[
index] = _lineProperties[line];
532 _bottomMargin = _lines - 1;
549 _cuX = qMin(_columns - 1, _cuX);
550 _cuX = qMax(0, _cuX - 1);
552 if (_screenLines[_cuY].size() < _cuX + 1)
553 _screenLines[_cuY].
resize(_cuX + 1);
556 _screenLines[_cuY][_cuX].character =
' ';
557 _screenLines[_cuY][_cuX].rendition = _screenLines[_cuY][_cuX].rendition & ~
RE_EXTENDED_CHAR;
565 while ((n > 0) && (_cuX < _columns - 1)) {
567 while ((_cuX < _columns - 1) && !_tabStops[_cuX])
577 while ((n > 0) && (_cuX > 0)) {
579 while ((_cuX > 0) && !_tabStops[_cuX]) {
588 for (
int i = 0; i < _columns; i++)
589 _tabStops[i] =
false;
594 if (_cuX >= _columns)
597 _tabStops[_cuX] = set;
600 void Screen::initTabStops()
602 _tabStops.
resize(_columns);
607 for (
int i = 0; i < _columns; i++)
608 _tabStops[i] = (i % 8 == 0 && i != 0);
625 if ((_selBottomRight >= (from + scr_TL)) && (_selTopLeft <= (to + scr_TL)))
640 if (
QChar(c).category() != QChar::Mark_NonSpacing)
642 int charToCombineWithX = -1;
643 int charToCombineWithY = -1;
647 if (_cuY > 0 && _columns == _screenLines[_cuY - 1].size()) {
648 charToCombineWithX = _columns - 1;
649 charToCombineWithY = _cuY - 1;
657 charToCombineWithX = _cuX - 1;
658 charToCombineWithY = _cuY;
662 if (charToCombineWithX >= _screenLines[charToCombineWithY].size()) {
666 Character& currentChar = _screenLines[charToCombineWithY][charToCombineWithX];
668 const ushort chars[2] = { currentChar.
character, c };
672 ushort extendedCharLength;
676 Q_ASSERT(extendedCharLength > 1);
677 Q_ASSERT(extendedCharLength < 65535);
678 ushort* chars =
new ushort[extendedCharLength + 1];
679 memcpy(chars, oldChars,
sizeof(ushort) * extendedCharLength);
680 chars[extendedCharLength] = c;
688 if (_cuX + w > _columns) {
698 if (_screenLines[_cuY].size() < _cuX + w) {
699 _screenLines[_cuY].
resize(_cuX + w);
704 _lastPos =
loc(_cuX, _cuY);
709 Character& currentChar = _screenLines[_cuY][_cuX];
714 currentChar.
rendition = _effectiveRendition;
718 const int newCursorX = _cuX + w--;
722 if (_screenLines[_cuY].size() < _cuX + i + 1)
723 _screenLines[_cuY].
resize(_cuX + i + 1);
725 Character& ch = _screenLines[_cuY][_cuX + i];
739 return _scrolledLines;
743 return _droppedLines;
757 if (_topMargin == 0) addHistLine();
763 return _lastScrolledRegion;
768 if (n <= 0 || from + n > _bottomMargin)
return;
771 _lastScrolledRegion =
QRect(0, _topMargin, _columns - 1, (_bottomMargin - _topMargin));
774 moveImage(
loc(0, from),
loc(0, from + n),
loc(_columns - 1, _bottomMargin));
775 clearImage(
loc(0, _bottomMargin - n + 1),
loc(_columns - 1, _bottomMargin),
' ');
791 if (from > _bottomMargin)
793 if (from + n > _bottomMargin)
794 n = _bottomMargin - from;
795 moveImage(
loc(0, from + n),
loc(0, from),
loc(_columns - 1, _bottomMargin - n));
796 clearImage(
loc(0, from),
loc(_columns - 1, from + n - 1),
' ');
809 _cuX = qMax(0, qMin(_columns - 1, x));
840 void Screen::clearImage(
int loca,
int loce,
char c)
846 if ((_selBottomRight > (loca + scr_TL)) && (_selTopLeft < (loce + scr_TL))) {
850 const int topLine = loca / _columns;
851 const int bottomLine = loce / _columns;
859 for (
int y = topLine; y <= bottomLine; y++) {
860 _lineProperties[y] = 0;
862 const int endCol = (y == bottomLine) ? loce % _columns : _columns - 1;
863 const int startCol = (y == topLine) ? loca % _columns : 0;
867 if (isDefaultCh && endCol == _columns - 1) {
870 if (line.
size() < endCol + 1)
874 for (
int i = startCol; i <= endCol; i++)
880 void Screen::moveImage(
int dest,
int sourceBegin,
int sourceEnd)
882 Q_ASSERT(sourceBegin <= sourceEnd);
884 const int lines = (sourceEnd - sourceBegin) / _columns;
891 if (dest < sourceBegin) {
892 for (
int i = 0; i <= lines; i++) {
893 _screenLines[(dest / _columns) + i ] = _screenLines[(sourceBegin / _columns) + i ];
894 _lineProperties[(dest / _columns) + i] = _lineProperties[(sourceBegin / _columns) + i];
897 for (
int i = lines; i >= 0; i--) {
898 _screenLines[(dest / _columns) + i ] = _screenLines[(sourceBegin / _columns) + i ];
899 _lineProperties[(dest / _columns) + i] = _lineProperties[(sourceBegin / _columns) + i];
903 if (_lastPos != -1) {
904 const int diff = dest - sourceBegin;
906 if ((_lastPos < 0) || (_lastPos >= (lines * _columns)))
911 if (_selBegin != -1) {
912 const bool beginIsTL = (_selBegin == _selTopLeft);
913 const int diff = dest - sourceBegin;
915 const int srca = sourceBegin + scr_TL;
916 const int srce = sourceEnd + scr_TL;
917 const int desta = srca + diff;
918 const int deste = srce + diff;
920 if ((_selTopLeft >= srca) && (_selTopLeft <= srce))
922 else if ((_selTopLeft >= desta) && (_selTopLeft <= deste))
923 _selBottomRight = -1;
925 if ((_selBottomRight >= srca) && (_selBottomRight <= srce))
926 _selBottomRight += diff;
927 else if ((_selBottomRight >= desta) && (_selBottomRight <= deste))
928 _selBottomRight = -1;
930 if (_selBottomRight < 0) {
938 _selBegin = _selTopLeft;
940 _selBegin = _selBottomRight;
946 clearImage(
loc(_cuX, _cuY),
loc(_columns - 1, _lines - 1),
' ');
951 clearImage(
loc(0, 0),
loc(_cuX, _cuY),
' ');
957 for (
int i = 0; i < (_lines - 1); i++) {
962 clearImage(
loc(0, 0),
loc(_columns - 1, _lines - 1),
' ');
971 clearImage(
loc(0, 0),
loc(_columns - 1, _lines - 1),
'E');
976 clearImage(
loc(_cuX, _cuY),
loc(_columns - 1, _cuY),
' ');
981 clearImage(
loc(0, _cuY),
loc(_cuX, _cuY),
' ');
986 clearImage(
loc(0, _cuY),
loc(_columns - 1, _cuY),
' ');
991 _currentRendition |= rendention;
992 updateEffectiveRendition();
997 _currentRendition &= ~rendention;
998 updateEffectiveRendition();
1006 updateEffectiveRendition();
1013 if (_currentForeground.
isValid())
1014 updateEffectiveRendition();
1023 if (_currentBackground.
isValid())
1024 updateEffectiveRendition();
1031 _selBottomRight = -1;
1038 if (_selTopLeft != -1) {
1039 column = _selTopLeft % _columns;
1040 line = _selTopLeft / _columns;
1048 if (_selBottomRight != -1) {
1049 column = _selBottomRight % _columns;
1050 line = _selBottomRight / _columns;
1058 _selBegin =
loc(x, y);
1060 if (x == _columns) _selBegin--;
1062 _selBottomRight = _selBegin;
1063 _selTopLeft = _selBegin;
1064 _blockSelectionMode = blockSelectionMode;
1069 if (_selBegin == -1)
1072 int endPos =
loc(x, y);
1074 if (endPos < _selBegin) {
1075 _selTopLeft = endPos;
1076 _selBottomRight = _selBegin;
1082 _selTopLeft = _selBegin;
1083 _selBottomRight = endPos;
1087 if (_blockSelectionMode) {
1088 const int topRow = _selTopLeft / _columns;
1089 const int topColumn = _selTopLeft % _columns;
1090 const int bottomRow = _selBottomRight / _columns;
1091 const int bottomColumn = _selBottomRight % _columns;
1093 _selTopLeft =
loc(qMin(topColumn, bottomColumn), topRow);
1094 _selBottomRight =
loc(qMax(topColumn, bottomColumn), bottomRow);
1100 bool columnInSelection =
true;
1101 if (_blockSelectionMode) {
1102 columnInSelection = x >= (_selTopLeft % _columns) &&
1103 x <= (_selBottomRight % _columns);
1106 const int pos =
loc(x, y);
1107 return pos >= _selTopLeft && pos <= _selBottomRight && columnInSelection;
1112 if (!isSelectionValid())
1115 return text(_selTopLeft, _selBottomRight, preserveLineBreaks, trimTrailingSpaces);
1121 QTextStream stream(&result, QIODevice::ReadWrite);
1124 decoder.
begin(&stream);
1125 writeToStream(&decoder, startIndex, endIndex, preserveLineBreaks, trimTrailingSpaces);
1131 bool Screen::isSelectionValid()
const
1133 return _selTopLeft >= 0 && _selBottomRight >= 0;
1137 bool preserveLineBreaks,
1138 bool trimTrailingSpaces)
const
1140 if (!isSelectionValid())
1142 writeToStream(decoder, _selTopLeft, _selBottomRight, preserveLineBreaks, trimTrailingSpaces);
1146 int startIndex,
int endIndex,
1147 bool preserveLineBreaks,
1148 bool trimTrailingSpaces)
const
1150 const int top = startIndex / _columns;
1151 const int left = startIndex % _columns;
1153 const int bottom = endIndex / _columns;
1154 const int right = endIndex % _columns;
1156 Q_ASSERT(top >= 0 && left >= 0 && bottom >= 0 && right >= 0);
1158 for (
int y = top; y <= bottom; y++) {
1160 if (y == top || _blockSelectionMode) start = left;
1163 if (y == bottom || _blockSelectionMode) count = right - start + 1;
1165 const bool appendNewLine = (y != bottom);
1166 int copied = copyLineToStream(y,
1172 trimTrailingSpaces);
1187 int Screen::copyLineToStream(
int line ,
1192 bool preserveLineBreaks,
1193 bool trimTrailingSpaces)
const
1199 static const int MAX_CHARS = 1024;
1200 static Character characterBuffer[MAX_CHARS];
1202 Q_ASSERT(count < MAX_CHARS);
1208 const int lineLength = _history->
getLineLen(line);
1211 start = qMin(start, qMax(0, lineLength - 1));
1217 count = lineLength - start;
1219 count = qMin(start + count, lineLength) - start;
1223 Q_ASSERT(start >= 0);
1224 Q_ASSERT(count >= 0);
1225 Q_ASSERT((start + count) <= _history->
getLineLen(line));
1227 _history->
getCells(line, start, count, characterBuffer);
1233 count = _columns - start;
1235 Q_ASSERT(count >= 0);
1237 int screenLine = line - _history->
getLines();
1239 Q_ASSERT(screenLine <= _screenLinesSize);
1241 screenLine = qMin(screenLine, _screenLinesSize);
1244 int length = _screenLines[screenLine].
count();
1247 if (trimTrailingSpaces && !(_lineProperties[screenLine] &
LINE_WRAPPED))
1250 for (
int i = length-1; i >= 0; i--)
1252 if (data[i].character ==
' ')
1260 for (
int i = start; i < qMin(start + count, length); i++) {
1261 characterBuffer[i - start] = data[i];
1265 count = qBound(0, count, length - start);
1267 Q_ASSERT(screenLine < _lineProperties.
count());
1268 currentLineProperties |= _lineProperties[screenLine];
1271 if (appendNewLine && (count + 1 < MAX_CHARS)) {
1272 if (currentLineProperties & LINE_WRAPPED) {
1278 characterBuffer[count] = preserveLineBreaks ?
Character(
'\n') : Character(
' ');
1285 count, currentLineProperties);
1292 writeToStream(decoder,
loc(0, fromLine),
loc(_columns - 1, toLine));
1295 void Screen::addHistLine()
1301 const int oldHistLines = _history->
getLines();
1304 _history->
addLine(_lineProperties[0] & LINE_WRAPPED);
1306 const int newHistLines = _history->
getLines();
1308 const bool beginIsTL = (_selBegin == _selTopLeft);
1312 if (newHistLines == oldHistLines)
1316 if (newHistLines > oldHistLines) {
1317 if (_selBegin != -1) {
1318 _selTopLeft += _columns;
1319 _selBottomRight += _columns;
1323 if (_selBegin != -1) {
1325 const int top_BR =
loc(0, 1 + newHistLines);
1327 if (_selTopLeft < top_BR)
1328 _selTopLeft -= _columns;
1330 if (_selBottomRight < top_BR)
1331 _selBottomRight -= _columns;
1333 if (_selBottomRight < 0) {
1336 if (_selTopLeft < 0)
1341 _selBegin = _selTopLeft;
1343 _selBegin = _selBottomRight;
1357 if (copyPreviousScroll) {
1358 _history = t.
scroll(_history);
1379 _lineProperties[_cuY] = (
LineProperty)(_lineProperties[_cuY] | property);
1381 _lineProperties[_cuY] = (
LineProperty)(_lineProperties[_cuY] & ~property);
1385 for (
int i = 0; i < count; i++)
bool hasScroll() const
Returns true if this screen keeps lines that are scrolled off the screen in a history buffer...
int droppedLines() const
Returns the number of lines of output which have been dropped from the history since the last call to...
virtual void end()
End decoding.
virtual void decodeLine(const Character *const characters, int count, LineProperty properties)=0
Converts a line of terminal characters with associated properties into a text string and writes the s...
void helpAlign()
Fills the entire screen with the letter 'E'.
void deleteChars(int n)
Delete n characters beginning from the current cursor position.
void cursorLeft(int n)
Move the cursor to the left by n columns.
QRect lastScrolledRegion() const
Returns the region of the image which was last scrolled.
void writeLinesToStream(TerminalCharacterDecoder *decoder, int fromLine, int toLine) const
Copies part of the output to a stream.
void resetMode(int mode)
Resets (clears) the specified screen mode.
void setDefaultRendition()
Resets the cursor's color back to the default and sets the character's rendition flags back to the de...
void scrollDown(int n)
Scroll the scrolling region of the screen down by n lines.
void clearTabStops()
Clears all the tab stops.
void clearToEndOfScreen()
Clear the area of the screen from the current cursor position to the end of the screen.
quint16 character
The unicode character value for this character.
QString selectedText(bool preserveLineBreaks, bool trimTrailingSpaces=false) const
Convenience method.
ushort createExtendedChar(const ushort *unicodePoints, ushort length)
Adds a sequences of unicode characters to the table and returns a hash code which can be used later t...
int getLines() const
Return the number of lines.
const HistoryType & getType() const
static ExtendedCharTable instance
The global ExtendedCharTable instance.
#define DEFAULT_FORE_COLOR
void clearEntireScreen()
Clear the whole screen, moving the current screen contents into the history first.
void getImage(Character *dest, int size, int startLine, int endLine) const
Returns the current screen image.
#define COLOR_SPACE_DEFAULT
int topMargin() const
Returns the top line of the scrolling region.
void cursorRight(int n)
Move the cursor to the right by n columns.
void reverseIndex()
Move the cursor up one line.
void insertChars(int n)
Insert n blank characters beginning from the current cursor position.
void insert(int i, const T &value)
int KONSOLEPRIVATE_EXPORT konsole_wcwidth(quint16 oucs)
const HistoryType & getScroll() const
Returns the type of storage used to keep lines in the history.
unsigned char LineProperty
virtual void getCells(int lineno, int colno, int count, Character res[])=0
void eraseChars(int n)
Erase n characters beginning from the current cursor position.
void setIntensive()
Set this color as an intensive system color.
void clearToEndOfLine()
Clears from the current cursor position to the end of the line.
void changeTabStop(bool set)
Sets or removes a tab stop at the cursor's current column.
void clearEntireLine()
Clears the whole of the line on which the cursor is currently positioned.
static void fillWithDefaultChar(Character *dest, int count)
Fills the buffer dest with count instances of the default (ie.
bool getMode(int mode) const
Returns whether the specified screen mode is enabled or not .
void setCursorYX(int y, int x)
Position the cursor at line y, column x.
void resetRendition(int rendition)
Disables the given rendition flag.
virtual bool isWrappedLine(int lineno)=0
QString text(int startIndex, int endIndex, bool preserveLineBreaks, bool trimTrailingSpaces=false) const
Convenience method.
A terminal character decoder which produces plain text, ignoring colors and other appearance-related ...
void cursorUp(int n)
Move the cursor up by n lines.
void index()
Move the cursor down one line.
void setMargins(int topLine, int bottomLine)
Sets the margins for scrolling the screen.
static const Character DefaultChar
A single character in the terminal which consists of a unicode character value, foreground and backgr...
bool isRealCharacter
Indicate whether this character really exists, or exists simply as place holder.
virtual void addLine(bool previousWrapped=false)=0
void resetScrolledLines()
Resets the count of the number of lines that the image has been scrolled up or down by...
Base class for terminal character decoders.
void setCursorY(int y)
Position the cursor on line y.
void clear()
Clear the entire screen and move the cursor to the home position.
virtual void addCellsVector(const QVector< Character > &cells)
void setForeColor(int space, int color)
Sets the cursor's foreground color.
void checkSelection(int from, int to)
Checks if the text between from and to is inside the current selection.
void displayCharacter(unsigned short c)
Displays a new character at the current cursor position.
void setScroll(const HistoryType &, bool copyPreviousScroll=true)
Sets the type of storage used to keep lines in the history.
int scrolledLines() const
Returns the number of lines that the image has been scrolled up or down by, since the last call to re...
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...
void newLine()
Moves the cursor down one line, if the MODE_NewLine mode flag is enabled then the cursor is returned ...
void toStartOfLine()
Moves the cursor to the beginning of the current line.
void setBackColor(int space, int color)
Sets the cursor's background color.
void cursorDown(int n)
Move the cursor down by n lines.
CharacterColor backgroundColor
The color used to draw this character's background.
void scrollUp(int n)
Scroll the scrolling region of the screen up by n lines.
void restoreCursor()
Restores the position and appearance of the cursor.
void clearSelection()
Clears the current selection.
const int DEFAULT_RENDITION
void insertLines(int n)
Inserts lines beginning from the current cursor position.
virtual int getLineLen(int lineno)=0
Describes the color of a single character in the terminal.
void getSelectionStart(int &column, int &line) const
Retrieves the start of the selection or the cursor position if there is no selection.
void setRendition(int rendition)
Enables the given rendition flag.
void clearToBeginOfLine()
Clears from the current cursor position to the beginning of the line.
void deleteLines(int n)
Removes n lines beginning from the current cursor position.
int bottomMargin() const
Returns the bottom line of the scrolling region.
virtual void begin(QTextStream *output)
Begin decoding characters.
Screen(int lines, int columns)
Construct a new screen image of size lines by columns.
void restoreMode(int mode)
Restores the state of a screen mode saved by calling saveMode()
bool isSelected(const int column, const int line) const
Returns true if the character at (column, line) is part of the current selection. ...
void clearToBeginOfScreen()
Clear the area of the screen from the current cursor position to the start of the screen...
void setDefaultMargins()
Resets the scrolling margins back to the top and bottom lines of the screen.
void getSelectionEnd(int &column, int &line) const
Retrieves the end of the selection or the cursor position if there is no selection.
int getCursorX() const
Returns the column which the cursor is positioned at.
void backspace()
Moves the cursor one column to the left and erases the character at the new cursor position...
void resizeImage(int new_lines, int new_columns)
Resizes the image to a new fixed size of new_lines by new_columns.
int getCursorY() const
Returns the line which the cursor is positioned on.
void reset(bool clearScreen=true)
Resets the state of the screen.
int count(const T &value) const
void setSelectionEnd(const int column, const int line)
Sets the end of the current selection.
void resetDroppedLines()
Resets the count of the number of lines dropped from the history.
void setLineProperty(LineProperty property, bool enable)
Sets or clears an attribute of the current line.
void backtab(int n)
Moves the cursor n tab-stops to the left.
void saveCursor()
Saves the current position and appearance (text color and style) of the cursor.
void nextLine()
Moves the cursor down one line and positions it at the beginning of the line.
void home()
Sets the position of the cursor to the 'home' position at the top-left corner of the screen (0...
void setCursorX(int x)
Position the cursor at column x.
void setMode(int mode)
Sets (enables) the specified screen mode.
void setSelectionStart(const int column, const int line, const bool blockSelectionMode)
Sets the start of the selection.
int getHistLines() const
Return the number of lines in the history buffer.
QVector< LineProperty > getLineProperties(int startLine, int endLine) const
Returns the additional attributes associated with lines in the image.
quint8 rendition
A combination of RENDITION flags which specify options for drawing the character. ...
void tab(int n=1)
Moves the cursor n tab-stops to the right.
void saveMode(int mode)
Saves the state of the specified screen mode.
CharacterColor foregroundColor
The foreground color used to draw this character.
bool isValid() const
Returns true if this character color entry is valid.
void writeSelectionToStream(TerminalCharacterDecoder *decoder, bool preserveLineBreaks=true, bool trimTrailingSpaces=false) const
Copies the selected characters, set using.
const int RE_EXTENDED_CHAR
virtual HistoryScroll * scroll(HistoryScroll *) const =0
Converts from one type of HistoryScroll to another or if given the same type, returns it...
#define DEFAULT_BACK_COLOR