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

Konsole

Vt102Emulation.h

Go to the documentation of this file.
00001 /*
00002     This file is part of Konsole, an X 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 VT102EMULATION_H
00024 #define VT102EMULATION_H
00025 
00026 // Standard Library
00027 #include <stdio.h>
00028 
00029 // Qt 
00030 #include <QtGui/QKeyEvent>
00031 #include <QtCore/QHash>
00032 #include <QtCore/QTimer>
00033 
00034 // Konsole
00035 #include "Emulation.h"
00036 #include "Screen.h"
00037 
00038 #define MODE_AppScreen       (MODES_SCREEN+0)   // Mode #1
00039 #define MODE_AppCuKeys       (MODES_SCREEN+1)   // Application cursor keys (DECCKM)
00040 #define MODE_AppKeyPad       (MODES_SCREEN+2)   // 
00041 #define MODE_Mouse1000       (MODES_SCREEN+3)   // Send mouse X,Y position on press and release
00042 #define MODE_Mouse1001       (MODES_SCREEN+4)   // Use Hilight mouse tracking
00043 #define MODE_Mouse1002       (MODES_SCREEN+5)   // Use cell motion mouse tracking
00044 #define MODE_Mouse1003       (MODES_SCREEN+6)   // Use all motion mouse tracking 
00045 #define MODE_Ansi            (MODES_SCREEN+7)   // Use US Ascii for character sets G0-G3 (DECANM) 
00046 #define MODE_132Columns      (MODES_SCREEN+8)   // 80 <-> 132 column mode switch (DECCOLM)
00047 #define MODE_Allow132Columns (MODES_SCREEN+9)   // Allow DECCOLM mode
00048 #define MODE_total           (MODES_SCREEN+10)
00049 
00050 namespace Konsole
00051 {
00052 
00053 struct CharCodes
00054 {
00055   // coding info
00056   char charset[4]; //
00057   int  cu_cs;      // actual charset.
00058   bool graphic;    // Some VT100 tricks
00059   bool pound  ;    // Some VT100 tricks
00060   bool sa_graphic; // saved graphic
00061   bool sa_pound;   // saved pound
00062 };
00063 
00074 class Vt102Emulation : public Emulation
00075 { 
00076 Q_OBJECT
00077 
00078 public:
00080   Vt102Emulation();
00081   ~Vt102Emulation();
00082   
00083   // reimplemented from Emulation
00084   virtual void clearEntireScreen();
00085   virtual void reset();
00086   virtual char eraseChar() const;
00087   
00088 public slots: 
00089   // reimplemented from Emulation 
00090   virtual void sendString(const char*,int length = -1);
00091   virtual void sendText(const QString& text);
00092   virtual void sendKeyEvent(QKeyEvent*);
00093   virtual void sendMouseEvent(int buttons, int column, int line, int eventType);
00094   
00095 protected:
00096   // reimplemented from Emulation
00097   virtual void setMode(int mode);
00098   virtual void resetMode(int mode);
00099   virtual void receiveChar(int cc);
00100   
00101 private slots:
00102   //causes changeTitle() to be emitted for each (int,QString) pair in pendingTitleUpdates
00103   //used to buffer multiple title updates
00104   void updateTitle();
00105 
00106 private:
00107   unsigned short applyCharset(unsigned short c);
00108   void setCharset(int n, int cs);
00109   void useCharset(int n);
00110   void setAndUseCharset(int n, int cs);
00111   void saveCursor();
00112   void restoreCursor();
00113   void resetCharset(int scrno);
00114 
00115   void setMargins(int top, int bottom);
00116   //set margins for all screens back to their defaults
00117   void setDefaultMargins();
00118 
00119   // returns true if 'mode' is set or false otherwise
00120   bool getMode    (int mode);
00121   // saves the current boolean value of 'mode'
00122   void saveMode   (int mode);
00123   // restores the boolean value of 'mode' 
00124   void restoreMode(int mode);
00125   // resets all modes
00126   // (except MODE_Allow132Columns)
00127   void resetModes();
00128 
00129   void resetTokenizer();
00130   #define MAX_TOKEN_LENGTH 80
00131   void addToCurrentToken(int cc);
00132   int tokenBuffer[MAX_TOKEN_LENGTH]; //FIXME: overflow?
00133   int tokenBufferPos;
00134 #define MAXARGS 15
00135   void addDigit(int dig);
00136   void addArgument();
00137   int argv[MAXARGS];
00138   int argc;
00139   void initTokenizer();
00140 
00141   // Set of flags for each of the ASCII characters which indicates
00142   // what category they fall into (printable character, control, digit etc.)
00143   // for the purposes of decoding terminal output
00144   int charClass[256];
00145 
00146   void reportDecodingError(); 
00147 
00148   void processToken(int code, int p, int q);
00149   void processWindowAttributeChange();
00150 
00151   void reportTerminalType();
00152   void reportSecondaryAttributes();
00153   void reportStatus();
00154   void reportAnswerBack();
00155   void reportCursorPosition();
00156   void reportTerminalParms(int p);
00157 
00158   void onScrollLock();
00159   void scrollLock(const bool lock);
00160 
00161   // clears the screen and resizes it to the specified
00162   // number of columns
00163   void clearScreenAndSetColumns(int columnCount);
00164 
00165   CharCodes _charset[2];
00166 
00167   class TerminalState
00168   {
00169   public:
00170     // Initializes all modes to false
00171     TerminalState()
00172     { memset(&mode,false,MODE_total * sizeof(bool)); }
00173 
00174     bool mode[MODE_total];
00175   };
00176 
00177   TerminalState _currentModes;
00178   TerminalState _savedModes;
00179 
00180   //hash table and timer for buffering calls to the session instance 
00181   //to update the name of the session
00182   //or window title.
00183   //these calls occur when certain escape sequences are seen in the 
00184   //output from the terminal
00185   QHash<int,QString> _pendingTitleUpdates;
00186   QTimer* _titleUpdateTimer;
00187 };
00188 
00189 }
00190 
00191 #endif // VT102EMULATION_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.7
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