Konsole
Screen.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SCREEN_H
00024 #define SCREEN_H
00025
00026
00027 #include <QtCore/QRect>
00028 #include <QtCore/QTextStream>
00029 #include <QtCore/QVarLengthArray>
00030
00031
00032 #include "Character.h"
00033 #include "History.h"
00034
00035 #define MODE_Origin 0
00036 #define MODE_Wrap 1
00037 #define MODE_Insert 2
00038 #define MODE_Screen 3
00039 #define MODE_Cursor 4
00040 #define MODE_NewLine 5
00041 #define MODES_SCREEN 6
00042
00043 namespace Konsole
00044 {
00045
00046 class TerminalCharacterDecoder;
00047
00071 class Screen
00072 {
00073 public:
00075 Screen(int lines, int columns);
00076 ~Screen();
00077
00078
00079
00080
00085 void cursorUp(int n);
00090 void cursorDown(int n);
00095 void cursorLeft(int n);
00100 void cursorRight(int n);
00102 void setCursorY(int y);
00104 void setCursorX(int x);
00106 void setCursorYX(int y, int x);
00113 void setMargins(int topLine , int bottomLine);
00115 int topMargin() const;
00117 int bottomMargin() const;
00118
00123 void setDefaultMargins();
00124
00133 void newLine();
00138 void nextLine();
00139
00145 void index();
00151 void reverseIndex();
00152
00158 void scrollUp(int n);
00164 void scrollDown(int n);
00169 void toStartOfLine();
00174 void backspace();
00176 void tab(int n = 1);
00178 void backtab(int n);
00179
00180
00181
00188 void eraseChars(int n);
00193 void deleteChars(int n);
00199 void insertChars(int n);
00205 void deleteLines(int n);
00211 void insertLines(int n);
00213 void clearTabStops();
00215 void changeTabStop(bool set);
00216
00218 void resetMode(int mode);
00220 void setMode(int mode);
00225 void saveMode(int mode);
00227 void restoreMode(int mode);
00229 bool getMode(int mode) const;
00230
00235 void saveCursor();
00237 void restoreCursor();
00238
00240 void clearEntireScreen();
00245 void clearToEndOfScreen();
00250 void clearToBeginOfScreen();
00252 void clearEntireLine();
00254 void clearToEndOfLine();
00256 void clearToBeginOfLine();
00257
00259 void helpAlign();
00260
00267 void setRendition(int rendition);
00274 void resetRendition(int rendition);
00275
00284 void setForeColor(int space, int color);
00293 void setBackColor(int space, int color);
00298 void setDefaultRendition();
00299
00301 int getCursorX() const;
00303 int getCursorY() const;
00304
00308 void clear();
00313 void home();
00331 void reset(bool clearScreen = true);
00332
00344 void displayCharacter(unsigned short c);
00345
00346
00347 void compose(const QString& compose);
00348
00359 void resizeImage(int new_lines, int new_columns);
00360
00371 void getImage( Character* dest , int size , int startLine , int endLine ) const;
00372
00379 QVector<LineProperty> getLineProperties( int startLine , int endLine ) const;
00380
00381
00383 int getLines() const
00384 { return lines; }
00386 int getColumns() const
00387 { return columns; }
00389 int getHistLines() const;
00395 void setScroll(const HistoryType& , bool copyPreviousScroll = true);
00397 const HistoryType& getScroll() const;
00402 bool hasScroll() const;
00403
00411 void setSelectionStart(const int column, const int line, const bool blockSelectionMode);
00412
00419 void setSelectionEnd(const int column, const int line);
00420
00425 void getSelectionStart(int& column , int& line) const;
00426
00431 void getSelectionEnd(int& column , int& line) const;
00432
00434 void clearSelection();
00435
00440 bool isSelected(const int column,const int line) const;
00441
00447 QString selectedText(bool preserveLineBreaks) const;
00448
00456 void writeLinesToStream(TerminalCharacterDecoder* decoder, int fromLine, int toLine) const;
00457
00468 void writeSelectionToStream(TerminalCharacterDecoder* decoder , bool
00469 preserveLineBreaks = true) const;
00470
00472 void checkSelection(int from, int to);
00473
00491 void setLineProperty(LineProperty property , bool enable);
00492
00500 int scrolledLines() const;
00501
00508 QRect lastScrolledRegion() const;
00509
00514 void resetScrolledLines();
00515
00525 int droppedLines() const;
00526
00531 void resetDroppedLines();
00532
00537 static void fillWithDefaultChar(Character* dest, int count);
00538
00539 private:
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552 int copyLineToStream(int line,
00553 int start,
00554 int count,
00555 TerminalCharacterDecoder* decoder,
00556 bool appendNewLine,
00557 bool preserveLineBreaks) const;
00558
00559
00560
00561
00562 void clearImage(int loca, int loce, char c);
00563
00564
00565
00566
00567
00568
00569 void moveImage(int dest, int sourceBegin, int sourceEnd);
00570
00571 void scrollUp(int from, int i);
00572
00573 void scrollDown(int from, int i);
00574
00575 void addHistLine();
00576
00577 void initTabStops();
00578
00579 void updateEffectiveRendition();
00580 void reverseRendition(Character& p) const;
00581
00582 bool isSelectionValid() const;
00583
00584
00585 void writeToStream(TerminalCharacterDecoder* decoder, int startIndex,
00586 int endIndex, bool preserveLineBreaks = true) const;
00587
00588
00589 void copyFromScreen(Character* dest, int startLine, int count) const;
00590
00591
00592 void copyFromHistory(Character* dest, int startLine, int count) const;
00593
00594
00595
00596 int lines;
00597 int columns;
00598
00599 typedef QVector<Character> ImageLine;
00600 ImageLine* screenLines;
00601
00602 int _scrolledLines;
00603 QRect _lastScrolledRegion;
00604
00605 int _droppedLines;
00606
00607 QVarLengthArray<LineProperty,64> lineProperties;
00608
00609
00610 HistoryScroll* history;
00611
00612
00613 int cuX;
00614 int cuY;
00615
00616
00617 CharacterColor currentForeground;
00618 CharacterColor currentBackground;
00619 quint8 currentRendition;
00620
00621
00622 int _topMargin;
00623 int _bottomMargin;
00624
00625
00626 int currentModes[MODES_SCREEN];
00627 int savedModes[MODES_SCREEN];
00628
00629
00630
00631 QBitArray tabStops;
00632
00633
00634 int selBegin;
00635 int selTopLeft;
00636 int selBottomRight;
00637 bool blockSelectionMode;
00638
00639
00640 CharacterColor effectiveForeground;
00641 CharacterColor effectiveBackground;
00642 quint8 effectiveRendition;
00643
00644 class SavedState
00645 {
00646 public:
00647 SavedState()
00648 : cursorColumn(0),cursorLine(0),rendition(0) {}
00649
00650 int cursorColumn;
00651 int cursorLine;
00652 quint8 rendition;
00653 CharacterColor foreground;
00654 CharacterColor background;
00655 };
00656 SavedState savedState;
00657
00658
00659 int lastPos;
00660
00661 static Character defaultChar;
00662 };
00663
00664 }
00665
00666 #endif // SCREEN_H