GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Types | Public Slots | Signals | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ScreenWindow Class Reference

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

#include "ScreenWindow.h"

Inheritance diagram for ScreenWindow:
Inheritance graph
[legend]
Collaboration diagram for ScreenWindow:
Collaboration graph
[legend]

Public Types

enum  RelativeScrollMode { ScrollLines, ScrollPages }

Public Slots

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

Signals

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

Public Member Functions

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

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

Enumerator:
ScrollLines 
ScrollPages 

Definition at line 172 of file ScreenWindow.h.

Constructor & Destructor Documentation

ScreenWindow::ScreenWindow ( QObject parent = 0)

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 ( )
virtual

Definition at line 43 of file ScreenWindow.cpp.

References _windowBuffer.

Member Function Documentation

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().

void ScreenWindow::clearSelection ( )

Clears the current selection.

Definition at line 155 of file ScreenWindow.cpp.

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

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().

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().

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().

int ScreenWindow::endWindowLine ( ) const
private
void ScreenWindow::fillUnusedArea ( )
private
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(), size(), windowColumns(), and windowLines().

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().

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().

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().

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().

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().

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().

void ScreenWindow::outputChanged ( )
signal

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

Referenced by notifyOutputChanged().

void ScreenWindow::resetScrollCount ( )

Resets the count of scrolled lines returned by scrollCount()

Definition at line 251 of file ScreenWindow.cpp.

References _scrollCount.

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().

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().

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.

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().

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().

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().

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().

void ScreenWindow::selectionChanged ( )
signal

Emitted when the selection is changed.

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

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().

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().

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().

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().

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().

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().

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().

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

bool ScreenWindow::_bufferNeedsUpdate
private
int ScreenWindow::_currentLine
private

Definition at line 246 of file ScreenWindow.h.

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

Screen* ScreenWindow::_screen
private
int ScreenWindow::_scrollCount
private

Definition at line 248 of file ScreenWindow.h.

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

bool ScreenWindow::_trackOutput
private

Definition at line 247 of file ScreenWindow.h.

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

Character* ScreenWindow::_windowBuffer
private

Definition at line 241 of file ScreenWindow.h.

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

int ScreenWindow::_windowBufferSize
private

Definition at line 242 of file ScreenWindow.h.

Referenced by fillUnusedArea(), and getImage().

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: