35 #include <QtCore/QTextStream> 36 #include <QtCore/QDate> 44 #define BS_CLEARS false 56 #define loc(X,Y) ((Y)*columns+(X)) 76 tmargin(0), bmargin(0),
78 sel_begin(0), sel_TL(0), sel_BR(0),
183 if (top == 0) top = 1;
184 if (bot == 0) bot =
lines;
187 if ( !( 0 <= top && top < bot && bot <
lines ) )
188 { qDebug()<<
" setRegion("<<top<<
","<<bot<<
") : bad range.";
382 if ((new_lines==
lines) && (new_columns==
columns))
return;
384 if (
cuY > new_lines-1)
387 for (
int i = 0;
i <
cuY-(new_lines-1);
i++)
396 for (
int i=0;
i < qMin(
lines-1,new_lines+1) ;
i++)
398 for (
int i=
lines;(
i > 0) && (
i<new_lines+1);
i++)
399 newScreenLines[
i].resize( new_columns );
402 for (
int i=
lines;(
i > 0) && (
i<new_lines+1);
i++)
468 p.foregroundColor =
b;
469 p.backgroundColor =
f;
514 Q_ASSERT( startLine >= 0 && count > 0 && startLine + count <= hist->
getLines() );
516 for (
int line = startLine;
line < startLine + count;
line++)
519 const int destLineOffset = (
line-startLine)*
columns;
542 Q_ASSERT( startLine >= 0 && count > 0 && startLine + count <=
lines );
544 for (
int line = startLine;
line < (startLine+count) ;
line++)
551 int srcIndex = srcLineStartIndex +
column;
552 int destIndex = destLineStartIndex +
column;
566 Q_ASSERT( startLine >= 0 );
567 Q_ASSERT( endLine >= startLine && endLine < hist->
getLines() +
lines );
569 const int mergedLines = endLine - startLine + 1;
571 Q_ASSERT( size >= mergedLines *
columns );
574 const int linesInHistoryBuffer = qBound(0,
hist->
getLines()-startLine,mergedLines);
575 const int linesInScreenBuffer = mergedLines - linesInHistoryBuffer;
578 if (linesInHistoryBuffer > 0) {
583 if (linesInScreenBuffer > 0) {
586 linesInScreenBuffer);
597 int cursorIndex =
loc(
cuX,
cuY + linesInHistoryBuffer);
604 Q_ASSERT( startLine >= 0 );
605 Q_ASSERT( endLine >= startLine && endLine < hist->
getLines() +
lines );
607 const int mergedLines = endLine-startLine+1;
608 const int linesInHistory = qBound(0,
hist->
getLines()-startLine,mergedLines);
609 const int linesInScreen = mergedLines - linesInHistory;
611 QVector<LineProperty>
result(mergedLines);
615 for (
int line = startLine;
line < startLine + linesInHistory;
line++)
626 const int firstScreenLine = startLine + linesInHistory -
hist->
getLines();
627 for (
int line = firstScreenLine;
line < firstScreenLine+linesInScreen;
line++)
694 while((n > 0) && (
cuX > 0))
746 if ( (
sel_BR > (from+scr_TL) )&&(
sel_TL < (to+scr_TL)) )
775 if (size == 0 &&
cuY > 0)
802 int newCursorX =
cuX +
w--;
874 if (n <= 0 || from + n >
bmargin)
return;
974 if ( (
sel_BR > (loca+scr_TL) )&&(
sel_TL < (loce+scr_TL)) )
986 bool isDefaultCh = (clearCh ==
Character());
988 for (
int y=topLine;
y<=bottomLine;
y++)
993 int startCol = (
y == topLine ) ? loca%
columns : 0;
997 if ( isDefaultCh && endCol ==
columns-1 )
999 line.resize(startCol);
1003 if (
line.size() < endCol + 1)
1004 line.resize(endCol+1);
1007 for (
int i=startCol;
i<=endCol;
i++)
1031 Q_ASSERT( sourceBegin <= sourceEnd );
1040 if (dest < sourceBegin)
1059 int diff = dest - sourceBegin;
1069 int diff = dest - sourceBegin;
1071 int srca = sourceBegin+scr_TL;
1072 int srce = sourceEnd+scr_TL;
1073 int desta = srca+diff;
1074 int deste = srce+diff;
1116 for (
int i = 0;
i < (
lines-1);
i++)
1264 int sel_Left,sel_Right;
1284 QTextStream stream(&
result, QIODevice::ReadWrite);
1287 decoder.
begin(&stream);
1300 bool preserveLineBreaks)
1312 Q_ASSERT( top >= 0 &&
left >= 0 && bottom >= 0 &&
right >= 0 );
1317 for (
int y=top;
y<=bottom;
y++)
1325 const bool appendNewLine = (
y != bottom );
1331 preserveLineBreaks );
1341 bool preserveLineBreaks)
1347 static const int MAX_CHARS = 1024;
1348 static Character characterBuffer[MAX_CHARS];
1350 assert( count < MAX_CHARS );
1365 count = lineLength-
start;
1373 assert(
start >= 0 );
1374 assert( count >= 0 );
1387 assert( count >= 0 );
1397 characterBuffer[
i-
start] = data[
i];
1408 for (
int i=count-1 ;
i >= 0;
i--)
1409 if (QChar(characterBuffer[
i].
character).isSpace())
1415 const bool omitLineBreak = (currentLineProperties &
LINE_WRAPPED) ||
1416 !preserveLineBreaks;
1418 if ( !omitLineBreak && appendNewLine && (count+1 < MAX_CHARS) )
1420 characterBuffer[count] =
'\n';
1426 count, currentLineProperties );
1479 if ( newHistLines == oldHistLines )
1483 if (newHistLines > oldHistLines)
1495 int top_BR =
loc(0, 1+newHistLines);
1531 if ( copyPreviousScroll )
1536 hist =
t.scroll(
nullptr);
1564 for (
int i=0;
i<count;
i++)
void changeTabStop(bool set)
Sets or removes a tab stop at the cursor's current column.
void clearToEndOfLine()
Clears from the current cursor position to the end of the line.
void setForeColor(int space, int color)
Sets the cursor's foreground color.
void setCursorY(int y)
Position the cursor on line y.
void clearSelection()
Clears the current selection.
bool isValid()
Returns true if this character color entry is valid.
void setBackColor(int space, int color)
Sets the cursor's background color.
virtual void decodeLine(const Character *const characters, int count, LineProperty properties)=0
Converts a line of terminal characters with associated properties into a text string and writes the s...
void resetScrolledLines()
Resets the count of the number of lines that the image has been scrolled up or down by...
virtual void getCells(int lineno, int colno, int count, Character res[])=0
void setScroll(const HistoryType &, bool copyPreviousScroll=true)
Sets the type of storage used to keep lines in the history.
OCTAVE_EXPORT octave_value_list column
void reset(bool clearScreen=true)
Resets the state of the screen.
QRect _lastScrolledRegion
void setDefaultMargins()
Resets the scrolling margins back to the top and bottom lines of the screen.
static Character defaultChar
void compose(const QString &compose)
QRect lastScrolledRegion() const
Returns the region of the image which was last scrolled.
void getImage(Character *dest, int size, int startLine, int endLine) const
Returns the current screen image.
int bottomMargin() const
Returns the bottom line of the scrolling region.
#define DEFAULT_FORE_COLOR
#define DEFAULT_RENDITION
void Tabulate(int n=1)
Moves the cursor n tab-stops to the right.
A single character in the terminal which consists of a unicode character value, foreground and backgr...
void setCursorYX(int y, int x)
Position the cursor at line y, column x.
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
void eraseChars(int n)
Erase n characters beginning from the current cursor position.
int getLines()
Return the number of lines.
void checkSelection(int from, int to)
TODO Document me.
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
void cursorRight(int n)
Move the cursor to the right by n columns.
QVarLengthArray< LineProperty, 64 > lineProperties
void helpAlign()
Fills the entire screen with the letter 'E'.
#define COLOR_SPACE_DEFAULT
void clear()
TODO Document me.
Describes the color of a single character in the terminal.
void saveMode(int mode)
Saves the state of the specified screen mode.
void clearToEndOfScreen()
Clear the area of the screen from the current cursor position to the end of the screen.
void resetMode(int mode)
Resets (clears) the specified screen mode.
void backTabulate(int n)
Moves the cursor n tab-stops to the left.
virtual bool isWrappedLine(int lineno)=0
void BackSpace()
Moves the cursor one column to the left and erases the character at the new cursor position...
quint8 rendition
A combination of RENDITION flags which specify options for drawing the character. ...
int konsole_wcwidth(quint16 ucs)
void Return()
Moves the cursor to the beginning of the current line.
void clearImage(int loca, int loce, char c)
void setRendition(int rendition)
Enables the given rendition flag.
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
void setMargins(int topLine, int bottomLine)
Sets the margins for scrolling the screen.
void NewLine()
Moves the cursor down one line, if the MODE_NewLine mode flag is enabled then the cursor is returned ...
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
in this the arguments are accumulated from left to right
void reverseRendition(Character &p) const
void resizeImage(int new_lines, int new_columns)
Resizes the image to a new fixed size of new_lines by new_columns.
void clearEntireScreen()
Clear the whole screen, moving the current screen contents into the history first.
bool isSelectionValid() const
unsigned char LineProperty
void getSelectionStart(int &column, int &line)
Retrieves the start of the selection or the cursor position if there is no selection.
void clearToBeginOfScreen()
Clear the area of the screen from the current cursor position to the start of the screen...
int getCursorY() const
Returns the line which the cursor is positioned on.
void moveImage(int dest, int sourceBegin, int sourceEnd)
Screen(int lines, int columns)
Construct a new screen image of size lines by columns.
static const int LINE_WRAPPED
A terminal character decoder which produces plain text, ignoring colours and other appearance-related...
void effectiveRendition()
void setDefaultRendition()
Resets the cursor's color back to the default and sets the character's rendition flags back to the de...
void clearToBeginOfLine()
Clears from the current cursor position to the beginning of the line.
void copyLineToStream(int line, int start, int count, TerminalCharacterDecoder *decoder, bool appendNewLine, bool preserveLineBreaks)
void setSelectionStart(const int column, const int line, const bool columnmode)
Sets the start of the selection.
void deleteLines(int n)
Removes n lines beginning from the current cursor position.
void writeSelectionToStream(TerminalCharacterDecoder *decoder, bool preserveLineBreaks=true)
Copies the selected characters, set using.
bool hasScroll()
Returns true if this screen keeps lines that are scrolled off the screen in a history buffer...
const HistoryType & getType()
void reverseIndex()
Move the cursor up one line.
void home()
Sets the position of the cursor to the 'home' position at the top-left corner of the screen (0...
void writeToStream(TerminalCharacterDecoder *decoder, int from, int to)
Copies part of the output to a stream.
std::complex< double > w(std::complex< double > z, double relerr=0)
bool getMode(int mode) const
Returns whether the specified screen mode is enabled or not .
void insertChars(int n)
Insert n blank characters beginning from the current cursor position.
CharacterColor backgroundColor
The color used to draw this character's background.
void copyFromScreen(Character *dest, int startLine, int count) const
QVector< LineProperty > getLineProperties(int startLine, int endLine) const
Returns the additional attributes associated with lines in the image.
void copyFromHistory(Character *dest, int startLine, int count) const
QString getHistoryLine(int no)
Sets the selection to line no in the history and returns the text of that line from the history buffe...
void resetDroppedLines()
Resets the count of the number of lines dropped from the history.
void index()
Move the cursor down one line.
CharacterColor foregroundColor
The foreground color used to draw this character.
With real return the complex result
Base class for terminal character decoders.
void getSelectionEnd(int &column, int &line)
Retrieves the end of the selection or the cursor position if there is no selection.
void setLineProperty(LineProperty property, bool enable)
Sets or clears an attribute of the current line.
void resetRendition(int rendition)
Disables the given rendition flag.
void clearEntireLine()
Clears the whole of the line on which the cursor is currently positioned.
void NextLine()
Moves the cursor down one line and positions it at the beginning of the line.
virtual void addCellsVector(const QVector< Character > &cells)
void toggleIntensive()
Toggles the value of this color between a normal system color and the corresponding intensive system ...
const HistoryType & getScroll()
Returns the type of storage used to keep lines in the history.
void insertLines(int n)
Inserts lines beginning from the current cursor position.
void deleteChars(int n)
Delete n characters beginning from the current cursor position.
static void fillWithDefaultChar(Character *dest, int count)
Fills the buffer dest with count instances of the default (ie.
void setMode(int mode)
Sets (enables) the specified screen mode.
void clearTabStops()
Clears all the tab stops.
void restoreCursor()
Restores the position and appearence of the cursor.
virtual int getLineLen(int lineno)=0
void restoreMode(int mode)
Restores the state of a screen mode saved by calling saveMode()
void scrollUp(int n)
Scroll the scrolling region of the screen up by n lines.
quint16 character
The unicode character value for this character.
the element is set to zero In other the statement xample y
virtual void addLine(bool previousWrapped=false)=0
static const int LINE_DEFAULT
void saveCursor()
Saves the current position and appearence (text color and style) of the cursor.
void cursorUp(int n)
Move the cursor up by n lines.
bool isSelected(const int column, const int line) const
Returns true if the character at (column, line) is part of the current selection. ...
void setSelectionEnd(const int column, const int line)
Sets the end of the current selection.
void cursorDown(int n)
Move the cursor down by n lines.
void ShowCharacter(unsigned short c)
Displays a new character at the current cursor position.
virtual void end()
End decoding.
void cursorLeft(int n)
Move the cursor to the left by n columns.
void scrollDown(int n)
Scroll the scrolling region of the screen down by n lines.
QVector< Character > ImageLine
int getHistLines()
Return the number of lines in the history buffer.
int getCursorX() const
Returns the column which the cursor is positioned at.
int droppedLines() const
Returns the number of lines of output which have been dropped from the history since the last call to...
void setCursorX(int x)
Position the cursor at column x.
int scrolledLines() const
Returns the number of lines that the image has been scrolled up or down by, since the last call to re...
QString selectedText(bool preserveLineBreaks)
Convenience method.
int topMargin() const
Returns the top line of the scrolling region.
virtual void begin(QTextStream *output)
Begin decoding characters.
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
nd example oindent assigns the value of the alert character(control-g, ASCII code 7) to the string variable ode
#define DEFAULT_BACK_COLOR