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

Provides a window onto a section of a terminal screen. More...

#include "ScreenWindow.h"

Inheritance diagram for ScreenWindow:
Collaboration diagram for ScreenWindow:

Public Types

enum  RelativeScrollMode { ScrollLines , ScrollPages }
 

Public Slots

void notifyOutputChanged ()
 Notifies the window that the contents of the associated terminal screen have changed. More...
 

Signals

void outputChanged ()
 Emitted when the contents of the associated terminal screen ( see screen() ) changes. More...
 
void scrolled (int line)
 Emitted when the screen window is scrolled to a different position. More...
 
void selectionChanged ()
 Emitted when the selection is changed. More...
 

Public Member Functions

 ScreenWindow (QObject *parent=nullptr)
 Constructs a new screen window with the given parent. More...
 
virtual ~ScreenWindow ()
 
bool atEndOfOutput () const
 Convenience method. More...
 
void clearSelection ()
 Clears the current selection. More...
 
int columnCount () const
 Returns the total number of columns in the screen. More...
 
int currentLine () const
 Returns the index of the line which is currently at the top of this window. More...
 
QPoint cursorPosition () const
 Returns the position of the cursor within the window. More...
 
CharactergetImage ()
 Returns the image of characters which are currently visible through this window onto the screen. More...
 
QVector< LinePropertygetLineProperties ()
 Returns the line attributes associated with the lines of characters which are currently visible through this window. More...
 
void getSelectionEnd (int &column, int &line)
 Retrieves the end of the selection within the window. More...
 
void getSelectionStart (int &column, int &line)
 Retrieves the start of the selection within the window. More...
 
bool isSelected (int column, int line)
 Returns true if the character at line , column is part of the selection. More...
 
int lineCount () const
 Returns the total number of lines in the screen. More...
 
void resetScrollCount ()
 Resets the count of scrolled lines returned by scrollCount() More...
 
Screenscreen () const
 Returns the screen which this window looks onto. More...
 
void scrollBy (RelativeScrollMode mode, int amount)
 Scrolls the window relative to its current position on the screen. More...
 
int scrollCount () const
 Returns the number of lines which the region of the window specified by scrollRegion() has been scrolled by since the last call to resetScrollCount(). More...
 
QRect scrollRegion () const
 Returns the area of the window which was last scrolled, this is usually the whole window area. More...
 
void scrollTo (int line)
 Scrolls the window so that line is at the top of the window. More...
 
QString selectedText (bool preserveLineBreaks) const
 Returns the text which is currently selected. More...
 
void setScreen (Screen *screen)
 Sets the screen which this window looks onto. More...
 
void setSelectionEnd (int column, int line)
 Sets the end of the selection to the given line and column within the window. More...
 
void setSelectionStart (int column, int line, bool columnMode)
 Sets the start of the selection to the given line and column within the window. More...
 
void setTrackOutput (bool trackOutput)
 Specifies whether the window should automatically move to the bottom of the screen when new output is added. More...
 
void setWindowLines (int lines)
 Sets the number of lines in the window. More...
 
bool trackOutput () const
 Returns whether the window automatically moves to the bottom of the screen as new output is added. More...
 
int windowColumns () const
 Returns the number of columns in the window. More...
 
int windowLines () const
 Returns the number of lines in the window. More...
 

Private Member Functions

int endWindowLine () const
 
void fillUnusedArea ()
 

Private Attributes

bool _bufferNeedsUpdate
 
int _currentLine
 
Screen_screen
 
int _scrollCount
 
bool _trackOutput
 
Character_windowBuffer
 
int _windowBufferSize
 
int _windowLines
 

Detailed Description

Provides a window onto a section of a terminal screen.

This window can then be rendered by a terminal display widget ( TerminalDisplay ).

To use the screen window, create a new ScreenWindow() instance and associated it with a terminal screen using setScreen(). Use the scrollTo() method to scroll the window up and down on the screen. Call the getImage() method to retrieve the character image which is currently visible in the window.

setTrackOutput() controls whether the window moves to the bottom of the associated screen when new lines are added to it.

Whenever the output from the underlying screen is changed, the notifyOutputChanged() slot should be called. This in turn will update the window's position and emit the outputChanged() signal if necessary.

Definition at line 51 of file ScreenWindow.h.

Member Enumeration Documentation

◆ RelativeScrollMode

Enumerator
ScrollLines 
ScrollPages 

Definition at line 172 of file ScreenWindow.h.

Constructor & Destructor Documentation

◆ ScreenWindow()

ScreenWindow::ScreenWindow ( QObject parent = nullptr)

Constructs a new screen window with the given parent.

A screen must be specified by calling setScreen() before calling getImage() or getLineProperties().

You should not call this constructor directly, instead use the Emulation::createWindow() method to create a window on the emulation which you wish to view. This allows the emulation to notify the window when the associated screen has changed and synchronize selection updates between all views on a session.

Definition at line 31 of file ScreenWindow.cpp.

◆ ~ScreenWindow()

ScreenWindow::~ScreenWindow ( )
virtual

Definition at line 43 of file ScreenWindow.cpp.

References _windowBuffer.

Member Function Documentation

◆ atEndOfOutput()

bool ScreenWindow::atEndOfOutput ( ) const

Convenience method.

Returns true if the window is currently at the bottom of the screen.

Definition at line 214 of file ScreenWindow.cpp.

References currentLine(), lineCount(), and windowLines().

Referenced by scrollRegion().

◆ clearSelection()

void ScreenWindow::clearSelection ( )

Clears the current selection.

Definition at line 155 of file ScreenWindow.cpp.

References _screen, Screen::clearSelection(), and selectionChanged().

◆ columnCount()

int ScreenWindow::columnCount ( ) const

Returns the total number of columns in the screen.

Definition at line 182 of file ScreenWindow.cpp.

References _screen, and Screen::getColumns().

◆ currentLine()

int ScreenWindow::currentLine ( ) const

Returns the index of the line which is currently at the top of this window.

Definition at line 197 of file ScreenWindow.cpp.

References _currentLine, lineCount(), and windowLines().

Referenced by atEndOfOutput(), endWindowLine(), fillUnusedArea(), getImage(), getLineProperties(), getSelectionEnd(), getSelectionStart(), isSelected(), scrollBy(), setSelectionEnd(), and setSelectionStart().

◆ cursorPosition()

QPoint ScreenWindow::cursorPosition ( ) const

Returns the position of the cursor within the window.

Definition at line 187 of file ScreenWindow.cpp.

References _screen, Screen::getCursorX(), and Screen::getCursorY().

◆ endWindowLine()

int ScreenWindow::endWindowLine ( ) const
private

◆ fillUnusedArea()

void ScreenWindow::fillUnusedArea ( )
private

◆ getImage()

Character * ScreenWindow::getImage ( )

Returns the image of characters which are currently visible through this window onto the screen.

The buffer is managed by the ScreenWindow instance and does not need to be deleted by the caller.

Definition at line 59 of file ScreenWindow.cpp.

References _bufferNeedsUpdate, _screen, _windowBuffer, _windowBufferSize, currentLine(), endWindowLine(), fillUnusedArea(), Screen::getImage(), windowColumns(), and windowLines().

◆ getLineProperties()

QVector< LineProperty > ScreenWindow::getLineProperties ( )

Returns the line attributes associated with the lines of characters which are currently visible through this window.

Definition at line 109 of file ScreenWindow.cpp.

References _screen, currentLine(), endWindowLine(), Screen::getLineProperties(), and windowLines().

◆ getSelectionEnd()

void ScreenWindow::getSelectionEnd ( int &  column,
int &  line 
)

Retrieves the end of the selection within the window.

Definition at line 129 of file ScreenWindow.cpp.

References _screen, currentLine(), and Screen::getSelectionEnd().

◆ getSelectionStart()

void ScreenWindow::getSelectionStart ( int &  column,
int &  line 
)

Retrieves the start of the selection within the window.

Definition at line 124 of file ScreenWindow.cpp.

References _screen, currentLine(), and Screen::getSelectionStart().

◆ isSelected()

bool ScreenWindow::isSelected ( int  column,
int  line 
)

Returns true if the character at line , column is part of the selection.

Definition at line 150 of file ScreenWindow.cpp.

References _screen, currentLine(), endWindowLine(), and Screen::isSelected().

◆ lineCount()

int ScreenWindow::lineCount ( ) const

Returns the total number of lines in the screen.

Definition at line 177 of file ScreenWindow.cpp.

References _screen, Screen::getHistLines(), and Screen::getLines().

Referenced by atEndOfOutput(), currentLine(), endWindowLine(), and scrollTo().

◆ notifyOutputChanged

void ScreenWindow::notifyOutputChanged ( )
slot

Notifies the window that the contents of the associated terminal screen have changed.

This moves the window to the bottom of the screen if trackOutput() is true and causes the outputChanged() signal to be emitted.

Definition at line 266 of file ScreenWindow.cpp.

References _bufferNeedsUpdate, _currentLine, _screen, _scrollCount, _trackOutput, Screen::droppedLines(), Screen::getHistLines(), Screen::getLines(), outputChanged(), Screen::scrolledLines(), and windowLines().

◆ outputChanged

void ScreenWindow::outputChanged ( )
signal

Emitted when the contents of the associated terminal screen ( see screen() ) changes.

Referenced by notifyOutputChanged().

◆ resetScrollCount()

void ScreenWindow::resetScrollCount ( )

Resets the count of scrolled lines returned by scrollCount()

Definition at line 251 of file ScreenWindow.cpp.

References _scrollCount.

◆ screen()

Screen * ScreenWindow::screen ( ) const

Returns the screen which this window looks onto.

Definition at line 54 of file ScreenWindow.cpp.

References _screen.

Referenced by setScreen().

◆ scrollBy()

void ScreenWindow::scrollBy ( RelativeScrollMode  mode,
int  amount 
)

Scrolls the window relative to its current position on the screen.

Parameters
modeSpecifies whether amount refers to the number of lines or the number of pages to scroll.
amountThe number of lines or pages ( depending on mode ) to scroll by. If this number is positive, the view is scrolled down. If this number is negative, the view is scrolled up.

Definition at line 202 of file ScreenWindow.cpp.

References currentLine(), ScrollLines, ScrollPages, scrollTo(), and windowLines().

◆ scrollCount()

int ScreenWindow::scrollCount ( ) const

Returns the number of lines which the region of the window specified by scrollRegion() has been scrolled by since the last call to resetScrollCount().

scrollRegion() is in most cases the whole window, but will be a smaller area in, for example, applications which provide split-screen facilities.

This is not guaranteed to be accurate, but allows views to optimise rendering by reducing the amount of costly text rendering that needs to be done when the output is scrolled.

Definition at line 246 of file ScreenWindow.cpp.

References _scrollCount.

◆ scrolled

void ScreenWindow::scrolled ( int  line)
signal

Emitted when the screen window is scrolled to a different position.

Parameters
lineThe line which is now at the top of the window.

Referenced by scrollTo().

◆ scrollRegion()

QRect ScreenWindow::scrollRegion ( ) const

Returns the area of the window which was last scrolled, this is usually the whole window area.

Like scrollCount(), this is not guaranteed to be accurate, but allows views to optimise rendering.

Definition at line 256 of file ScreenWindow.cpp.

References _screen, atEndOfOutput(), Screen::getLines(), Screen::lastScrolledRegion(), windowColumns(), and windowLines().

◆ scrollTo()

void ScreenWindow::scrollTo ( int  line)

Scrolls the window so that line is at the top of the window.

Definition at line 219 of file ScreenWindow.cpp.

References _bufferNeedsUpdate, _currentLine, _scrollCount, lineCount(), scrolled(), and windowLines().

Referenced by scrollBy().

◆ selectedText()

QString ScreenWindow::selectedText ( bool  preserveLineBreaks) const

Returns the text which is currently selected.

Parameters
preserveLineBreaksSee Screen::selectedText()

Definition at line 119 of file ScreenWindow.cpp.

References _screen, and Screen::selectedText().

◆ selectionChanged

void ScreenWindow::selectionChanged ( )
signal

Emitted when the selection is changed.

Referenced by clearSelection(), setSelectionEnd(), and setSelectionStart().

◆ setScreen()

void ScreenWindow::setScreen ( Screen screen)

Sets the screen which this window looks onto.

Definition at line 47 of file ScreenWindow.cpp.

References _screen, and screen().

Referenced by Emulation::createWindow().

◆ setSelectionEnd()

void ScreenWindow::setSelectionEnd ( int  column,
int  line 
)

Sets the end of the selection to the given line and column within the window.

Definition at line 142 of file ScreenWindow.cpp.

References _bufferNeedsUpdate, _screen, currentLine(), endWindowLine(), selectionChanged(), and Screen::setSelectionEnd().

◆ setSelectionStart()

void ScreenWindow::setSelectionStart ( int  column,
int  line,
bool  columnMode 
)

Sets the start of the selection to the given line and column within the window.

Definition at line 134 of file ScreenWindow.cpp.

References _bufferNeedsUpdate, _screen, currentLine(), endWindowLine(), selectionChanged(), and Screen::setSelectionStart().

◆ setTrackOutput()

void ScreenWindow::setTrackOutput ( bool  trackOutput)

Specifies whether the window should automatically move to the bottom of the screen when new output is added.

If this is set to true, the window will be moved to the bottom of the associated screen ( see screen() ) when the notifyOutputChanged() method is called.

Definition at line 236 of file ScreenWindow.cpp.

References _trackOutput, and trackOutput().

◆ setWindowLines()

void ScreenWindow::setWindowLines ( int  lines)

Sets the number of lines in the window.

Definition at line 162 of file ScreenWindow.cpp.

References _windowLines.

Referenced by TerminalView::setScreenWindow().

◆ trackOutput()

bool ScreenWindow::trackOutput ( ) const

Returns whether the window automatically moves to the bottom of the screen as new output is added.

See setTrackOutput()

Definition at line 241 of file ScreenWindow.cpp.

References _trackOutput.

Referenced by setTrackOutput().

◆ windowColumns()

int ScreenWindow::windowColumns ( ) const

Returns the number of columns in the window.

Definition at line 172 of file ScreenWindow.cpp.

References _screen, and Screen::getColumns().

Referenced by fillUnusedArea(), getImage(), and scrollRegion().

◆ windowLines()

int ScreenWindow::windowLines ( ) const

Returns the number of lines in the window.

Definition at line 167 of file ScreenWindow.cpp.

References _windowLines.

Referenced by atEndOfOutput(), currentLine(), endWindowLine(), fillUnusedArea(), getImage(), getLineProperties(), notifyOutputChanged(), scrollBy(), scrollRegion(), and scrollTo().

Member Data Documentation

◆ _bufferNeedsUpdate

bool ScreenWindow::_bufferNeedsUpdate
private

◆ _currentLine

int ScreenWindow::_currentLine
private

Definition at line 246 of file ScreenWindow.h.

Referenced by currentLine(), notifyOutputChanged(), and scrollTo().

◆ _screen

◆ _scrollCount

int ScreenWindow::_scrollCount
private

Definition at line 248 of file ScreenWindow.h.

Referenced by notifyOutputChanged(), resetScrollCount(), scrollCount(), and scrollTo().

◆ _trackOutput

bool ScreenWindow::_trackOutput
private

Definition at line 247 of file ScreenWindow.h.

Referenced by notifyOutputChanged(), setTrackOutput(), and trackOutput().

◆ _windowBuffer

Character* ScreenWindow::_windowBuffer
private

Definition at line 241 of file ScreenWindow.h.

Referenced by ~ScreenWindow(), fillUnusedArea(), and getImage().

◆ _windowBufferSize

int ScreenWindow::_windowBufferSize
private

Definition at line 242 of file ScreenWindow.h.

Referenced by fillUnusedArea(), and getImage().

◆ _windowLines

int ScreenWindow::_windowLines
private

Definition at line 245 of file ScreenWindow.h.

Referenced by setWindowLines(), and windowLines().


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