Konsole
#include <Screen.h>
Public Member Functions | |
Screen (int lines, int columns) | |
~Screen () | |
void | backspace () |
void | backtab (int n) |
int | bottomMargin () const |
void | changeTabStop (bool set) |
void | checkSelection (int from, int to) |
void | clear () |
void | clearEntireLine () |
void | clearEntireScreen () |
void | clearSelection () |
void | clearTabStops () |
void | clearToBeginOfLine () |
void | clearToBeginOfScreen () |
void | clearToEndOfLine () |
void | clearToEndOfScreen () |
TerminalDisplay * | currentTerminalDisplay () |
void | cursorDown (int n) |
void | cursorLeft (int n) |
void | cursorRight (int n) |
void | cursorUp (int n) |
void | deleteChars (int n) |
void | deleteLines (int n) |
void | displayCharacter (unsigned short c) |
int | droppedLines () const |
void | eraseChars (int n) |
int | getColumns () const |
int | getCursorX () const |
int | getCursorY () const |
int | getHistLines () const |
void | getImage (Character *dest, int size, int startLine, int endLine) const |
QVector< LineProperty > | getLineProperties (int startLine, int endLine) const |
int | getLines () const |
bool | getMode (int mode) const |
const HistoryType & | getScroll () const |
void | getSelectionEnd (int &column, int &line) const |
void | getSelectionStart (int &column, int &line) const |
bool | hasScroll () const |
void | helpAlign () |
void | home () |
void | index () |
void | insertChars (int n) |
void | insertLines (int n) |
bool | isSelected (const int column, const int line) const |
QRect | lastScrolledRegion () const |
void | newLine () |
void | nextLine () |
void | reset (bool clearScreen=true) |
void | resetDroppedLines () |
void | resetMode (int mode) |
void | resetRendition (int rendition) |
void | resetScrolledLines () |
void | resizeImage (int new_lines, int new_columns) |
void | restoreCursor () |
void | restoreMode (int mode) |
void | reverseIndex () |
void | saveCursor () |
void | saveMode (int mode) |
void | scrollDown (int n) |
int | scrolledLines () const |
void | scrollUp (int n) |
QString | selectedText (bool preserveLineBreaks, bool trimTrailingSpaces=false) const |
void | setBackColor (int space, int color) |
void | setCurrentTerminalDisplay (TerminalDisplay *display) |
void | setCursorX (int x) |
void | setCursorY (int y) |
void | setCursorYX (int y, int x) |
void | setDefaultMargins () |
void | setDefaultRendition () |
void | setForeColor (int space, int color) |
void | setLineProperty (LineProperty property, bool enable) |
void | setMargins (int topLine, int bottomLine) |
void | setMode (int mode) |
void | setRendition (int rendition) |
void | setScroll (const HistoryType &, bool copyPreviousScroll=true) |
void | setSelectionEnd (const int column, const int line) |
void | setSelectionStart (const int column, const int line, const bool blockSelectionMode) |
void | tab (int n=1) |
QString | text (int startIndex, int endIndex, bool preserveLineBreaks, bool trimTrailingSpaces=false) const |
int | topMargin () const |
void | toStartOfLine () |
QSet< ushort > | usedExtendedChars () const |
void | writeLinesToStream (TerminalCharacterDecoder *decoder, int fromLine, int toLine) const |
void | writeSelectionToStream (TerminalCharacterDecoder *decoder, bool preserveLineBreaks=true, bool trimTrailingSpaces=false) const |
Static Public Member Functions | |
static void | fillWithDefaultChar (Character *dest, int count) |
Static Public Attributes | |
static const Character | DefaultChar |
Detailed Description
An image of characters with associated attributes.
The terminal emulation ( Emulation ) receives a serial stream of characters from the program currently running in the terminal. From this stream it creates an image of characters which is ultimately rendered by the display widget ( TerminalDisplay ). Some types of emulation may have more than one screen image.
getImage() is used to retrieve the currently visible image which is then used by the display widget to draw the output from the terminal.
The number of lines of output history which are kept in addition to the current screen image depends on the history scroll being used to store the output. The scroll is specified using setScroll() The output history can be retrieved using writeToStream()
The screen image has a selection associated with it, specified using setSelectionStart() and setSelectionEnd(). The selected text can be retrieved using selectedText(). When getImage() is used to retrieve the visible image, characters which are part of the selection have their colors inverted.
Constructor & Destructor Documentation
Screen::Screen | ( | int | lines, |
int | columns | ||
) |
Construct a new screen image of size lines
by columns
.
Definition at line 60 of file Screen.cpp.
Screen::~Screen | ( | ) |
Definition at line 91 of file Screen.cpp.
Member Function Documentation
void Screen::backspace | ( | ) |
Moves the cursor one column to the left and erases the character at the new cursor position.
Definition at line 547 of file Screen.cpp.
void Screen::backtab | ( | int | n | ) |
Moves the cursor n
tab-stops to the left.
Definition at line 573 of file Screen.cpp.
int Screen::bottomMargin | ( | ) | const |
Returns the bottom line of the scrolling region.
Definition at line 151 of file Screen.cpp.
void Screen::changeTabStop | ( | bool | set | ) |
Sets or removes a tab stop at the cursor's current column.
Definition at line 592 of file Screen.cpp.
void Screen::checkSelection | ( | int | from, |
int | to | ||
) |
Checks if the text between from and to is inside the current selection.
If this is the case, the selection is cleared. The from and to are coordinates in the current viewable window. The loc(x,y) macro can be used to generate these values from a column,line pair.
- Parameters
-
from The start of the area to check. to The end of the area to check
Definition at line 619 of file Screen.cpp.
void Screen::clear | ( | ) |
Clear the entire screen and move the cursor to the home position.
Equivalent to calling clearEntireScreen() followed by home().
Definition at line 541 of file Screen.cpp.
void Screen::clearEntireLine | ( | ) |
Clears the whole of the line on which the cursor is currently positioned.
Definition at line 984 of file Screen.cpp.
void Screen::clearEntireScreen | ( | ) |
Clear the whole screen, moving the current screen contents into the history first.
Definition at line 954 of file Screen.cpp.
void Screen::clearSelection | ( | ) |
Clears the current selection.
Definition at line 1029 of file Screen.cpp.
void Screen::clearTabStops | ( | ) |
Clears all the tab stops.
Definition at line 586 of file Screen.cpp.
void Screen::clearToBeginOfLine | ( | ) |
Clears from the current cursor position to the beginning of the line.
Definition at line 979 of file Screen.cpp.
void Screen::clearToBeginOfScreen | ( | ) |
Clear the area of the screen from the current cursor position to the start of the screen.
Definition at line 949 of file Screen.cpp.
void Screen::clearToEndOfLine | ( | ) |
Clears from the current cursor position to the end of the line.
Definition at line 974 of file Screen.cpp.
void Screen::clearToEndOfScreen | ( | ) |
Clear the area of the screen from the current cursor position to the end of the screen.
Definition at line 944 of file Screen.cpp.
|
inline |
void Screen::cursorDown | ( | int | n | ) |
Move the cursor down by n
lines.
The cursor will stop at the bottom margin.
Definition at line 106 of file Screen.cpp.
void Screen::cursorLeft | ( | int | n | ) |
Move the cursor to the left by n
columns.
The cursor will stop at the first column.
Definition at line 115 of file Screen.cpp.
void Screen::cursorRight | ( | int | n | ) |
Move the cursor to the right by n
columns.
The cursor will stop at the right-most column.
Definition at line 123 of file Screen.cpp.
void Screen::cursorUp | ( | int | n | ) |
Move the cursor up by n
lines.
The cursor will stop at the top margin.
Definition at line 97 of file Screen.cpp.
void Screen::deleteChars | ( | int | n | ) |
Delete n
characters beginning from the current cursor position.
If n
is 0 then one character is deleted.
Definition at line 188 of file Screen.cpp.
void Screen::deleteLines | ( | int | n | ) |
Removes n
lines beginning from the current cursor position.
The position of the cursor is not altered. If n
is 0 then one line is removed.
Definition at line 230 of file Screen.cpp.
void Screen::displayCharacter | ( | unsigned short | c | ) |
Displays a new character at the current cursor position.
If the cursor is currently positioned at the right-edge of the screen and line wrapping is enabled then the character is added at the start of a new line below the current one.
If the MODE_Insert screen mode is currently enabled then the character is inserted at the current cursor position, otherwise it will replace the character already at the current cursor position.
Definition at line 629 of file Screen.cpp.
int Screen::droppedLines | ( | ) | const |
Returns the number of lines of output which have been dropped from the history since the last call to resetDroppedLines()
If the history is not unlimited then it will drop the oldest lines of output if new lines are added when it is full.
Definition at line 741 of file Screen.cpp.
void Screen::eraseChars | ( | int | n | ) |
Erase n
characters beginning from the current cursor position.
This is equivalent to over-writing n
characters starting with the current cursor position with spaces. If n
is 0 then one character is erased.
Definition at line 181 of file Screen.cpp.
|
static |
Fills the buffer dest
with count
instances of the default (ie.
blank) Character style.
Definition at line 1383 of file Screen.cpp.
|
inline |
int Screen::getCursorX | ( | ) | const |
Returns the column which the cursor is positioned at.
Definition at line 830 of file Screen.cpp.
int Screen::getCursorY | ( | ) | const |
Returns the line which the cursor is positioned on.
Definition at line 835 of file Screen.cpp.
int Screen::getHistLines | ( | ) | const |
Return the number of lines in the history buffer.
Definition at line 1348 of file Screen.cpp.
void Screen::getImage | ( | Character * | dest, |
int | size, | ||
int | startLine, | ||
int | endLine | ||
) | const |
Returns the current screen image.
The result is an array of Characters of size [getLines()][getColumns()] which must be freed by the caller after use.
- Parameters
-
dest Buffer to copy the characters into size Size of dest
in CharactersstartLine Index of first line to copy endLine Index of last line to copy
Definition at line 450 of file Screen.cpp.
QVector< LineProperty > Screen::getLineProperties | ( | int | startLine, |
int | endLine | ||
) | const |
Returns the additional attributes associated with lines in the image.
The most important attribute is LINE_WRAPPED which specifies that the line is wrapped, other attributes control the size of characters in the line.
Definition at line 485 of file Screen.cpp.
|
inline |
bool Screen::getMode | ( | int | mode | ) | const |
Returns whether the specified screen mode
is enabled or not .
Definition at line 274 of file Screen.cpp.
const HistoryType & Screen::getScroll | ( | ) | const |
Returns the type of storage used to keep lines in the history.
Definition at line 1371 of file Screen.cpp.
void Screen::getSelectionEnd | ( | int & | column, |
int & | line | ||
) | const |
Retrieves the end of the selection or the cursor position if there is no selection.
Definition at line 1046 of file Screen.cpp.
void Screen::getSelectionStart | ( | int & | column, |
int & | line | ||
) | const |
Retrieves the start of the selection or the cursor position if there is no selection.
Definition at line 1036 of file Screen.cpp.
bool Screen::hasScroll | ( | ) | const |
Returns true if this screen keeps lines that are scrolled off the screen in a history buffer.
Definition at line 1366 of file Screen.cpp.
void Screen::helpAlign | ( | ) |
Fills the entire screen with the letter 'E'.
fill screen with 'E' This is to aid screen alignment
Definition at line 969 of file Screen.cpp.
void Screen::home | ( | ) |
Sets the position of the cursor to the 'home' position at the top-left corner of the screen (0,0)
Definition at line 819 of file Screen.cpp.
void Screen::index | ( | ) |
Move the cursor down one line.
If the cursor is on the bottom line of the scrolling region (as returned by bottomMargin()) the scrolling region is scrolled up by one line instead.
Definition at line 156 of file Screen.cpp.
void Screen::insertChars | ( | int | n | ) |
Insert n
blank characters beginning from the current cursor position.
The position of the cursor is not altered. If n
is 0 then one character is inserted.
Definition at line 217 of file Screen.cpp.
void Screen::insertLines | ( | int | n | ) |
Inserts lines
beginning from the current cursor position.
The position of the cursor is not altered. If n
is 0 then one line is inserted.
Definition at line 236 of file Screen.cpp.
bool Screen::isSelected | ( | const int | column, |
const int | line | ||
) | const |
Returns true if the character at (column
, line
) is part of the current selection.
Definition at line 1098 of file Screen.cpp.
QRect Screen::lastScrolledRegion | ( | ) | const |
Returns the region of the image which was last scrolled.
This is the area of the image from the top margin to the bottom margin when the last scroll occurred.
Definition at line 761 of file Screen.cpp.
void Screen::newLine | ( | ) |
Moves the cursor down one line, if the MODE_NewLine mode flag is enabled then the cursor is returned to the leftmost column first.
Equivalent to NextLine() if the MODE_NewLine flag is set or index() otherwise.
Definition at line 611 of file Screen.cpp.
void Screen::nextLine | ( | ) |
Moves the cursor down one line and positions it at the beginning of the line.
Equivalent to calling Return() followed by index()
Definition at line 174 of file Screen.cpp.
void Screen::reset | ( | bool | clearScreen = true | ) |
Resets the state of the screen.
This resets the various screen modes back to their default states. The cursor style and colors are reset (as if setDefaultRendition() had been called)
- Line wrapping is enabled.
- Origin mode is disabled.
- Insert mode is disabled.
- Cursor mode is enabled. TODO Document me
- Screen mode is disabled. TODO Document me
- New line mode is disabled. TODO Document me
If clearScreen
is true then the screen contents are erased entirely, otherwise they are unaltered.
Definition at line 516 of file Screen.cpp.
void Screen::resetDroppedLines | ( | ) |
Resets the count of the number of lines dropped from the history.
Definition at line 745 of file Screen.cpp.
void Screen::resetMode | ( | int | mode | ) |
Resets (clears) the specified screen mode
.
Definition at line 253 of file Screen.cpp.
void Screen::resetRendition | ( | int | rendition | ) |
Disables the given rendition
flag.
Rendition flags control the appearance of characters on the screen.
- See also
- Character::rendition
Definition at line 995 of file Screen.cpp.
void Screen::resetScrolledLines | ( | ) |
Resets the count of the number of lines that the image has been scrolled up or down by, see scrolledLines()
Definition at line 749 of file Screen.cpp.
void Screen::resizeImage | ( | int | new_lines, |
int | new_columns | ||
) |
Resizes the image to a new fixed size of new_lines
by new_columns
.
In the case that new_columns
is smaller than the current number of columns, existing lines are not truncated. This prevents characters from being lost if the terminal display is resized smaller and then larger again.
The top and bottom margins are reset to the top and bottom of the new screen size. Tab stops are also reset and the current selection is cleared.
Definition at line 298 of file Screen.cpp.
void Screen::restoreCursor | ( | ) |
Restores the position and appearance of the cursor.
See saveCursor()
Definition at line 288 of file Screen.cpp.
void Screen::restoreMode | ( | int | mode | ) |
Restores the state of a screen mode
saved by calling saveMode()
Definition at line 269 of file Screen.cpp.
void Screen::reverseIndex | ( | ) |
Move the cursor up one line.
If the cursor is on the top line of the scrolling region (as returned by topMargin()) the scrolling region is scrolled down by one line instead.
Definition at line 165 of file Screen.cpp.
void Screen::saveCursor | ( | ) |
Saves the current position and appearance (text color and style) of the cursor.
It can be restored by calling restoreCursor()
Definition at line 279 of file Screen.cpp.
void Screen::saveMode | ( | int | mode | ) |
Saves the state of the specified screen mode
.
It can be restored using restoreMode()
Definition at line 264 of file Screen.cpp.
void Screen::scrollDown | ( | int | n | ) |
Scroll the scrolling region of the screen down by n
lines.
The scrolling region is initially the whole screen, but can be changed using setMargins()
Definition at line 778 of file Screen.cpp.
int Screen::scrolledLines | ( | ) | const |
Returns the number of lines that the image has been scrolled up or down by, since the last call to resetScrolledLines().
a positive return value indicates that the image has been scrolled up, a negative return value indicates that the image has been scrolled down.
Definition at line 737 of file Screen.cpp.
void Screen::scrollUp | ( | int | n | ) |
Scroll the scrolling region of the screen up by n
lines.
The scrolling region is initially the whole screen, but can be changed using setMargins()
Definition at line 754 of file Screen.cpp.
QString Screen::selectedText | ( | bool | preserveLineBreaks, |
bool | trimTrailingSpaces = false |
||
) | const |
Convenience method.
Returns the currently selected text.
- Parameters
-
preserveLineBreaks Specifies whether new line characters should be inserted into the returned text at the end of each terminal line. trimTrailingSpaces Specifies whether trailing spaces should be trimmed in the returned text.
Definition at line 1110 of file Screen.cpp.
void Screen::setBackColor | ( | int | space, |
int | color | ||
) |
Sets the cursor's background color.
- Parameters
-
space The color space used by the color
argument.color The new background color. The meaning of this depends on the color space
used.
- See also
- CharacterColor
Definition at line 1019 of file Screen.cpp.
|
inline |
void Screen::setCursorX | ( | int | x | ) |
Position the cursor at column x
.
Definition at line 805 of file Screen.cpp.
void Screen::setCursorY | ( | int | y | ) |
Position the cursor on line y
.
Definition at line 812 of file Screen.cpp.
void Screen::setCursorYX | ( | int | y, |
int | x | ||
) |
Position the cursor at line y
, column x
.
Definition at line 799 of file Screen.cpp.
void Screen::setDefaultMargins | ( | ) |
Resets the scrolling margins back to the top and bottom lines of the screen.
Definition at line 341 of file Screen.cpp.
void Screen::setDefaultRendition | ( | ) |
Resets the cursor's color back to the default and sets the character's rendition flags back to the default settings.
Definition at line 1001 of file Screen.cpp.
void Screen::setForeColor | ( | int | space, |
int | color | ||
) |
Sets the cursor's foreground color.
- Parameters
-
space The color space used by the color
argumentcolor The new foreground color. The meaning of this depends on the color space
used.
- See also
- CharacterColor
Definition at line 1009 of file Screen.cpp.
void Screen::setLineProperty | ( | LineProperty | property, |
bool | enable | ||
) |
Sets or clears an attribute of the current line.
- Parameters
-
property The attribute to set or clear Possible properties are: LINE_WRAPPED: Specifies that the line is wrapped. LINE_DOUBLEWIDTH: Specifies that the characters in the current line should be double the normal width. LINE_DOUBLEHEIGHT:Specifies that the characters in the current line should be double the normal height. Double-height lines are formed of two lines containing the same characters, with both having the LINE_DOUBLEHEIGHT attribute. This allows other parts of the code to work on the assumption that all lines are the same height. enable true to apply the attribute to the current line or false to remove it
Definition at line 1376 of file Screen.cpp.
void Screen::setMargins | ( | int | topLine, |
int | bottomLine | ||
) |
Sets the margins for scrolling the screen.
- Parameters
-
topLine The top line of the new scrolling margin. bottomLine The bottom line of the new scrolling margin.
Definition at line 130 of file Screen.cpp.
void Screen::setMode | ( | int | mode | ) |
Sets (enables) the specified screen mode
.
Definition at line 242 of file Screen.cpp.
void Screen::setRendition | ( | int | rendition | ) |
Enables the given rendition
flag.
Rendition flags control the appearance of characters on the screen.
- See also
- Character::rendition
Definition at line 989 of file Screen.cpp.
void Screen::setScroll | ( | const HistoryType & | t, |
bool | copyPreviousScroll = true |
||
) |
Sets the type of storage used to keep lines in the history.
If copyPreviousScroll
is true then the contents of the previous history buffer are copied into the new scroll.
Definition at line 1353 of file Screen.cpp.
void Screen::setSelectionEnd | ( | const int | column, |
const int | line | ||
) |
Sets the end of the current selection.
- Parameters
-
column The column index of the last character in the selection. line The line index of the last character in the selection.
Definition at line 1067 of file Screen.cpp.
void Screen::setSelectionStart | ( | const int | column, |
const int | line, | ||
const bool | blockSelectionMode | ||
) |
Sets the start of the selection.
- Parameters
-
column The column index of the first character in the selection. line The line index of the first character in the selection. blockSelectionMode True if the selection is in column mode.
Definition at line 1056 of file Screen.cpp.
void Screen::tab | ( | int | n = 1 | ) |
Moves the cursor n
tab-stops to the right.
Definition at line 561 of file Screen.cpp.
QString Screen::text | ( | int | startIndex, |
int | endIndex, | ||
bool | preserveLineBreaks, | ||
bool | trimTrailingSpaces = false |
||
) | const |
Convenience method.
Returns the text between two indices.
- Parameters
-
startIndex Specifies the starting text index endIndex Specifies the ending text index preserveLineBreaks Specifies whether new line characters should be inserted into the returned text at the end of each terminal line. trimTrailingSpaces Specifies whether trailing spaces should be trimmed in the returned text.
Definition at line 1118 of file Screen.cpp.
int Screen::topMargin | ( | ) | const |
Returns the top line of the scrolling region.
Definition at line 147 of file Screen.cpp.
void Screen::toStartOfLine | ( | ) |
Moves the cursor to the beginning of the current line.
Equivalent to setCursorX(0)
Definition at line 825 of file Screen.cpp.
|
inline |
void Screen::writeLinesToStream | ( | TerminalCharacterDecoder * | decoder, |
int | fromLine, | ||
int | toLine | ||
) | const |
Copies part of the output to a stream.
- Parameters
-
decoder A decoder which converts terminal characters into text fromLine The first line in the history to retrieve toLine The last line in the history to retrieve
Definition at line 1290 of file Screen.cpp.
void Screen::writeSelectionToStream | ( | TerminalCharacterDecoder * | decoder, |
bool | preserveLineBreaks = true , |
||
bool | trimTrailingSpaces = false |
||
) | const |
Copies the selected characters, set using.
- See also
- setSelBeginXY and
- setSelExtentXY into a stream.
- Parameters
-
decoder A decoder which converts terminal characters into text. PlainTextDecoder is the most commonly used decoder which converts characters into plain text with no formatting. preserveLineBreaks Specifies whether new line characters should be inserted into the returned text at the end of each terminal line. trimTrailingSpaces Specifies whether trailing spaces should be trimmed in the returned text.
Definition at line 1136 of file Screen.cpp.
Member Data Documentation
|
static |
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:25 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.