• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Konsole

Screen.h

Go to the documentation of this file.
00001 /*
00002     This file is part of Konsole, KDE's terminal.
00003 
00004     Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
00005     Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020     02110-1301  USA.
00021 */
00022 
00023 #ifndef SCREEN_H
00024 #define SCREEN_H
00025 
00026 // Qt
00027 #include <QtCore/QRect>
00028 #include <QtCore/QTextStream>
00029 #include <QtCore/QVarLengthArray>
00030 
00031 // Konsole
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     // VT100/2 Operations 
00086     // Cursor Movement
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     // Editing
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     // Do composition with last shown character FIXME: Not implemented yet for KDE 4
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     //copies a line of text from the screen or history into a stream using a 
00555     //specified character decoder.  Returns the number of lines actually copied,
00556     //which may be less than 'count' if (start+count) is more than the number of characters on
00557     //the line 
00558     //
00559     //line - the line number to copy, from 0 (the earliest line in the history) up to 
00560     //       hist->getLines() + lines - 1
00561     //start - the first column on the line to copy
00562     //count - the number of characters on the line to copy
00563     //decoder - a decoder which coverts terminal characters (an Character array) into text
00564     //appendNewLine - if true a new line character (\n) is appended to the end of the line
00565     int  copyLineToStream(int line, 
00566                           int start, 
00567                           int count, 
00568                           TerminalCharacterDecoder* decoder,
00569                           bool appendNewLine,
00570                           bool preserveLineBreaks);
00571     
00572     //fills a section of the screen image with the character 'c'
00573     //the parameters are specified as offsets from the start of the screen image.
00574     //the loc(x,y) macro can be used to generate these values from a column,line pair.
00575     void clearImage(int loca, int loce, char c);
00576 
00577     //move screen image between 'sourceBegin' and 'sourceEnd' to 'dest'.
00578     //the parameters are specified as offsets from the start of the screen image.
00579     //the loc(x,y) macro can be used to generate these values from a column,line pair.
00580     //
00581     //NOTE: moveImage() can only move whole lines
00582     void moveImage(int dest, int sourceBegin, int sourceEnd);
00583     // scroll up 'i' lines in current region, clearing the bottom 'i' lines 
00584     void scrollUp(int from, int i);
00585     // scroll down 'i' lines in current region, clearing the top 'i' lines
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     // copies 'count' lines from the screen buffer into 'dest',
00598     // starting from 'startLine', where 0 is the first line in the screen buffer
00599     void copyFromScreen(Character* dest, int startLine, int count) const;
00600     // copies 'count' lines from the history buffer into 'dest',
00601     // starting from 'startLine', where 0 is the first line in the history
00602     void copyFromHistory(Character* dest, int startLine, int count) const;
00603 
00604 
00605     // screen image ----------------
00606     int lines;
00607     int columns;
00608 
00609     typedef QVector<Character> ImageLine;      // [0..columns]
00610     ImageLine*          screenLines;    // [lines]
00611 
00612     int _scrolledLines;
00613     QRect _lastScrolledRegion;
00614 
00615     int _droppedLines;
00616 
00617     QVarLengthArray<LineProperty,64> lineProperties;    
00618     
00619     // history buffer ---------------
00620     HistoryScroll *hist;
00621     
00622     // cursor location
00623     int cuX;
00624     int cuY;
00625 
00626     // cursor color and rendition info
00627     CharacterColor cu_fg;      // foreground
00628     CharacterColor cu_bg;      // background
00629     quint8 cu_re;      // rendition
00630 
00631     // margins ----------------
00632     int tmargin;      // top margin
00633     int bmargin;      // bottom margin
00634 
00635     // states ----------------
00636     ScreenParm currParm;
00637 
00638     // ----------------------------
00639 
00640     bool* tabstops;
00641 
00642     // selection -------------------
00643     int sel_begin; // The first location selected.
00644     int sel_TL;    // TopLeft Location.
00645     int sel_BR;    // Bottom Right Location.
00646     bool sel_busy; // Busy making a selection.
00647     bool columnmode;  // Column selection mode
00648 
00649     // effective colors and rendition ------------
00650     CharacterColor ef_fg;      // These are derived from
00651     CharacterColor ef_bg;      // the cu_* variables above
00652     quint8 ef_re;      // to speed up operation
00653 
00654     //
00655     // save cursor, rendition & states ------------
00656     // 
00657 
00658     // cursor location
00659     int sa_cuX;
00660     int sa_cuY;
00661 
00662     // rendition info
00663     quint8 sa_cu_re;
00664     CharacterColor sa_cu_fg;
00665     CharacterColor sa_cu_bg;
00666     
00667     // last position where we added a character
00668     int lastPos;
00669 
00670     // modes
00671     ScreenParm saveParm;
00672 
00673     static Character defaultChar;
00674 };
00675 
00676 }
00677 
00678 #endif // SCREEN_H

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • Konsole
  • Libraries
  •   libkonq
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal