Konsole
Konsole::Screen Class Reference
#include <Screen.h>
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 the visible image, characters which are part of the selection have their colours inverted.
Definition at line 78 of file Screen.h.
Public Member Functions | |
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 () |
void | compose (const QString &compose) |
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 () |
int | getCursorX () const |
int | getCursorY () const |
int | getHistLines () |
QString | getHistoryLine (int no) |
void | getImage (Character *dest, int size, int startLine, int endLine) const |
QVector< LineProperty > | getLineProperties (int startLine, int endLine) const |
int | getLines () |
bool | getMode (int mode) const |
const HistoryType & | getScroll () |
void | getSelectionEnd (int &column, int &line) |
void | getSelectionStart (int &column, int &line) |
bool | hasScroll () |
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) |
Screen (int lines, int columns) | |
void | scrollDown (int n) |
int | scrolledLines () const |
void | scrollUp (int n) |
QString | selectedText (bool preserveLineBreaks) |
void | setBackColor (int space, int color) |
void | setBusySelecting (bool busy) |
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 columnmode) |
void | tab (int n=1) |
int | topMargin () const |
void | toStartOfLine () |
void | writeSelectionToStream (TerminalCharacterDecoder *decoder, bool preserveLineBreaks=true) |
void | writeToStream (TerminalCharacterDecoder *decoder, int from, int to) |
~Screen () | |
Static Public Member Functions | |
static void | fillWithDefaultChar (Character *dest, int count) |
Constructor & Destructor Documentation
Screen::Screen | ( | int | lines, | |
int | columns | |||
) |
Screen::~Screen | ( | ) |
Destructor
Definition at line 100 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 592 of file Screen.cpp.
void Screen::backtab | ( | int | n | ) |
int Screen::bottomMargin | ( | ) | const |
void Screen::changeTabStop | ( | bool | set | ) |
Sets or removes a tab stop at the cursor's current column.
Definition at line 631 of file Screen.cpp.
void Screen::checkSelection | ( | int | from, | |
int | to | |||
) |
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 586 of file Screen.cpp.
void Screen::clearEntireLine | ( | ) |
Clears the whole of the line on which the cursor is currently positioned.
Definition at line 1009 of file Screen.cpp.
void Screen::clearEntireScreen | ( | ) |
Clear the whole screen, moving the current screen contents into the history first.
Definition at line 979 of file Screen.cpp.
void Screen::clearSelection | ( | ) |
void Screen::clearTabStops | ( | ) |
void Screen::clearToBeginOfLine | ( | ) |
Clears from the current cursor position to the beginning of the line.
Definition at line 1004 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 974 of file Screen.cpp.
void Screen::clearToEndOfLine | ( | ) |
Clears from the current cursor position to the end of the line.
Definition at line 999 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 969 of file Screen.cpp.
void Screen::compose | ( | const QString & | compose | ) |
Definition at line 734 of file Screen.cpp.
void Screen::cursorDown | ( | int | n | ) |
Move the cursor down by n
lines.
The cursor will stop at the bottom margin.
Definition at line 134 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 143 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 151 of file Screen.cpp.
void Screen::cursorUp | ( | int | n | ) |
Move the cursor up by n
lines.
The cursor will stop at the top margin.
Cursor
The `cursor' is a location within the screen that is implicitely used in many operations. The operations within this section allow to manipulate the cursor explicitly and to obtain it's value.The position of the cursor is guarantied to be between (including) 0 and `columns-1' and `lines-1'.
Definition at line 125 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 218 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 252 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 665 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 751 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 211 of file Screen.cpp.
void Screen::fillWithDefaultChar | ( | Character * | dest, | |
int | count | |||
) | [static] |
Fills the buffer dest
with count
instances of the default (ie.
blank) Character style.
Definition at line 1420 of file Screen.cpp.
int Konsole::Screen::getColumns | ( | ) | [inline] |
int Screen::getCursorX | ( | ) | const |
int Screen::getCursorY | ( | ) | const |
int Screen::getHistLines | ( | ) |
QString Screen::getHistoryLine | ( | int | no | ) |
Sets the selection to line no
in the history and returns the text of that line from the history buffer.
Definition at line 1311 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 498 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 533 of file Screen.cpp.
int Konsole::Screen::getLines | ( | ) | [inline] |
bool Screen::getMode | ( | int | mode | ) | const |
Returns whether the specified screen mode
is enabled or not .
Definition at line 294 of file Screen.cpp.
const HistoryType & Screen::getScroll | ( | ) |
Returns the type of storage used to keep lines in the history.
Definition at line 1404 of file Screen.cpp.
void Screen::getSelectionEnd | ( | int & | column, | |
int & | line | |||
) |
Retrieves the end of the selection or the cursor position if there is no selection.
Definition at line 1080 of file Screen.cpp.
void Screen::getSelectionStart | ( | int & | column, | |
int & | line | |||
) |
Retrieves the start of the selection or the cursor position if there is no selection.
Definition at line 1067 of file Screen.cpp.
bool Screen::hasScroll | ( | ) |
Returns true if this screen keeps lines that are scrolled off the screen in a history buffer.
Definition at line 1399 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 994 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 827 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 185 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 239 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 258 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 1124 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 773 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 648 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 205 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 567 of file Screen.cpp.
void Screen::resetDroppedLines | ( | ) |
Resets the count of the number of lines dropped from the history.
Definition at line 755 of file Screen.cpp.
void Screen::resetMode | ( | int | mode | ) |
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 1020 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 759 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 324 of file Screen.cpp.
void Screen::restoreCursor | ( | ) |
Restores the position and appearance of the cursor.
See saveCursor()
Definition at line 308 of file Screen.cpp.
void Screen::restoreMode | ( | int | mode | ) |
Restores the state of a screen mode
saved by calling saveMode().
Definition at line 289 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 196 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 299 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 284 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 790 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 747 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 766 of file Screen.cpp.
QString Screen::selectedText | ( | bool | preserveLineBreaks | ) |
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.
Definition at line 1142 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
argumnet.color The new background color. The meaning of this depends on the color space
used.
- See also:
- CharacterColor
Definition at line 1044 of file Screen.cpp.
void Konsole::Screen::setBusySelecting | ( | bool | busy | ) | [inline] |
void Screen::setCursorX | ( | int | x | ) |
void Screen::setCursorY | ( | int | y | ) |
void Screen::setCursorYX | ( | int | y, | |
int | x | |||
) |
void Screen::setDefaultMargins | ( | ) |
Resets the scrolling margins back to the top and bottom lines of the screen.
Definition at line 366 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 1026 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 1034 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 1409 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 158 of file Screen.cpp.
void Screen::setMode | ( | int | mode | ) |
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 1014 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 1385 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 1104 of file Screen.cpp.
void Screen::setSelectionStart | ( | const int | column, | |
const int | line, | |||
const bool | columnmode | |||
) |
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. columnmode True if the selection is in column mode.
Definition at line 1093 of file Screen.cpp.
void Screen::tab | ( | int | n = 1 |
) |
int Screen::topMargin | ( | ) | const |
void Screen::toStartOfLine | ( | ) |
Moves the cursor to the beginning of the current line.
Equivalent to setCursorX(0)
Definition at line 833 of file Screen.cpp.
void Screen::writeSelectionToStream | ( | TerminalCharacterDecoder * | decoder, | |
bool | preserveLineBreaks = true | |||
) |
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 coverts 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.
Definition at line 1160 of file Screen.cpp.
void Screen::writeToStream | ( | TerminalCharacterDecoder * | decoder, | |
int | from, | |||
int | to | |||
) |
Copies part of the output to a stream.
- Parameters:
-
decoder A decoder which coverts terminal characters into text from The first line in the history to retrieve to The last line in the history to retrieve
Definition at line 1302 of file Screen.cpp.
The documentation for this class was generated from the following files: