GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Screen Class Reference

An image of characters with associated attributes. More...

#include "Screen.h"

Collaboration diagram for Screen:

Public Member Functions

 Screen (int lines, int columns)
 Construct a new screen image of size lines by columns. More...
 
 ~Screen ()
 
void BackSpace ()
 Moves the cursor one column to the left and erases the character at the new cursor position. More...
 
void backTabulate (int n)
 Moves the cursor n tab-stops to the left. More...
 
int bottomMargin () const
 Returns the bottom line of the scrolling region. More...
 
void changeTabStop (bool set)
 Sets or removes a tab stop at the cursor's current column. More...
 
void checkSelection (int from, int to)
 TODO Document me. More...
 
void clear ()
 TODO Document me. More...
 
void clearEntireLine ()
 Clears the whole of the line on which the cursor is currently positioned. More...
 
void clearEntireScreen ()
 Clear the whole screen, moving the current screen contents into the history first. More...
 
void clearSelection ()
 Clears the current selection. More...
 
void clearTabStops ()
 Clears all the tab stops. More...
 
void clearToBeginOfLine ()
 Clears from the current cursor position to the beginning of the line. More...
 
void clearToBeginOfScreen ()
 Clear the area of the screen from the current cursor position to the start of the screen. More...
 
void clearToEndOfLine ()
 Clears from the current cursor position to the end of the line. More...
 
void clearToEndOfScreen ()
 Clear the area of the screen from the current cursor position to the end of the screen. More...
 
void compose (const QString &compose)
 
void cursorDown (int n)
 Move the cursor down by n lines. More...
 
void cursorLeft (int n)
 Move the cursor to the left by n columns. More...
 
void cursorRight (int n)
 Move the cursor to the right by n columns. More...
 
void cursorUp (int n)
 Move the cursor up by n lines. More...
 
void deleteChars (int n)
 Delete n characters beginning from the current cursor position. More...
 
void deleteLines (int n)
 Removes n lines beginning from the current cursor position. More...
 
int droppedLines () const
 Returns the number of lines of output which have been dropped from the history since the last call to resetDroppedLines() More...
 
void eraseChars (int n)
 Erase n characters beginning from the current cursor position. More...
 
int getColumns ()
 Return the number of columns. More...
 
int getCursorX () const
 Returns the column which the cursor is positioned at. More...
 
int getCursorY () const
 Returns the line which the cursor is positioned on. More...
 
int getHistLines ()
 Return the number of lines in the history buffer. More...
 
QString getHistoryLine (int no)
 Sets the selection to line no in the history and returns the text of that line from the history buffer. More...
 
void getImage (Character *dest, int size, int startLine, int endLine) const
 Returns the current screen image. More...
 
QVector< LinePropertygetLineProperties (int startLine, int endLine) const
 Returns the additional attributes associated with lines in the image. More...
 
int getLines ()
 Return the number of lines. More...
 
bool getMode (int mode) const
 Returns whether the specified screen mode is enabled or not . More...
 
const HistoryTypegetScroll ()
 Returns the type of storage used to keep lines in the history. More...
 
void getSelectionEnd (int &column, int &line)
 Retrieves the end of the selection or the cursor position if there is no selection. More...
 
void getSelectionStart (int &column, int &line)
 Retrieves the start of the selection or the cursor position if there is no selection. More...
 
bool hasScroll ()
 Returns true if this screen keeps lines that are scrolled off the screen in a history buffer. More...
 
void helpAlign ()
 Fills the entire screen with the letter 'E'. More...
 
void home ()
 Sets the position of the cursor to the 'home' position at the top-left corner of the screen (0,0) More...
 
void index ()
 Move the cursor down one line. More...
 
void insertChars (int n)
 Insert n blank characters beginning from the current cursor position. More...
 
void insertLines (int n)
 Inserts lines beginning from the current cursor position. More...
 
bool isSelected (const int column, const int line) const
 Returns true if the character at (column, line) is part of the current selection. More...
 
QRect lastScrolledRegion () const
 Returns the region of the image which was last scrolled. More...
 
void 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. More...
 
void NextLine ()
 Moves the cursor down one line and positions it at the beginning of the line. More...
 
void reset (bool clearScreen=true)
 Resets the state of the screen. More...
 
void resetDroppedLines ()
 Resets the count of the number of lines dropped from the history. More...
 
void resetMode (int mode)
 Resets (clears) the specified screen mode. More...
 
void resetRendition (int rendition)
 Disables the given rendition flag. More...
 
void resetScrolledLines ()
 Resets the count of the number of lines that the image has been scrolled up or down by, see scrolledLines() More...
 
void resizeImage (int new_lines, int new_columns)
 Resizes the image to a new fixed size of new_lines by new_columns. More...
 
void restoreCursor ()
 Restores the position and appearence of the cursor. More...
 
void restoreMode (int mode)
 Restores the state of a screen mode saved by calling saveMode() More...
 
void Return ()
 Moves the cursor to the beginning of the current line. More...
 
void reverseIndex ()
 Move the cursor up one line. More...
 
void saveCursor ()
 Saves the current position and appearence (text color and style) of the cursor. More...
 
void saveMode (int mode)
 Saves the state of the specified screen mode. More...
 
void scrollDown (int n)
 Scroll the scrolling region of the screen down by n lines. More...
 
int scrolledLines () const
 Returns the number of lines that the image has been scrolled up or down by, since the last call to resetScrolledLines(). More...
 
void scrollUp (int n)
 Scroll the scrolling region of the screen up by n lines. More...
 
QString selectedText (bool preserveLineBreaks)
 Convenience method. More...
 
void setBackColor (int space, int color)
 Sets the cursor's background color. More...
 
void setBusySelecting (bool busy)
 
void setCursorX (int x)
 Position the cursor at column x. More...
 
void setCursorY (int y)
 Position the cursor on line y. More...
 
void setCursorYX (int y, int x)
 Position the cursor at line y, column x. More...
 
void setDefaultMargins ()
 Resets the scrolling margins back to the top and bottom lines of the screen. More...
 
void setDefaultRendition ()
 Resets the cursor's color back to the default and sets the character's rendition flags back to the default settings. More...
 
void setForeColor (int space, int color)
 Sets the cursor's foreground color. More...
 
void setLineProperty (LineProperty property, bool enable)
 Sets or clears an attribute of the current line. More...
 
void setMargins (int topLine, int bottomLine)
 Sets the margins for scrolling the screen. More...
 
void setMode (int mode)
 Sets (enables) the specified screen mode. More...
 
void setRendition (int rendition)
 Enables the given rendition flag. More...
 
void setScroll (const HistoryType &, bool copyPreviousScroll=true)
 Sets the type of storage used to keep lines in the history. More...
 
void setSelectionEnd (const int column, const int line)
 Sets the end of the current selection. More...
 
void setSelectionStart (const int column, const int line, const bool columnmode)
 Sets the start of the selection. More...
 
void ShowCharacter (unsigned short c)
 Displays a new character at the current cursor position. More...
 
void Tabulate (int n=1)
 Moves the cursor n tab-stops to the right. More...
 
int topMargin () const
 Returns the top line of the scrolling region. More...
 
void writeSelectionToStream (TerminalCharacterDecoder *decoder, bool preserveLineBreaks=true)
 Copies the selected characters, set using. More...
 
void writeToStream (TerminalCharacterDecoder *decoder, int from, int to)
 Copies part of the output to a stream. More...
 

Static Public Member Functions

static void fillWithDefaultChar (Character *dest, int count)
 Fills the buffer dest with count instances of the default (ie. More...
 

Private Types

typedef QVector< CharacterImageLine
 

Private Member Functions

void addHistLine ()
 
void clearImage (int loca, int loce, char c)
 
void copyFromHistory (Character *dest, int startLine, int count) const
 
void copyFromScreen (Character *dest, int startLine, int count) const
 
void copyLineToStream (int line, int start, int count, TerminalCharacterDecoder *decoder, bool appendNewLine, bool preserveLineBreaks)
 
void effectiveRendition ()
 
void initTabStops ()
 
bool isSelectionValid () const
 
void moveImage (int dest, int sourceBegin, int sourceEnd)
 
void reverseRendition (Character &p) const
 
void scrollDown (int from, int i)
 
void scrollUp (int from, int i)
 

Private Attributes

int _droppedLines
 
QRect _lastScrolledRegion
 
int _scrolledLines
 
int bmargin
 
bool columnmode
 
int columns
 
CharacterColor cu_bg
 
CharacterColor cu_fg
 
quint8 cu_re
 
ScreenParm currParm
 
int cuX
 
int cuY
 
CharacterColor ef_bg
 
CharacterColor ef_fg
 
quint8 ef_re
 
HistoryScrollhist
 
int lastPos
 
QVarLengthArray< LineProperty, 64 > lineProperties
 
int lines
 
CharacterColor sa_cu_bg
 
CharacterColor sa_cu_fg
 
quint8 sa_cu_re
 
int sa_cuX
 
int sa_cuY
 
ScreenParm saveParm
 
ImageLinescreenLines
 
int sel_begin
 
int sel_BR
 
bool sel_busy
 
int sel_TL
 
bool * tabstops
 
int tmargin
 

Static Private Attributes

static 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 the visible image, characters which are part of the selection have their colours inverted.

Definition at line 75 of file Screen.h.

Member Typedef Documentation

◆ ImageLine

typedef QVector<Character> Screen::ImageLine
private

Definition at line 588 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 67 of file Screen.cpp.

References clearSelection(), initTabStops(), LINE_DEFAULT, lineProperties, lines, and reset().

◆ ~Screen()

Screen::~Screen ( )

Destructor

Definition at line 98 of file Screen.cpp.

References hist, screenLines, and tabstops.

Member Function Documentation

◆ addHistLine()

◆ BackSpace()

void Screen::BackSpace ( )

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

Definition at line 667 of file Screen.cpp.

References BS_CLEARS, columns, cuX, cuY, and screenLines.

Referenced by Emulation::receiveChar(), and Vt102Emulation::tau().

◆ backTabulate()

void Screen::backTabulate ( int  n)

Moves the cursor n tab-stops to the left.

Definition at line 690 of file Screen.cpp.

References cursorLeft(), cuX, n, and tabstops.

Referenced by Vt102Emulation::tau().

◆ bottomMargin()

int Screen::bottomMargin ( ) const

Returns the bottom line of the scrolling region.

Definition at line 202 of file Screen.cpp.

References bmargin.

◆ changeTabStop()

void Screen::changeTabStop ( bool  set)

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

Definition at line 706 of file Screen.cpp.

References columns, cuX, and tabstops.

Referenced by Vt102Emulation::tau().

◆ checkSelection()

void Screen::checkSelection ( int  from,
int  to 
)

TODO Document me.

put ‘c’ literally onto the screen at the current cursor position.

VT100 uses the convention to produce an automatic newline (am) with the first character that would fall onto the next line (xenl).

Definition at line 741 of file Screen.cpp.

References clearSelection(), HistoryScroll::getLines(), hist, loc, sel_begin, sel_BR, and sel_TL.

◆ clear()

void Screen::clear ( void  )

TODO Document me.

Clear the entire screen and home the cursor.

Definition at line 661 of file Screen.cpp.

References clearEntireScreen(), and home().

Referenced by reset().

◆ clearEntireLine()

void Screen::clearEntireLine ( )

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

Definition at line 1143 of file Screen.cpp.

References clearImage(), columns, cuY, and loc.

Referenced by Vt102Emulation::tau().

◆ clearEntireScreen()

void Screen::clearEntireScreen ( )

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

Definition at line 1113 of file Screen.cpp.

References addHistLine(), clearImage(), columns, lines, loc, and scrollUp().

Referenced by clear(), Vt102Emulation::clearEntireScreen(), and Vt102Emulation::tau().

◆ clearImage()

void Screen::clearImage ( int  loca,
int  loce,
char  c 
)
private

Erasing

This group of operations erase parts of the screen contents by filling it with spaces colored due to the current rendition settings.

Althought the cursor position is involved in most of these operations, it is never modified by them.

fill screen between (including) ‘loca’ (start) and ‘loce’ (end) with spaces.

This is an internal helper functions. The parameter types are internal addresses of within the screen image and make use of the way how the screen matrix is mapped to the image vector.

Definition at line 968 of file Screen.cpp.

References clearSelection(), columns, cu_bg, cu_fg, DEFAULT_RENDITION, HistoryScroll::getLines(), hist, lineProperties, loc, screenLines, sel_BR, and sel_TL.

Referenced by clearEntireLine(), clearEntireScreen(), clearToBeginOfLine(), clearToBeginOfScreen(), clearToEndOfLine(), clearToEndOfScreen(), eraseChars(), helpAlign(), scrollDown(), and scrollUp().

◆ clearSelection()

void Screen::clearSelection ( )

◆ clearTabStops()

void Screen::clearTabStops ( )

Clears all the tab stops.

Definition at line 701 of file Screen.cpp.

References columns, and tabstops.

Referenced by Vt102Emulation::tau().

◆ clearToBeginOfLine()

void Screen::clearToBeginOfLine ( )

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

Definition at line 1138 of file Screen.cpp.

References clearImage(), cuX, cuY, and loc.

Referenced by Vt102Emulation::tau().

◆ clearToBeginOfScreen()

void Screen::clearToBeginOfScreen ( )

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

Definition at line 1108 of file Screen.cpp.

References clearImage(), cuX, cuY, and loc.

Referenced by Vt102Emulation::tau().

◆ clearToEndOfLine()

void Screen::clearToEndOfLine ( )

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

Definition at line 1133 of file Screen.cpp.

References clearImage(), columns, cuX, cuY, and loc.

Referenced by Vt102Emulation::tau().

◆ clearToEndOfScreen()

void Screen::clearToEndOfScreen ( )

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

Definition at line 1103 of file Screen.cpp.

References clearImage(), columns, cuX, cuY, lines, and loc.

Referenced by Vt102Emulation::tau().

◆ compose()

void Screen::compose ( const QString &  compose)

Definition at line 821 of file Screen.cpp.

◆ copyFromHistory()

void Screen::copyFromHistory ( Character dest,
int  startLine,
int  count 
) const
private

returns the image.

Get the size of the image by

See also
getLines and
getColumns.

NOTE that the image returned by this function must later be freed.

Definition at line 512 of file Screen.cpp.

References columns, defaultChar, HistoryScroll::getCells(), HistoryScroll::getLineLen(), getLines(), hist, isSelected(), reverseRendition(), and sel_begin.

Referenced by getImage().

◆ copyFromScreen()

void Screen::copyFromScreen ( Character dest,
int  startLine,
int  count 
) const
private

◆ copyLineToStream()

void Screen::copyLineToStream ( int  line,
int  start,
int  count,
TerminalCharacterDecoder decoder,
bool  appendNewLine,
bool  preserveLineBreaks 
)
private

◆ cursorDown()

void Screen::cursorDown ( int  n)

Move the cursor down by n lines.

Move the cursor down.

The cursor will not be moved beyond the bottom margin.

Definition at line 144 of file Screen.cpp.

References bmargin, columns, cuX, cuY, lines, and n.

Referenced by Vt102Emulation::tau().

◆ cursorLeft()

void Screen::cursorLeft ( int  n)

Move the cursor to the left by n columns.

Move the cursor left.

The cursor will not move beyond the first column.

Definition at line 159 of file Screen.cpp.

References columns, cuX, and n.

Referenced by backTabulate(), and Vt102Emulation::tau().

◆ cursorRight()

void Screen::cursorRight ( int  n)

Move the cursor to the right by n columns.

Move the cursor left.

The cursor will not move beyond the rightmost column.

Definition at line 173 of file Screen.cpp.

References columns, cuX, and n.

Referenced by Tabulate(), and Vt102Emulation::tau().

◆ cursorUp()

void Screen::cursorUp ( int  n)

Move the cursor up by n lines.

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’.

Move the cursor up.

The cursor will not be moved beyond the top margin.

Definition at line 129 of file Screen.cpp.

References columns, cuX, cuY, n, and tmargin.

Referenced by Vt102Emulation::tau().

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

References cuX, cuY, n, and screenLines.

Referenced by Vt102Emulation::tau().

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

References cuY, n, and scrollUp().

Referenced by Vt102Emulation::tau().

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

References _droppedLines.

Referenced by ScreenWindow::notifyOutputChanged().

◆ effectiveRendition()

void Screen::effectiveRendition ( )
private

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

References clearImage(), columns, cuX, cuY, loc, and n.

Referenced by Vt102Emulation::tau().

◆ fillWithDefaultChar()

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

References defaultChar.

Referenced by ScreenWindow::fillUnusedArea().

◆ getColumns()

int Screen::getColumns ( )
inline

Return the number of columns.

Definition at line 379 of file Screen.h.

References columns.

Referenced by ScreenWindow::columnCount(), Emulation::imageSize(), and ScreenWindow::windowColumns().

◆ getCursorX()

int Screen::getCursorX ( ) const

Returns the column which the cursor is positioned at.

Definition at line 940 of file Screen.cpp.

References cuX.

Referenced by ScreenWindow::cursorPosition(), and Vt102Emulation::reportCursorPosition().

◆ getCursorY()

int Screen::getCursorY ( ) const

Returns the line which the cursor is positioned on.

Definition at line 945 of file Screen.cpp.

References cuY.

Referenced by ScreenWindow::cursorPosition(), and Vt102Emulation::reportCursorPosition().

◆ getHistLines()

int Screen::getHistLines ( )

Return the number of lines in the history buffer.

Definition at line 1522 of file Screen.cpp.

References HistoryScroll::getLines(), and hist.

Referenced by ScreenWindow::fillUnusedArea(), getSelectionEnd(), getSelectionStart(), Emulation::lineCount(), ScreenWindow::lineCount(), and ScreenWindow::notifyOutputChanged().

◆ getHistoryLine()

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

References columns, loc, sel_begin, sel_BR, sel_TL, and selectedText().

◆ getImage()

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

References columns, copyFromHistory(), copyFromScreen(), cuX, cuY, getLines(), HistoryScroll::getLines(), getMode(), hist, lines, loc, MODE_Cursor, MODE_Screen, RE_CURSOR, Character::rendition, and reverseRendition().

Referenced by ScreenWindow::getImage().

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

References getLines(), HistoryScroll::getLines(), hist, index(), HistoryScroll::isWrappedLine(), LINE_WRAPPED, lineProperties, and lines.

Referenced by ScreenWindow::getLineProperties().

◆ getLines()

◆ getMode()

bool Screen::getMode ( int  mode) const

Returns whether the specified screen mode is enabled or not .

Definition at line 336 of file Screen.cpp.

References currParm, m, and ScreenParm::mode.

Referenced by getImage(), NewLine(), setCursorY(), setMargins(), and ShowCharacter().

◆ getScroll()

const HistoryType & Screen::getScroll ( )

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

Definition at line 1546 of file Screen.cpp.

References HistoryScroll::getType(), and hist.

Referenced by Emulation::history().

◆ getSelectionEnd()

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

References columns, cuX, cuY, getHistLines(), and sel_BR.

Referenced by ScreenWindow::getSelectionEnd().

◆ getSelectionStart()

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

References columns, cuX, cuY, getHistLines(), and sel_TL.

Referenced by ScreenWindow::getSelectionStart().

◆ hasScroll()

bool Screen::hasScroll ( )

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

Definition at line 1541 of file Screen.cpp.

References HistoryScroll::hasScroll(), and hist.

Referenced by addHistLine().

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

References clearImage(), columns, lines, and loc.

Referenced by Vt102Emulation::tau().

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

References cuX, and cuY.

Referenced by clear().

◆ index()

void Screen::index ( void  )

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

References bmargin, cuY, lines, and scrollUp().

Referenced by getLineProperties(), NewLine(), NextLine(), and Vt102Emulation::tau().

◆ initTabStops()

void Screen::initTabStops ( )
private

Definition at line 712 of file Screen.cpp.

References columns, and tabstops.

Referenced by Screen(), and resizeImage().

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

References columns, cuX, cuY, n, and screenLines.

Referenced by ShowCharacter(), and Vt102Emulation::tau().

◆ 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.

insert ‘n’ lines at the cursor position.

The cursor is not moved by the operation.

Definition at line 292 of file Screen.cpp.

References cuY, n, and scrollDown().

Referenced by Vt102Emulation::tau().

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

References columnmode, columns, loc, sel_BR, sel_TL, and x.

Referenced by copyFromHistory(), copyFromScreen(), and ScreenWindow::isSelected().

◆ isSelectionValid()

bool Screen::isSelectionValid ( ) const
private

Definition at line 1294 of file Screen.cpp.

References sel_BR, and sel_TL.

Referenced by writeSelectionToStream().

◆ 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.

scroll up ‘n’ lines within current region. The ‘n’ new lines are cleared.

See also
setRegion
scrollDown

Definition at line 867 of file Screen.cpp.

References _lastScrolledRegion.

Referenced by ScreenWindow::scrollRegion().

◆ moveImage()

void Screen::moveImage ( int  dest,
int  sourceBegin,
int  sourceEnd 
)
private

move image between (including) ‘sourceBegin’ and ‘sourceEnd’ to 'dest'.

The 'dest', 'sourceBegin' and 'sourceEnd' parameters can be generated using the loc(column,line) macro.

NOTE: moveImage() can only move whole lines.

This is an internal helper functions. The parameter types are internal
addresses of within the screen image and make use of the way how the
screen matrix is mapped to the image vector.

Definition at line 1025 of file Screen.cpp.

References clearSelection(), columns, HistoryScroll::getLines(), hist, lastPos, lineProperties, lines, loc, screenLines, sel_begin, sel_BR, and sel_TL.

Referenced by scrollDown(), and scrollUp().

◆ 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.

This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) depending on the NewLine Mode (LNM). This mode also affects the key sequence returned for newline ([CR]LF).

Definition at line 729 of file Screen.cpp.

References getMode(), index(), MODE_NewLine, and Return().

Referenced by Emulation::receiveChar(), and Vt102Emulation::tau().

◆ NextLine()

void Screen::NextLine ( )

Moves the cursor down one line and positions it at the beginning of the line.

Move the cursor to the begin of the next line.

If cursor is on bottom margin, the region between the actual top and bottom margin is scrolled up.

Definition at line 234 of file Screen.cpp.

References index(), and Return().

Referenced by ShowCharacter(), and Vt102Emulation::tau().

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

References bmargin, clear(), lines, MODE_Cursor, MODE_Insert, MODE_NewLine, MODE_Origin, MODE_Screen, MODE_Wrap, resetMode(), saveCursor(), saveMode(), setDefaultRendition(), setMode(), and tmargin.

Referenced by Screen(), and Vt102Emulation::reset().

◆ resetDroppedLines()

void Screen::resetDroppedLines ( )

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

Definition at line 842 of file Screen.cpp.

References _droppedLines.

Referenced by Emulation::showBulk().

◆ resetMode()

void Screen::resetMode ( int  m)

Resets (clears) the specified screen mode.

Reset a specific mode.

Definition at line 313 of file Screen.cpp.

References currParm, cuX, cuY, m, ScreenParm::mode, and MODE_Origin.

Referenced by reset(), and Vt102Emulation::resetMode().

◆ resetRendition()

void Screen::resetRendition ( int  rendition)

Disables the given rendition flag.

Rendition flags control the appearence of characters on the screen.

See also
Character::rendition

Definition at line 1154 of file Screen.cpp.

References cu_re, and effectiveRendition().

Referenced by Vt102Emulation::tau().

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

References _scrolledLines.

Referenced by Emulation::showBulk().

◆ 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.

(note that in versions of Konsole prior to KDE 4, existing lines were truncated when making the screen image smaller)

Resize the screen image

The topmost left position is maintained, while lower lines or right hand side columns might be removed or filled with spaces to fit the new size.

The region setting is reset to the whole screen and the tab positions reinitialized.

If the new image is narrower than the old image then text on lines which extends past the end of the new image is preserved so that it becomes visible again if the screen is later resized to make it larger.

Definition at line 380 of file Screen.cpp.

References addHistLine(), bmargin, clearSelection(), columns, cuX, cuY, initTabStops(), LINE_DEFAULT, lineProperties, lines, screenLines, scrollUp(), and tmargin.

Referenced by Emulation::setImageSize().

◆ restoreCursor()

void Screen::restoreCursor ( )

Restores the position and appearence of the cursor.

See saveCursor()

Definition at line 350 of file Screen.cpp.

References columns, cu_bg, cu_fg, cu_re, cuX, cuY, effectiveRendition(), lines, sa_cu_bg, sa_cu_fg, sa_cu_re, sa_cuX, and sa_cuY.

Referenced by Vt102Emulation::restoreCursor().

◆ restoreMode()

void Screen::restoreMode ( int  m)

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

Restore a specific mode.

Definition at line 331 of file Screen.cpp.

References currParm, m, ScreenParm::mode, and saveParm.

Referenced by Vt102Emulation::tau().

◆ Return()

void Screen::Return ( )

Moves the cursor to the beginning of the current line.

Equivalent to setCursorX(0)

Definition at line 935 of file Screen.cpp.

References cuX.

Referenced by NewLine(), NextLine(), Emulation::receiveChar(), and Vt102Emulation::tau().

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

References cuY, scrollDown(), and tmargin.

Referenced by Vt102Emulation::tau().

◆ reverseRendition()

void Screen::reverseRendition ( Character p) const
private

Definition at line 463 of file Screen.cpp.

References Character::backgroundColor, f, and Character::foregroundColor.

Referenced by copyFromHistory(), copyFromScreen(), and getImage().

◆ saveCursor()

void Screen::saveCursor ( )

Saves the current position and appearence (text color and style) of the cursor.

It can be restored by calling restoreCursor()

Definition at line 341 of file Screen.cpp.

References cu_bg, cu_fg, cu_re, cuX, cuY, sa_cu_bg, sa_cu_fg, sa_cu_re, sa_cuX, and sa_cuY.

Referenced by reset(), and Vt102Emulation::saveCursor().

◆ saveMode()

void Screen::saveMode ( int  m)

Saves the state of the specified screen mode.

It can be restored using restoreMode()

Save a specific mode.

Definition at line 324 of file Screen.cpp.

References currParm, m, ScreenParm::mode, and saveParm.

Referenced by reset().

◆ scrollDown() [1/2]

void Screen::scrollDown ( int  from,
int  n 
)
private

scroll down ‘n’ lines within current region. The ‘n’ new lines are cleared.

See also
setRegion
scrollUp

Definition at line 895 of file Screen.cpp.

References _scrolledLines, bmargin, clearImage(), columns, loc, moveImage(), and n.

◆ scrollDown() [2/2]

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

References n, and tmargin.

Referenced by insertLines(), reverseIndex(), and Vt102Emulation::tau().

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

References _scrolledLines.

Referenced by ScreenWindow::notifyOutputChanged().

◆ scrollUp() [1/2]

void Screen::scrollUp ( int  from,
int  i 
)
private

Definition at line 872 of file Screen.cpp.

References _lastScrolledRegion, _scrolledLines, bmargin, clearImage(), columns, loc, moveImage(), n, and tmargin.

◆ scrollUp() [2/2]

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

References addHistLine(), n, and tmargin.

Referenced by clearEntireScreen(), deleteLines(), index(), resizeImage(), and Vt102Emulation::tau().

◆ selectedText()

QString Screen::selectedText ( bool  preserveLineBreaks)

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

References PlainTextDecoder::begin(), PlainTextDecoder::end(), and writeSelectionToStream().

Referenced by getHistoryLine(), and ScreenWindow::selectedText().

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

References COLOR_SPACE_DEFAULT, cu_bg, DEFAULT_BACK_COLOR, effectiveRendition(), and CharacterColor::isValid().

Referenced by setDefaultRendition(), and Vt102Emulation::tau().

◆ setBusySelecting()

void Screen::setBusySelecting ( bool  busy)
inline

Definition at line 428 of file Screen.h.

References sel_busy.

Referenced by Emulation::setScreen().

◆ setCursorX()

void Screen::setCursorX ( int  x)

Position the cursor at column x.

Definition at line 915 of file Screen.cpp.

References columns, cuX, and x.

Referenced by setCursorYX(), and Vt102Emulation::tau().

◆ setCursorY()

void Screen::setCursorY ( int  y)

Position the cursor on line y.

Definition at line 922 of file Screen.cpp.

References cuY, getMode(), lines, MODE_Origin, and tmargin.

Referenced by setCursorYX(), and Vt102Emulation::tau().

◆ setCursorYX()

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

Position the cursor at line y, column x.

Definition at line 910 of file Screen.cpp.

References setCursorX(), setCursorY(), and x.

Referenced by Vt102Emulation::clearScreenAndSetColumns(), and Vt102Emulation::tau().

◆ setDefaultMargins()

void Screen::setDefaultMargins ( )

Resets the scrolling margins back to the top and bottom lines of the screen.

Definition at line 422 of file Screen.cpp.

References bmargin, lines, and tmargin.

Referenced by Vt102Emulation::setDefaultMargins().

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

References COLOR_SPACE_DEFAULT, cu_re, DEFAULT_BACK_COLOR, DEFAULT_FORE_COLOR, DEFAULT_RENDITION, effectiveRendition(), setBackColor(), and setForeColor().

Referenced by reset(), and Vt102Emulation::tau().

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

References COLOR_SPACE_DEFAULT, cu_fg, DEFAULT_FORE_COLOR, effectiveRendition(), and CharacterColor::isValid().

Referenced by setDefaultRendition(), and Vt102Emulation::tau().

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

References cuY, and lineProperties.

Referenced by Vt102Emulation::tau().

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

References bmargin, cuX, cuY, getMode(), lines, MODE_Origin, and tmargin.

Referenced by Vt102Emulation::setMargins().

◆ setMode()

void Screen::setMode ( int  m)

Sets (enables) the specified screen mode.

Set a specific mode.

Definition at line 302 of file Screen.cpp.

References currParm, cuX, cuY, m, ScreenParm::mode, MODE_Origin, and tmargin.

Referenced by reset(), and Vt102Emulation::setMode().

◆ setRendition()

void Screen::setRendition ( int  rendition)

Enables the given rendition flag.

Rendition flags control the appearence of characters on the screen.

See also
Character::rendition

Definition at line 1148 of file Screen.cpp.

References cu_re, and effectiveRendition().

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

References clearSelection(), hist, and HistoryType::scroll().

Referenced by Emulation::clearHistory(), and Emulation::setHistory().

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

References columns, loc, sel_begin, sel_BR, sel_TL, and x.

Referenced by ScreenWindow::setSelectionEnd().

◆ setSelectionStart()

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

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.
columnmodeTrue if the selection is in column mode.

Definition at line 1227 of file Screen.cpp.

References columnmode, columns, loc, sel_begin, sel_BR, sel_TL, and x.

Referenced by ScreenWindow::setSelectionStart().

◆ ShowCharacter()

void Screen::ShowCharacter ( 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 752 of file Screen.cpp.

References Character::backgroundColor, Character::character, clearSelection(), columns, cuX, cuY, ef_bg, ef_fg, ef_re, Character::foregroundColor, getMode(), insertChars(), konsole_wcwidth(), lastPos, LINE_WRAPPED, lineProperties, loc, MODE_Insert, MODE_Wrap, NextLine(), Character::rendition, screenLines, and Faddeeva::w().

Referenced by Emulation::receiveChar(), and Vt102Emulation::tau().

◆ Tabulate()

void Screen::Tabulate ( int  n = 1)

Moves the cursor n tab-stops to the right.

Definition at line 679 of file Screen.cpp.

References columns, cursorRight(), cuX, n, and tabstops.

Referenced by Emulation::receiveChar(), and Vt102Emulation::tau().

◆ topMargin()

int Screen::topMargin ( ) const

Returns the top line of the scrolling region.

Definition at line 198 of file Screen.cpp.

References tmargin.

◆ writeSelectionToStream()

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

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

References columnmode, columns, copyLineToStream(), isSelectionValid(), left, sel_BR, and sel_TL.

Referenced by selectedText(), and writeToStream().

◆ writeToStream()

void Screen::writeToStream ( TerminalCharacterDecoder decoder,
int  from,
int  to 
)

Copies part of the output to a stream.

Parameters
decoderA decoder which coverts terminal characters into text
fromThe first line in the history to retrieve
toThe last line in the history to retrieve

Definition at line 1444 of file Screen.cpp.

References clearSelection(), columns, loc, sel_begin, sel_BR, sel_TL, and writeSelectionToStream().

Referenced by Emulation::writeToStream().

Member Data Documentation

◆ _droppedLines

int Screen::_droppedLines
private

Definition at line 594 of file Screen.h.

Referenced by addHistLine(), droppedLines(), and resetDroppedLines().

◆ _lastScrolledRegion

QRect Screen::_lastScrolledRegion
private

Definition at line 592 of file Screen.h.

Referenced by lastScrolledRegion(), and scrollUp().

◆ _scrolledLines

int Screen::_scrolledLines
private

Definition at line 591 of file Screen.h.

Referenced by resetScrolledLines(), scrollDown(), scrolledLines(), and scrollUp().

◆ bmargin

int Screen::bmargin
private

◆ columnmode

bool Screen::columnmode
private

Definition at line 626 of file Screen.h.

Referenced by isSelected(), setSelectionStart(), and writeSelectionToStream().

◆ columns

◆ cu_bg

CharacterColor Screen::cu_bg
private

Definition at line 607 of file Screen.h.

Referenced by clearImage(), effectiveRendition(), restoreCursor(), saveCursor(), and setBackColor().

◆ cu_fg

CharacterColor Screen::cu_fg
private

Definition at line 606 of file Screen.h.

Referenced by clearImage(), effectiveRendition(), restoreCursor(), saveCursor(), and setForeColor().

◆ cu_re

quint8 Screen::cu_re
private

◆ currParm

ScreenParm Screen::currParm
private

Definition at line 615 of file Screen.h.

Referenced by getMode(), resetMode(), restoreMode(), saveMode(), and setMode().

◆ cuX

◆ cuY

◆ defaultChar

Character Screen::defaultChar
staticprivate
Initial value:
= Character(' ',
#define COLOR_SPACE_DEFAULT
#define DEFAULT_FORE_COLOR
#define DEFAULT_BACK_COLOR
#define DEFAULT_RENDITION
Definition: Character.h:41
Describes the color of a single character in the terminal.
A single character in the terminal which consists of a unicode character value, foreground and backgr...
Definition: Character.h:56

Definition at line 652 of file Screen.h.

Referenced by copyFromHistory(), copyFromScreen(), and fillWithDefaultChar().

◆ ef_bg

CharacterColor Screen::ef_bg
private

Definition at line 630 of file Screen.h.

Referenced by effectiveRendition(), and ShowCharacter().

◆ ef_fg

CharacterColor Screen::ef_fg
private

Definition at line 629 of file Screen.h.

Referenced by effectiveRendition(), and ShowCharacter().

◆ ef_re

quint8 Screen::ef_re
private

Definition at line 631 of file Screen.h.

Referenced by effectiveRendition(), and ShowCharacter().

◆ hist

◆ lastPos

int Screen::lastPos
private

Definition at line 647 of file Screen.h.

Referenced by moveImage(), and ShowCharacter().

◆ lineProperties

QVarLengthArray<LineProperty,64> Screen::lineProperties
private

◆ lines

◆ sa_cu_bg

CharacterColor Screen::sa_cu_bg
private

Definition at line 644 of file Screen.h.

Referenced by restoreCursor(), and saveCursor().

◆ sa_cu_fg

CharacterColor Screen::sa_cu_fg
private

Definition at line 643 of file Screen.h.

Referenced by restoreCursor(), and saveCursor().

◆ sa_cu_re

quint8 Screen::sa_cu_re
private

Definition at line 642 of file Screen.h.

Referenced by restoreCursor(), and saveCursor().

◆ sa_cuX

int Screen::sa_cuX
private

Definition at line 638 of file Screen.h.

Referenced by restoreCursor(), and saveCursor().

◆ sa_cuY

int Screen::sa_cuY
private

Definition at line 639 of file Screen.h.

Referenced by restoreCursor(), and saveCursor().

◆ saveParm

ScreenParm Screen::saveParm
private

Definition at line 650 of file Screen.h.

Referenced by restoreMode(), and saveMode().

◆ screenLines

◆ sel_begin

◆ sel_BR

◆ sel_busy

bool Screen::sel_busy
private

Definition at line 625 of file Screen.h.

Referenced by setBusySelecting().

◆ sel_TL

◆ tabstops

bool* Screen::tabstops
private

Definition at line 619 of file Screen.h.

Referenced by ~Screen(), backTabulate(), changeTabStop(), clearTabStops(), initTabStops(), and Tabulate().

◆ tmargin

int Screen::tmargin
private

The documentation for this class was generated from the following files: