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 00053 class ScreenWindow : public QObject 00054 { 00055 Q_OBJECT 00056 00057 public: 00067 ScreenWindow(QObject* parent = 0); 00068 virtual ~ScreenWindow(); 00069 00071 void setScreen(Screen* screen); 00073 Screen* screen() const; 00074 00082 Character* getImage(); 00083 00088 QVector<LineProperty> getLineProperties(); 00089 00101 int scrollCount() const; 00102 00106 void resetScrollCount(); 00107 00115 QRect scrollRegion() const; 00116 00121 void setSelectionStart( int column , int line , bool columnMode ); 00126 void setSelectionEnd( int column , int line ); 00130 void getSelectionStart( int& column , int& line ); 00134 void getSelectionEnd( int& column , int& line ); 00138 bool isSelected( int column , int line ); 00142 void clearSelection(); 00143 00145 void setWindowLines(int lines); 00147 int windowLines() const; 00149 int windowColumns() const; 00150 00152 int lineCount() const; 00154 int columnCount() const; 00155 00157 int currentLine() const; 00158 00163 QPoint cursorPosition() const; 00164 00169 bool atEndOfOutput() const; 00170 00172 void scrollTo( int line ); 00173 00175 enum RelativeScrollMode 00176 { 00178 ScrollLines, 00183 ScrollPages 00184 }; 00185 00195 void scrollBy( RelativeScrollMode mode , int amount ); 00196 00204 void setTrackOutput(bool trackOutput); 00209 bool trackOutput() const; 00210 00216 QString selectedText( bool preserveLineBreaks ) const; 00217 00218 public slots: 00224 void notifyOutputChanged(); 00225 00226 signals: 00230 void outputChanged(); 00231 00237 void scrolled(int line); 00238 00240 void selectionChanged(); 00241 00242 private: 00243 int endWindowLine() const; 00244 void fillUnusedArea(); 00245 00246 Screen* _screen; // see setScreen() , screen() 00247 Character* _windowBuffer; 00248 int _windowBufferSize; 00249 bool _bufferNeedsUpdate; 00250 00251 int _windowLines; 00252 int _currentLine; // see scrollTo() , currentLine() 00253 bool _trackOutput; // see setTrackOutput() , trackOutput() 00254 int _scrollCount; // count of lines which the window has been scrolled by since 00255 // the last call to resetScrollCount() 00256 }; 00257 00258 } 00259 #endif // SCREENWINDOW_H