Konsole::Screen

Search for usage in LXR

#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 ()
 
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 (QChar c)
 
int droppedLines () const
 
void eraseChars (int n)
 
int getColumns () const
 
int getCursorX () const
 
int getCursorY () const
 
int getHistLines () const
 
void getImage (std::span< 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 repeatChars (int count)
 
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) const
 
void setBackColor (int space, int color)
 
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)
 
int topMargin () const
 
void toStartOfLine ()
 
void writeLinesToStream (TerminalCharacterDecoder *decoder, int fromLine, int toLine) const
 
void writeSelectionToStream (TerminalCharacterDecoder *decoder, bool preserveLineBreaks=true) const
 

Static Public Member Functions

static void fillWithDefaultChar (std::span< Character > dest, int count)
 

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 colours inverted.

Definition at line 69 of file Screen.h.

Constructor & Destructor Documentation

◆ Screen()

Screen::Screen ( int lines,
int columns )

Construct a new screen image of size lines by columns.

Definition at line 65 of file Screen.cpp.

◆ ~Screen()

Screen::~Screen ( )

Destructor

Definition at line 98 of file Screen.cpp.

Member Function Documentation

◆ backspace()

void Screen::backspace ( )

Moves the cursor one column to the left and erases the character at the new cursor position.

Definition at line 567 of file Screen.cpp.

◆ backtab()

void Screen::backtab ( int n)

Moves the cursor n tab-stops to the left.

Definition at line 592 of file Screen.cpp.

◆ bottomMargin()

int Screen::bottomMargin ( ) const

Returns the bottom line of the scrolling region.

Definition at line 161 of file Screen.cpp.

◆ changeTabStop()

void Screen::changeTabStop ( bool set)

Sets or removes a tab stop at the cursor's current column.

Definition at line 611 of file Screen.cpp.

◆ checkSelection()

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
fromThe start of the area to check.
toThe end of the area to check

Definition at line 636 of file Screen.cpp.

◆ clear()

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 561 of file Screen.cpp.

◆ clearEntireLine()

void Screen::clearEntireLine ( )

Clears the whole of the line on which the cursor is currently positioned.

Definition at line 977 of file Screen.cpp.

◆ clearEntireScreen()

void Screen::clearEntireScreen ( )

Clear the whole screen, moving the current screen contents into the history first.

Definition at line 947 of file Screen.cpp.

◆ clearSelection()

void Screen::clearSelection ( )

Clears the current selection.

Definition at line 1022 of file Screen.cpp.

◆ clearTabStops()

void Screen::clearTabStops ( )

Clears all the tab stops.

Definition at line 605 of file Screen.cpp.

◆ clearToBeginOfLine()

void Screen::clearToBeginOfLine ( )

Clears from the current cursor position to the beginning of the line.

Definition at line 972 of file Screen.cpp.

◆ clearToBeginOfScreen()

void Screen::clearToBeginOfScreen ( )

Clear the area of the screen from the current cursor position to the start of the screen.

Definition at line 942 of file Screen.cpp.

◆ clearToEndOfLine()

void Screen::clearToEndOfLine ( )

Clears from the current cursor position to the end of the line.

Definition at line 967 of file Screen.cpp.

◆ clearToEndOfScreen()

void Screen::clearToEndOfScreen ( )

Clear the area of the screen from the current cursor position to the end of the screen.

Definition at line 937 of file Screen.cpp.

◆ compose()

void Screen::compose ( const QString & compose)

Definition at line 707 of file Screen.cpp.

◆ cursorDown()

void Screen::cursorDown ( int n)

Move the cursor down by n lines.

The cursor will stop at the bottom margin.

Definition at line 112 of file Screen.cpp.

◆ cursorLeft()

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 122 of file Screen.cpp.

◆ cursorRight()

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 131 of file Screen.cpp.

◆ cursorUp()

void Screen::cursorUp ( int n)

Move the cursor up by n lines.

The cursor will stop at the top margin.

Definition at line 102 of file Screen.cpp.

◆ deleteChars()

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 199 of file Screen.cpp.

◆ deleteLines()

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 254 of file Screen.cpp.

◆ displayCharacter()

void Screen::displayCharacter ( QChar 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 646 of file Screen.cpp.

◆ droppedLines()

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 724 of file Screen.cpp.

◆ eraseChars()

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 191 of file Screen.cpp.

◆ fillWithDefaultChar()

void Screen::fillWithDefaultChar ( std::span< Character > dest,
int count )
static

Fills the buffer dest with count instances of the default (ie.

blank) Character style.

Definition at line 1329 of file Screen.cpp.

◆ getColumns()

int Konsole::Screen::getColumns ( ) const
inline

Return the number of columns.

Definition at line 390 of file Screen.h.

◆ getCursorX()

int Screen::getCursorX ( ) const

Returns the column which the cursor is positioned at.

Definition at line 823 of file Screen.cpp.

◆ getCursorY()

int Screen::getCursorY ( ) const

Returns the line which the cursor is positioned on.

Definition at line 828 of file Screen.cpp.

◆ getHistLines()

int Screen::getHistLines ( ) const

Return the number of lines in the history buffer.

Definition at line 1295 of file Screen.cpp.

◆ getImage()

void Screen::getImage ( std::span< 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
destBuffer to copy the characters into
sizeSize of dest in Characters
startLineIndex of first line to copy
endLineIndex of last line to copy

Definition at line 475 of file Screen.cpp.

◆ getLineProperties()

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 508 of file Screen.cpp.

◆ getLines()

int Konsole::Screen::getLines ( ) const
inline

Return the number of lines.

Definition at line 385 of file Screen.h.

◆ getMode()

bool Screen::getMode ( int mode) const

Returns whether the specified screen mode is enabled or not .

Definition at line 300 of file Screen.cpp.

◆ getScroll()

const HistoryType & Screen::getScroll ( ) const

Returns the type of storage used to keep lines in the history.

Definition at line 1317 of file Screen.cpp.

◆ getSelectionEnd()

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 1039 of file Screen.cpp.

◆ getSelectionStart()

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 1029 of file Screen.cpp.

◆ hasScroll()

bool Screen::hasScroll ( ) const

Returns true if this screen keeps lines that are scrolled off the screen in a history buffer.

Definition at line 1312 of file Screen.cpp.

◆ helpAlign()

void Screen::helpAlign ( )

Fills the entire screen with the letter 'E'.

fill screen with 'E' This is to aid screen alignment

Definition at line 962 of file Screen.cpp.

◆ home()

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 812 of file Screen.cpp.

◆ index()

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 166 of file Screen.cpp.

◆ insertChars()

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 220 of file Screen.cpp.

◆ insertLines()

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 261 of file Screen.cpp.

◆ isSelected()

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 1092 of file Screen.cpp.

◆ lastScrolledRegion()

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 746 of file Screen.cpp.

◆ newLine()

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 629 of file Screen.cpp.

◆ nextLine()

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 184 of file Screen.cpp.

◆ repeatChars()

void Screen::repeatChars ( int count)

Repeat the preceeding graphic character @count times, including SPACE.

If @count is 0 then the character is repeated once.

From ECMA-48 version 5, section 8.3.103 If the character preceding REP is a control function or part of a control function, the effect of REP is not defined by this Standard.

So, a "normal" program should always use REP immediately after a visible character (those other than escape sequences). So, lastDrawnChar can be safely used.

Definition at line 234 of file Screen.cpp.

◆ reset()

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 539 of file Screen.cpp.

◆ resetDroppedLines()

void Screen::resetDroppedLines ( )

Resets the count of the number of lines dropped from the history.

Definition at line 728 of file Screen.cpp.

◆ resetMode()

void Screen::resetMode ( int mode)

Resets (clears) the specified screen mode.

Definition at line 279 of file Screen.cpp.

◆ resetRendition()

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 988 of file Screen.cpp.

◆ resetScrolledLines()

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 732 of file Screen.cpp.

◆ resizeImage()

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.

◆ restoreCursor()

void Screen::restoreCursor ( )

Restores the position and appearance of the cursor.

See saveCursor()

Definition at line 314 of file Screen.cpp.

◆ restoreMode()

void Screen::restoreMode ( int mode)

Restores the state of a screen mode saved by calling saveMode()

Definition at line 295 of file Screen.cpp.

◆ reverseIndex()

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 175 of file Screen.cpp.

◆ saveCursor()

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 305 of file Screen.cpp.

◆ saveMode()

void Screen::saveMode ( int mode)

Saves the state of the specified screen mode.

It can be restored using restoreMode()

Definition at line 290 of file Screen.cpp.

◆ scrollDown()

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 768 of file Screen.cpp.

◆ scrolledLines()

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 720 of file Screen.cpp.

◆ scrollUp()

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 737 of file Screen.cpp.

◆ selectedText()

QString Screen::selectedText ( bool preserveLineBreaks) const

Convenience method.

Returns the currently selected text.

Parameters
preserveLineBreaksSpecifies whether new line characters should be inserted into the returned text at the end of each terminal line.

Definition at line 1103 of file Screen.cpp.

◆ setBackColor()

void Screen::setBackColor ( int space,
int color )

Sets the cursor's background color.

Parameters
spaceThe color space used by the color argumnet.
colorThe new background color. The meaning of this depends on the color space used.
See also
CharacterColor

Definition at line 1012 of file Screen.cpp.

◆ setCursorX()

void Screen::setCursorX ( int x)

Position the cursor at column x.

Definition at line 796 of file Screen.cpp.

◆ setCursorY()

void Screen::setCursorY ( int y)

Position the cursor on line y.

Definition at line 804 of file Screen.cpp.

◆ setCursorYX()

void Screen::setCursorYX ( int y,
int x )

Position the cursor at line y, column x.

Definition at line 790 of file Screen.cpp.

◆ setDefaultMargins()

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.

◆ setDefaultRendition()

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 994 of file Screen.cpp.

◆ setForeColor()

void Screen::setForeColor ( int space,
int color )

Sets the cursor's foreground color.

Parameters
spaceThe color space used by the color argument
colorThe new foreground color. The meaning of this depends on the color space used.
See also
CharacterColor

Definition at line 1002 of file Screen.cpp.

◆ setLineProperty()

void Screen::setLineProperty ( LineProperty property,
bool enable )

Sets or clears an attribute of the current line.

Parameters
propertyThe 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.
enabletrue to apply the attribute to the current line or false to remove it

Definition at line 1322 of file Screen.cpp.

◆ setMargins()

void Screen::setMargins ( int topLine,
int bottomLine )

Sets the margins for scrolling the screen.

Parameters
topLineThe top line of the new scrolling margin.
bottomLineThe bottom line of the new scrolling margin.

Definition at line 139 of file Screen.cpp.

◆ setMode()

void Screen::setMode ( int mode)

Sets (enables) the specified screen mode.

Definition at line 268 of file Screen.cpp.

◆ setRendition()

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 982 of file Screen.cpp.

◆ setScroll()

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 1300 of file Screen.cpp.

◆ setSelectionEnd()

void Screen::setSelectionEnd ( const int column,
const int line )

Sets the end of the current selection.

Parameters
columnThe column index of the last character in the selection.
lineThe line index of the last character in the selection.

Definition at line 1061 of file Screen.cpp.

◆ setSelectionStart()

void Screen::setSelectionStart ( const int column,
const int line,
const bool blockSelectionMode )

Sets the start of the selection.

Parameters
columnThe column index of the first character in the selection.
lineThe line index of the first character in the selection.
blockSelectionModeTrue if the selection is in column mode.

Definition at line 1049 of file Screen.cpp.

◆ tab()

void Screen::tab ( int n = 1)

Moves the cursor n tab-stops to the right.

Definition at line 579 of file Screen.cpp.

◆ topMargin()

int Screen::topMargin ( ) const

Returns the top line of the scrolling region.

Definition at line 157 of file Screen.cpp.

◆ toStartOfLine()

void Screen::toStartOfLine ( )

Moves the cursor to the beginning of the current line.

Equivalent to setCursorX(0)

Definition at line 818 of file Screen.cpp.

◆ writeLinesToStream()

void Screen::writeLinesToStream ( TerminalCharacterDecoder * decoder,
int fromLine,
int toLine ) const

Copies part of the output to a stream.

Parameters
decoderA decoder which converts terminal characters into text
fromLineThe first line in the history to retrieve
toLineThe last line in the history to retrieve

Definition at line 1237 of file Screen.cpp.

◆ writeSelectionToStream()

void Screen::writeSelectionToStream ( TerminalCharacterDecoder * decoder,
bool preserveLineBreaks = true ) const

Copies the selected characters, set using.

See also
setSelBeginXY and
setSelExtentXY into a stream.
Parameters
decoderA decoder which converts terminal characters into text. PlainTextDecoder is the most commonly used decoder which converts characters into plain text with no formatting.
preserveLineBreaksSpecifies whether new line characters should be inserted into the returned text at the end of each terminal line.

Definition at line 1121 of file Screen.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:04:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.