Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

screen.h

Go to the documentation of this file.
00001 /* -------------------------------------------------------------------------- */
00002 /*                                                                            */
00003 /* [screen.h]                 Screen Data Type                             */
00004 /*                                                                            */
00005 /* -------------------------------------------------------------------------- */
00006 /*                                                                            */
00007 /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de>            */
00008 /*                                                                            */
00009 /* This file is part of Konsole - an X terminal for KDE                       */
00010 /*                                                                            */
00011 /* -------------------------------------------------------------------------- */
00012 /*                                                                            */
00013 /* Ported Konsole to Qt/Embedded                                              */
00014 /*                                                                            */
00015 /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com>                  */
00016 /*                                                                            */
00017 /* -------------------------------------------------------------------------- */
00018 
00019 #ifndef SCREEN_H
00020 #define SCREEN_H
00021 
00025 #include "common.h"
00026 #include "history.h"
00027 
00028 #define MODE_Origin    0
00029 #define MODE_Wrap      1
00030 #define MODE_Insert    2
00031 #define MODE_Screen    3
00032 #define MODE_Cursor    4
00033 #define MODE_NewLine   5
00034 #define MODES_SCREEN   6
00035 
00038 struct ScreenParm
00039 {
00040   int mode[MODES_SCREEN];
00041 };
00042 
00043 
00044 class Screen
00045 {
00046 public:
00047     Screen(int lines, int columns);
00048     ~Screen();
00049 
00050 public: // these are all `Screen' operations
00051     //
00052     // VT100/2 Operations ------------------
00053     //
00054     // Cursor Movement
00055     //
00056     void cursorUp    (int n);
00057     void cursorDown  (int n);
00058     void cursorLeft  (int n);
00059     void cursorRight (int n);
00060     void setCursorY  (int y);
00061     void setCursorX  (int x);
00062     void setCursorYX (int y, int x);
00063     void setMargins  (int t, int b);
00064     //
00065     // Cursor Movement with Scrolling
00066     //
00067     void NewLine     ();
00068     void NextLine    ();
00069     void index       ();
00070     void reverseIndex();
00071     //
00072     void Return      ();
00073     void BackSpace   ();
00074     void Tabulate    ();
00075     //
00076     // Editing
00077     //
00078     void eraseChars  (int n);
00079     void deleteChars (int n);
00080     void insertChars (int n);
00081     void deleteLines (int n);
00082     void insertLines (int n);
00083     //
00084     // -------------------------------------
00085     //
00086     void clearTabStops();
00087     void changeTabStop(bool set);
00088     //
00089     void resetMode   (int n);
00090     void setMode     (int n);
00091     void saveMode    (int n);
00092     void restoreMode (int n);
00093     //
00094     void saveCursor  ();
00095     void restoreCursor();
00096     //
00097     // -------------------------------------
00098     //
00099     void clearEntireScreen();
00100     void clearToEndOfScreen();
00101     void clearToBeginOfScreen();
00102     //
00103     void clearEntireLine();
00104     void clearToEndOfLine();
00105     void clearToBeginOfLine();
00106     //
00107     void helpAlign   ();
00108     //
00109     // -------------------------------------
00110     //
00111     void setRendition  (int rendition);
00112     void resetRendition(int rendition);
00113     void setForeColor  (int fgcolor);
00114     void setBackColor  (int bgcolor);
00115     //
00116     void setDefaultRendition();
00117     void setForeColorToDefault();
00118     void setBackColorToDefault();
00119     //
00120     // -------------------------------------
00121     //
00122     BOOL getMode     (int n);
00123     //
00124     // only for report cursor position
00125     //
00126     int  getCursorX();
00127     int  getCursorY();
00128     //
00129     // -------------------------------------
00130     //
00131     void clear();
00132     void home();
00133     void reset();
00134     //
00135     void ShowCharacter(unsigned short c);
00136     //
00137     void resizeImage(int new_lines, int new_columns);
00138     //
00139     QArray<Character> getCookedImage();
00140     
00142     int  getLines()   { return lines; }
00144     int  getColumns() { return columns; }
00145 
00147     void setHistCursor(int cursor);
00149     int  getHistCursor();
00150 
00151     int  getHistLines ();
00152     void setScroll(bool on);
00153     bool hasScroll();
00154 
00155     //
00156     // Selection
00157     //
00158     void setSelBeginXY(const int x, const int y);
00159     void setSelExtentXY(const int x, const int y);
00160     void clearSelection();
00161     QString getSelText(const BOOL preserve_line_breaks);
00162 
00163     void checkSelection(int from, int to);
00164 
00165 private: // helper
00166 
00167     void clearImage(int loca, int loce, char c);
00168     void moveImage(int dst, int loca, int loce);
00169     
00170     void scrollUp(int from, int i);
00171     void scrollDown(int from, int i);
00172 
00173     void addHistLine();
00174 
00175     void initTabStops();
00176 
00177     void effectiveRendition();
00178     void reverseRendition( Character *p );
00179 
00180 private:
00181 
00182     /*
00183        The state of the screen is more complex as one would
00184        expect first. The screem does really do part of the
00185        emulation providing state informations in form of modes,
00186        margins, tabulators, cursor etc.
00187 
00188        Even more unexpected are variables to save and restore
00189        parts of the state.
00190     */
00191 
00192     // screen image ----------------
00193 
00194     int lines;
00195     int columns;
00196     QArray<Character> image; // [lines][columns]
00197 
00198     // history buffer ---------------
00199 
00200     int histCursor;   // display position relative to start of the history buffer
00201     HistoryScroll hist;
00202     
00203     // cursor location
00204 
00205     int cuX;
00206     int cuY;
00207 
00208     // cursor color and rendition info
00209 
00210     UINT8 cu_fg;      // foreground
00211     UINT8 cu_bg;      // background
00212     UINT8 cu_re;      // rendition
00213 
00214     // margins ----------------
00215 
00216     int tmargin;      // top margin
00217     int bmargin;      // bottom margin
00218 
00219     // states ----------------
00220 
00221     ScreenParm currParm;
00222 
00223     // ----------------------------
00224 
00225     bool* tabstops;
00226 
00227     // selection -------------------
00228 
00229     int sel_begin; // The first location selected.
00230     int sel_TL;    // TopLeft Location.
00231     int sel_BR;    // Bottom Right Location.
00232 
00233     // effective colors and rendition ------------
00234 
00235     UINT8 ef_fg;      // These are derived from
00236     UINT8 ef_bg;      // the cu_* variables above
00237     UINT8 ef_re;      // to speed up operation
00238 
00239     //
00240     // save cursor, rendition & states ------------
00241     // 
00242 
00243     // cursor location
00244 
00245     int sa_cuX;
00246     int sa_cuY;
00247 
00248     // rendition info
00249 
00250     UINT8 sa_cu_re;
00251     UINT8 sa_cu_fg;
00252     UINT8 sa_cu_bg;
00253 
00254     // modes
00255 
00256     ScreenParm saveParm;
00257 };
00258 
00259 #endif // TESCREEN_H

Generated on Sat Nov 5 16:16:51 2005 for OPIE by  doxygen 1.4.2