Konsole
ScreenWindow.h
Go to the documentation of this file.00001 /* 00002 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301 USA. 00018 */ 00019 00020 #ifndef SCREENWINDOW_H 00021 #define SCREENWINDOW_H 00022 00023 // Qt 00024 #include <QtCore/QObject> 00025 #include <QtCore/QPoint> 00026 #include <QtCore/QRect> 00027 00028 // Konsole 00029 #include "Character.h" 00030 00031 namespace Konsole 00032 { 00033 00034 class Screen; 00035 00052 class ScreenWindow : public QObject 00053 { 00054 Q_OBJECT 00055 00056 public: 00066 ScreenWindow(QObject* parent = 0); 00067 virtual ~ScreenWindow(); 00068 00070 void setScreen(Screen* screen); 00072 Screen* screen() const; 00073 00081 Character* getImage(); 00082 00087 QVector<LineProperty> getLineProperties(); 00088 00100 int scrollCount() const; 00101 00105 void resetScrollCount(); 00106 00114 QRect scrollRegion() const; 00115 00120 void setSelectionStart( int column , int line , bool columnMode ); 00125 void setSelectionEnd( int column , int line ); 00129 void getSelectionStart( int& column , int& line ); 00133 void getSelectionEnd( int& column , int& line ); 00137 bool isSelected( int column , int line ); 00141 void clearSelection(); 00142 00144 void setWindowLines(int lines); 00146 int windowLines() const; 00148 int windowColumns() const; 00149 00151 int lineCount() const; 00153 int columnCount() const; 00154 00156 int currentLine() const; 00157 00162 QPoint cursorPosition() const; 00163 00168 bool atEndOfOutput() const; 00169 00171 void scrollTo( int line ); 00172 00173 enum RelativeScrollMode 00174 { 00175 ScrollLines, 00176 ScrollPages 00177 }; 00178 00188 void scrollBy( RelativeScrollMode mode , int amount ); 00189 00197 void setTrackOutput(bool trackOutput); 00202 bool trackOutput() const; 00203 00209 QString selectedText( bool preserveLineBreaks ) const; 00210 00211 public slots: 00217 void notifyOutputChanged(); 00218 00219 signals: 00223 void outputChanged(); 00224 00230 void scrolled(int line); 00231 00235 void selectionChanged(); 00236 00237 private: 00238 int endWindowLine() const; 00239 void fillUnusedArea(); 00240 00241 Screen* _screen; // see setScreen() , screen() 00242 Character* _windowBuffer; 00243 int _windowBufferSize; 00244 bool _bufferNeedsUpdate; 00245 00246 int _windowLines; 00247 int _currentLine; // see scrollTo() , currentLine() 00248 bool _trackOutput; // see setTrackOutput() , trackOutput() 00249 int _scrollCount; // count of lines which the window has been scrolled by since 00250 // the last call to resetScrollCount() 00251 }; 00252 00253 } 00254 #endif // SCREENWINDOW_H