GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
|
Provides a window onto a section of a terminal screen. More...
#include "ScreenWindow.h"
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. | |
Character * | getImage () |
Returns the image of characters which are currently visible through this window onto the screen. | |
QVector< LineProperty > | getLineProperties () |
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() | |
Screen * | screen () 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 |
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.
Definition at line 172 of file ScreenWindow.h.
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.
|
virtual |
Definition at line 43 of file ScreenWindow.cpp.
References _windowBuffer.
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().
|
private |
Definition at line 104 of file ScreenWindow.cpp.
References currentLine(), lineCount(), and windowLines().
Referenced by getImage(), getLineProperties(), isSelected(), setSelectionEnd(), and setSelectionStart().
|
private |
Definition at line 86 of file ScreenWindow.cpp.
References _screen, _windowBuffer, _windowBufferSize, currentLine(), Screen::fillWithDefaultChar(), Screen::getHistLines(), Screen::getLines(), windowColumns(), and windowLines().
Referenced by 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(), 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().
Retrieves the end of the selection within the window.
Definition at line 129 of file ScreenWindow.cpp.
References _screen, currentLine(), and Screen::getSelectionEnd().
Retrieves the start of the selection within the window.
Definition at line 124 of file ScreenWindow.cpp.
References _screen, currentLine(), and Screen::getSelectionStart().
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().
|
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().
|
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.
mode | Specifies whether amount refers to the number of lines or the number of pages to scroll. |
amount | The 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.
Emitted when the screen window is scrolled to a different position.
line | The 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().
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.
preserveLineBreaks | See Screen::selectedText() |
Definition at line 119 of file ScreenWindow.cpp.
References _screen, and Screen::selectedText().
|
signal |
Emitted when the selection is changed.
Referenced by clearSelection(), setSelectionEnd(), and setSelectionStart().
Sets the screen which this window looks onto.
Definition at line 47 of file ScreenWindow.cpp.
References _screen, and screen().
Referenced by Emulation::createWindow().
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().
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().
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().
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().
|
private |
Definition at line 243 of file ScreenWindow.h.
Referenced by getImage(), notifyOutputChanged(), scrollTo(), setSelectionEnd(), and setSelectionStart().
|
private |
Definition at line 246 of file ScreenWindow.h.
Referenced by currentLine(), notifyOutputChanged(), and scrollTo().
|
private |
Definition at line 240 of file ScreenWindow.h.
Referenced by clearSelection(), columnCount(), cursorPosition(), fillUnusedArea(), getImage(), getLineProperties(), getSelectionEnd(), getSelectionStart(), isSelected(), lineCount(), notifyOutputChanged(), screen(), scrollRegion(), selectedText(), setScreen(), setSelectionEnd(), setSelectionStart(), and windowColumns().
|
private |
Definition at line 248 of file ScreenWindow.h.
Referenced by notifyOutputChanged(), resetScrollCount(), scrollCount(), and scrollTo().
|
private |
Definition at line 247 of file ScreenWindow.h.
Referenced by notifyOutputChanged(), setTrackOutput(), and trackOutput().
|
private |
Definition at line 241 of file ScreenWindow.h.
Referenced by fillUnusedArea(), getImage(), and ~ScreenWindow().
|
private |
Definition at line 242 of file ScreenWindow.h.
Referenced by fillUnusedArea(), and getImage().
|
private |
Definition at line 245 of file ScreenWindow.h.
Referenced by setWindowLines(), and windowLines().