[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: PATCH, take 2 , uses BlockArray (was Re: konsole's history : is anyone taking care of it ?)
From:       Guillaume Laurent <glaurent () telegraph-road ! org>
Date:       2001-06-02 9:34:55
[Download RAW message or body]

On Friday 01 June 2001 09:18, Stephan Kulow wrote:

> The patch doesn't include the include directory. Can you send it too?

Woops. Here it is.

-- 
					Guillaume.
					http://www.telegraph-road.org

["konsole_history_patch_include.patch" (text/x-c)]

Index: BlockArray.h
===================================================================
RCS file: /home/kde/kdebase/konsole/include/BlockArray.h,v
retrieving revision 1.2
diff -u -r1.2 BlockArray.h
--- BlockArray.h	2001/02/01 21:54:28	1.2
+++ BlockArray.h	2001/06/02 09:33:26
@@ -3,7 +3,7 @@
 
 #include <unistd.h>
 
-#error Dont use in KDE 2.1
+//#error Dont use in KDE 2.1
 
 #define BlockSize (1 << 12)
 #define ENTRIES   ((BlockSize - sizeof(size_t) ) / sizeof(unsigned char))
@@ -73,6 +73,8 @@
     size_t len() const { return length; }
 
     bool has(size_t index) const;
+
+    size_t getCurrent() const { return current; }
 
 private:
     void unmap();
Index: TEHistory.h
===================================================================
RCS file: /home/kde/kdebase/konsole/include/TEHistory.h,v
retrieving revision 1.4
diff -u -r1.4 TEHistory.h
--- TEHistory.h	2001/02/01 21:54:28	1.4
+++ TEHistory.h	2001/06/02 09:33:27
@@ -13,57 +13,240 @@
 #ifndef TEHISTORY_H
 #define TEHISTORY_H
 
+#include <qcstring.h>
+#include <qvector.h>
+
 #include "TECommon.h"
 
+#if 0
 /*
    An extendable tmpfile(1) based buffer.
 */
-class HistoryBuffer
-{
-public:
-  HistoryBuffer();
- ~HistoryBuffer();
 
+class HistoryFile
+{
 public:
-  void setScroll(bool on);
-  bool hasScroll();
+  HistoryFile();
+  virtual ~HistoryFile();
 
-public:
-  void add(const unsigned char* bytes, int len);
-  void get(unsigned char* bytes, int len, int loc);
-  int  len();
+  virtual void add(const unsigned char* bytes, int len);
+  virtual void get(unsigned char* bytes, int len, int loc);
+  virtual int  len();
 
 private:
   int  ion;
   int  length;
 };
+#endif
 
+//////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////
+// Abstract base class for file and buffer versions
+//////////////////////////////////////////////////////////////////////
+class HistoryType;
+
 class HistoryScroll
 {
 public:
-  HistoryScroll();
- ~HistoryScroll();
+  HistoryScroll(HistoryType*);
+ virtual ~HistoryScroll();
 
-public:
-  void setScroll(bool on);
-  bool hasScroll();
+  virtual bool hasScroll();
 
-public: // access to history
-  int  getLines();
-  int  getLineLen(int lineno);
-  void getCells(int lineno, int colno, int count, ca res[]);
+  // access to history
+  virtual int  getLines() = 0;
+  virtual int  getLineLen(int lineno) = 0;
+  virtual void getCells(int lineno, int colno, int count, ca res[]) = 0;
 
-public: // backward compatibility (obsolete)
+  // backward compatibility (obsolete)
   ca   getCell(int lineno, int colno) { ca res; getCells(lineno,colno,1,&res); return res; }
+
+  // adding lines.
+  virtual void addCells(ca a[], int count) = 0;
+  virtual void addLine() = 0;
+
+  const HistoryType& getType() { return *m_histType; }
 
-public: // adding lines.
-  void addCells(ca a[], int count);
-  void addLine();
+protected:
+  HistoryType* m_histType;
 
+};
+
+#if 0
+
+//////////////////////////////////////////////////////////////////////
+// File-based history (e.g. file log, no limitation in length)
+//////////////////////////////////////////////////////////////////////
+
+class HistoryScrollFile : public HistoryScroll
+{
+public:
+  HistoryScrollFile(const QString &logFileName);
+  virtual ~HistoryScrollFile();
+
+  virtual int  getLines();
+  virtual int  getLineLen(int lineno);
+  virtual void getCells(int lineno, int colno, int count, ca res[]);
+
+  virtual void addCells(ca a[], int count);
+  virtual void addLine();
+
 private:
   int startOfLine(int lineno);
-  HistoryBuffer index; // lines Row(int)
-  HistoryBuffer cells; // text  Row(ca)
+
+  QString m_logFileName;
+  HistoryFile index; // lines Row(int)
+  HistoryFile cells; // text  Row(ca)
+};
+
+
+//////////////////////////////////////////////////////////////////////
+// Buffer-based history (limited to a fixed nb of lines)
+//////////////////////////////////////////////////////////////////////
+class HistoryScrollBuffer : public HistoryScroll
+{
+public:
+  typedef QArray<ca> histline;
+
+  HistoryScrollBuffer(unsigned int maxNbLines = 1000);
+  virtual ~HistoryScrollBuffer();
+
+  virtual int  getLines();
+  virtual int  getLineLen(int lineno);
+  virtual void getCells(int lineno, int colno, int count, ca res[]);
+
+  virtual void addCells(ca a[], int count);
+  virtual void addLine();
+
+  void setMaxNbLines(unsigned int nbLines);
+  unsigned int maxNbLines() { return m_maxNbLines; }
+
+private:
+
+  bool m_hasScroll;
+  QVector<histline> m_histBuffer;
+  unsigned int m_maxNbLines;
+  unsigned int m_nbLines;
+  unsigned int m_arrayIndex;
+  
+};
+
+#endif
+
+//////////////////////////////////////////////////////////////////////
+// Nothing-based history (no history :-)
+//////////////////////////////////////////////////////////////////////
+class HistoryScrollNone : public HistoryScroll
+{
+public:
+  HistoryScrollNone();
+  virtual ~HistoryScrollNone();
+
+  virtual bool hasScroll();
+
+  virtual int  getLines();
+  virtual int  getLineLen(int lineno);
+  virtual void getCells(int lineno, int colno, int count, ca res[]);
+
+  virtual void addCells(ca a[], int count);
+  virtual void addLine();
 };
+
+//////////////////////////////////////////////////////////////////////
+// BlockArray-based history
+//////////////////////////////////////////////////////////////////////
+#include "BlockArray.h"
+#include <qintdict.h>
+class HistoryScrollBlockArray : public HistoryScroll
+{
+public:
+  HistoryScrollBlockArray(size_t size);
+  virtual ~HistoryScrollBlockArray();
+
+  virtual int  getLines();
+  virtual int  getLineLen(int lineno);
+  virtual void getCells(int lineno, int colno, int count, ca res[]);
+
+  virtual void addCells(ca a[], int count);
+  virtual void addLine();
+
+protected:
+  BlockArray m_blockArray;
+  QIntDict<size_t> m_lineLengths;
+};
+
+//////////////////////////////////////////////////////////////////////
+// History type
+//////////////////////////////////////////////////////////////////////
+
+class HistoryType
+{
+public:
+  HistoryType();
+  virtual ~HistoryType();
+
+  virtual bool isOn()                const = 0;
+  virtual unsigned int getSize()     const = 0;
+
+  virtual HistoryScroll* getScroll() const = 0;
+};
+
+class HistoryTypeNone : public HistoryType
+{
+public:
+  HistoryTypeNone();
+
+  virtual bool isOn() const;
+  virtual unsigned int getSize() const;
+
+  virtual HistoryScroll* getScroll() const;
+};
+
+class HistoryTypeBlockArray : public HistoryType
+{
+public:
+  HistoryTypeBlockArray(size_t size);
+  
+  virtual bool isOn() const;
+  virtual unsigned int getSize() const;
+
+  virtual HistoryScroll* getScroll() const;
+
+protected:
+  size_t m_size;
+};
+
+#if 0 // Disabled for now 
+class HistoryTypeFile : public HistoryType
+{
+public:
+  HistoryTypeFile(const QString& fileName);
+
+  virtual bool isOn() const;
+  virtual const QString& getFileName() const;
+
+  virtual HistoryScroll* getScroll() const;
+
+protected:
+  QString m_fileName;
+};
+
+
+class HistoryTypeBuffer : public HistoryType
+{
+public:
+  HistoryTypeBuffer(unsigned int nbLines);
+  
+  virtual bool isOn() const;
+  virtual unsigned int getNbLines() const;
+
+  virtual HistoryScroll* getScroll() const;
+
+protected:
+  unsigned int m_nbLines;
+};
+
+#endif
 
 #endif // TEHISTORY_H
Index: TEScreen.h
===================================================================
RCS file: /home/kde/kdebase/konsole/include/TEScreen.h,v
retrieving revision 1.10
diff -u -r1.10 TEScreen.h
--- TEScreen.h	2000/01/29 01:47:35	1.10
+++ TEScreen.h	2001/06/02 09:33:27
@@ -143,7 +143,8 @@
     int  getHistCursor();
 
     int  getHistLines ();
-    void setScroll(bool on);
+    void setScroll(const HistoryType&);
+    const HistoryType& getScroll();
     bool hasScroll();
 
     //
@@ -192,7 +193,7 @@
     // history buffer ---------------
 
     int histCursor;   // display position relative to start of the history buffer
-    HistoryScroll hist;
+    HistoryScroll *hist;
     
     // cursor location
 
Index: TEmulation.h
===================================================================
RCS file: /home/kde/kdebase/konsole/include/TEmulation.h,v
retrieving revision 1.11
diff -u -r1.11 TEmulation.h
--- TEmulation.h	2001/03/19 14:34:01	1.11
+++ TEmulation.h	2001/06/02 09:33:28
@@ -29,8 +29,8 @@
   ~TEmulation();
 
 public:
-  virtual void setHistory(bool on);
-  virtual bool history();
+  virtual void setHistory(const HistoryType&);
+  virtual const HistoryType& history();
 
 public slots: // signals incoming from TEWidget
 
@@ -80,7 +80,6 @@
   void setCodec(int c); // codec number, 0 = locale, 1=utf8
 
   QTextCodec* codec;
-  QTextCodec* localeCodec;
   QTextDecoder* decoder;
 
   KeyTrans* keytrans;
@@ -101,7 +100,6 @@
 
   QTimer bulk_timer;
   int    bulk_nlcnt;   // bulk newline counter
-  char*  SelectedText;
   int    bulk_incnt;   // bulk counter
 
 
Index: konsole.h
===================================================================
RCS file: /home/kde/kdebase/konsole/include/konsole.h,v
retrieving revision 1.39
diff -u -r1.39 konsole.h
--- konsole.h	2001/05/20 20:41:28	1.39
+++ konsole.h	2001/06/02 09:33:28
@@ -98,6 +98,7 @@
   void slotToggleMenubar();
   void slotToggleFrame();
   void slotRenameSession();
+  void slotHistoryType();
   void slotWordSeps();
   void slotSelectSize();
   void slotSelectFont();
@@ -115,8 +116,6 @@
   void addSession(TESession* s);
   void setColorPixmaps();
 
-  void setHistory(bool);
-
   void setSchema(const QString & path);
   void setSchema(ColorSchema* s);
   void setFont(int fontno);
@@ -192,9 +191,36 @@
   bool        b_warnQuit:1;
   bool        alreadyNoticedBackgroundChange_:1;
 
+  unsigned int m_histSize;
+
 public:
 
   QString     title;
 };
+
+class QSpinBox;
+#include <kdialogbase.h>
+
+class HistoryTypeDialog : public KDialogBase 
+{
+    Q_OBJECT
+public:
+  HistoryTypeDialog(const HistoryType& histType, QWidget *parent);
+
+public slots:
+
+  void slotBufferHistChoosen();
+  void slotNoHistChoosen();
+
+  unsigned int bufferSize() const;
+
+  bool isOff()         { return m_isOff; }
+
+protected:
+  QSpinBox*  m_size;
+  bool m_isOff;
+};
+
+
 
 #endif
Index: session.h
===================================================================
RCS file: /home/kde/kdebase/konsole/include/session.h,v
retrieving revision 1.17
diff -u -r1.17 session.h
--- session.h	2001/03/10 21:13:43	1.17
+++ session.h	2001/06/02 09:33:28
@@ -40,10 +40,11 @@
   int fontNo();
   const char* emuName();
   const QString& Title();
-  bool history();
   int keymap();
 
-  void setHistory(bool on);
+  void setHistory(const HistoryType&);
+  const HistoryType& history();
+
   void setSchemaNo(int sn);
   void setKeymapNo(int kn);
   void setFontNo(int fn);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic