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
00048 struct ScreenParm
00049 {
00050 int mode[MODES_SCREEN];
00051 };
00052
00053 class TerminalCharacterDecoder;
00054
00078 class Screen
00079 {
00080 public:
00082 Screen(int lines, int columns);
00083 ~Screen();
00084
00085
00086
00087
00092 void cursorUp(int n);
00097 void cursorDown(int n);
00102 void cursorLeft(int n);
00107 void cursorRight(int n);
00109 void setCursorY(int y);
00111 void setCursorX(int x);
00113 void setCursorYX(int y, int x);
00120 void setMargins(int topLine , int bottomLine);
00122 int topMargin() const;
00124 int bottomMargin() const;
00125
00130 void setDefaultMargins();
00131
00140 void newLine();
00145 void nextLine();
00146
00152 void index();
00158 void reverseIndex();
00159
00165 void scrollUp(int n);
00171 void scrollDown(int n);
00176 void toStartOfLine();
00181 void backspace();
00183 void tab(int n = 1);
00185 void backtab(int n);
00186
00187
00188
00195 void eraseChars(int n);
00200 void deleteChars(int n);
00206 void insertChars(int n);
00212 void deleteLines(int n);
00218 void insertLines(int n);
00220 void clearTabStops();
00222 void changeTabStop(bool set);
00223
00225 void resetMode(int mode);
00227 void setMode(int mode);
00232 void saveMode(int mode);
00234 void restoreMode(int mode);
00236 bool getMode(int mode) const;
00237
00242 void saveCursor();
00244 void restoreCursor();
00245
00247 void clearEntireScreen();
00252 void clearToEndOfScreen();
00257 void clearToBeginOfScreen();
00259 void clearEntireLine();
00261 void clearToEndOfLine();
00263 void clearToBeginOfLine();
00264
00266 void helpAlign();
00267
00274 void setRendition(int rendition);
00281 void resetRendition(int rendition);
00282
00291 void setForeColor(int space, int color);
00300 void setBackColor(int space, int color);
00305 void setDefaultRendition();
00306
00308 int getCursorX() const;
00310 int getCursorY() const;
00311
00315 void clear();
00320 void home();
00338 void reset(bool clearScreen = true);
00339
00351 void displayCharacter(unsigned short c);
00352
00353
00354 void compose(const QString& compose);
00355
00366 void resizeImage(int new_lines, int new_columns);
00367
00378 void getImage( Character* dest , int size , int startLine , int endLine ) const;
00379
00386 QVector<LineProperty> getLineProperties( int startLine , int endLine ) const;
00387
00388
00390 int getLines() { return lines; }
00392 int getColumns() { return columns; }
00394 int getHistLines ();
00400 void setScroll(const HistoryType& , bool copyPreviousScroll = true);
00402 const HistoryType& getScroll();
00407 bool hasScroll();
00408
00416 void setSelectionStart(const int column, const int line, const bool columnmode);
00417
00424 void setSelectionEnd(const int column, const int line);
00425
00430 void getSelectionStart(int& column , int& line);
00431
00436 void getSelectionEnd(int& column , int& line);
00437
00439 void clearSelection();
00440
00441 void setBusySelecting(bool busy) { sel_busy = busy; }
00442
00447 bool isSelected(const int column,const int line) const;
00448
00454 QString selectedText(bool preserveLineBreaks);
00455
00463 void writeToStream(TerminalCharacterDecoder* decoder, int from, int to);
00464
00469 QString getHistoryLine(int no);
00470
00481 void writeSelectionToStream(TerminalCharacterDecoder* decoder , bool
00482 preserveLineBreaks = true);
00483
00485 void checkSelection(int from, int to);
00486
00504 void setLineProperty(LineProperty property , bool enable);
00505
00513 int scrolledLines() const;
00514
00521 QRect lastScrolledRegion() const;
00522
00527 void resetScrolledLines();
00528
00538 int droppedLines() const;
00539
00544 void resetDroppedLines();
00545
00550 static void fillWithDefaultChar(Character* dest, int count);
00551
00552 private:
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565 int copyLineToStream(int line,
00566 int start,
00567 int count,
00568 TerminalCharacterDecoder* decoder,
00569 bool appendNewLine,
00570 bool preserveLineBreaks);
00571
00572
00573
00574
00575 void clearImage(int loca, int loce, char c);
00576
00577
00578
00579
00580
00581
00582 void moveImage(int dest, int sourceBegin, int sourceEnd);
00583
00584 void scrollUp(int from, int i);
00585
00586 void scrollDown(int from, int i);
00587
00588 void addHistLine();
00589
00590 void initTabStops();
00591
00592 void effectiveRendition();
00593 void reverseRendition(Character& p) const;
00594
00595 bool isSelectionValid() const;
00596
00597
00598
00599 void copyFromScreen(Character* dest, int startLine, int count) const;
00600
00601
00602 void copyFromHistory(Character* dest, int startLine, int count) const;
00603
00604
00605
00606 int lines;
00607 int columns;
00608
00609 typedef QVector<Character> ImageLine;
00610 ImageLine* screenLines;
00611
00612 int _scrolledLines;
00613 QRect _lastScrolledRegion;
00614
00615 int _droppedLines;
00616
00617 QVarLengthArray<LineProperty,64> lineProperties;
00618
00619
00620 HistoryScroll *hist;
00621
00622
00623 int cuX;
00624 int cuY;
00625
00626
00627 CharacterColor cu_fg;
00628 CharacterColor cu_bg;
00629 quint8 cu_re;
00630
00631
00632 int tmargin;
00633 int bmargin;
00634
00635
00636 ScreenParm currParm;
00637
00638
00639
00640 bool* tabstops;
00641
00642
00643 int sel_begin;
00644 int sel_TL;
00645 int sel_BR;
00646 bool sel_busy;
00647 bool columnmode;
00648
00649
00650 CharacterColor ef_fg;
00651 CharacterColor ef_bg;
00652 quint8 ef_re;
00653
00654
00655
00656
00657
00658
00659 int sa_cuX;
00660 int sa_cuY;
00661
00662
00663 quint8 sa_cu_re;
00664 CharacterColor sa_cu_fg;
00665 CharacterColor sa_cu_bg;
00666
00667
00668 int lastPos;
00669
00670
00671 ScreenParm saveParm;
00672
00673 static Character defaultChar;
00674 };
00675
00676 }
00677
00678 #endif // SCREEN_H