[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] Konsole, changing history size.
From: Waldo Bastian <bastian () kde ! org>
Date: 2001-07-23 4:55:43
[Download RAW message or body]
The following patch allows you to change your history size without losing the
contents of the history buffer.
A problem that still needs fixing before release is to stop the scrolling
when looking at the history. This is a bit tricky I guess, because you need
to take care that the part you are viewing isn't deleted underneath you.
Cheers,
Waldo
--
Andrei Sakharov, Exciled 1980-1986, USSR, http://www.aip.org/history/sakharov/
Dmitry Sklyarov, Detained 2001-????, USA, http://www.elcomsoft.com/
["konsole_scroll.diff" (text/x-diff)]
Index: include/TEHistory.h
===================================================================
RCS file: /home/kde/kdebase/konsole/include/TEHistory.h,v
retrieving revision 1.8
diff -u -3 -d -p -r1.8 TEHistory.h
--- include/TEHistory.h 2001/06/25 09:35:55 1.8
+++ include/TEHistory.h 2001/07/23 04:52:32
@@ -121,10 +121,14 @@ public:
void setMaxNbLines(unsigned int nbLines);
unsigned int maxNbLines() { return m_maxNbLines; }
+
private:
int adjustLineNb(int lineno);
+ // Normalize buffer so that the size can be changed.
+ void normalize();
+
bool m_hasScroll;
QVector<histline> m_histBuffer;
unsigned int m_maxNbLines;
@@ -191,7 +195,7 @@ public:
virtual bool isOn() const = 0;
virtual unsigned int getSize() const = 0;
- virtual HistoryScroll* getScroll() const = 0;
+ virtual HistoryScroll* getScroll(HistoryScroll *) const = 0;
};
class HistoryTypeNone : public HistoryType
@@ -202,7 +206,7 @@ public:
virtual bool isOn() const;
virtual unsigned int getSize() const;
- virtual HistoryScroll* getScroll() const;
+ virtual HistoryScroll* getScroll(HistoryScroll *) const;
};
class HistoryTypeBlockArray : public HistoryType
@@ -213,7 +217,7 @@ public:
virtual bool isOn() const;
virtual unsigned int getSize() const;
- virtual HistoryScroll* getScroll() const;
+ virtual HistoryScroll* getScroll(HistoryScroll *) const;
protected:
size_t m_size;
@@ -229,7 +233,7 @@ public:
virtual const QString& getFileName() const;
virtual unsigned int getSize() const;
- virtual HistoryScroll* getScroll() const;
+ virtual HistoryScroll* getScroll(HistoryScroll *) const;
protected:
QString m_fileName;
@@ -245,7 +249,7 @@ public:
virtual unsigned int getNbLines() const;
virtual unsigned int getSize() const;
- virtual HistoryScroll* getScroll() const;
+ virtual HistoryScroll* getScroll(HistoryScroll *) const;
protected:
unsigned int m_nbLines;
Index: src/TEHistory.C
===================================================================
RCS file: /home/kde/kdebase/konsole/src/TEHistory.C,v
retrieving revision 1.18
diff -u -3 -d -p -r1.18 TEHistory.C
--- src/TEHistory.C 2001/06/27 18:06:02 1.18
+++ src/TEHistory.C 2001/07/23 04:52:33
@@ -232,6 +232,30 @@ void HistoryScrollBuffer::addCells(ca a[
m_histBuffer.insert(m_arrayIndex, newLine);
}
+void HistoryScrollBuffer::normalize()
+{
+ if (!m_buffFilled || !m_arrayIndex) return;
+ QVector<histline> newHistBuffer;
+ newHistBuffer.resize(m_maxNbLines);
+ for(int i = 0; i < m_maxNbLines-2; i++)
+ {
+ int lineno = adjustLineNb(i);
+ newHistBuffer.insert(i+1, m_histBuffer[lineno]);
+ }
+ m_histBuffer.setAutoDelete(false);
+ // Qt 2.3: QVector copy assignment is buggy :-(
+ // m_histBuffer = newHistBuffer;
+ for(int i = 0; i < m_maxNbLines; i++)
+ {
+ m_histBuffer.insert(i, newHistBuffer[i]);
+ }
+ m_histBuffer.setAutoDelete(true);
+
+ m_arrayIndex = m_maxNbLines;
+ m_buffFilled = false;
+ m_nbLines = m_maxNbLines-2;
+}
+
void HistoryScrollBuffer::addLine()
{
// ? Do nothing
@@ -276,8 +300,14 @@ void HistoryScrollBuffer::getCells(int l
void HistoryScrollBuffer::setMaxNbLines(unsigned int nbLines)
{
+ normalize();
m_maxNbLines = nbLines;
m_histBuffer.resize(m_maxNbLines);
+ if (m_nbLines > m_maxNbLines - 2)
+ m_nbLines = m_maxNbLines -2;
+
+ delete m_histType;
+ m_histType = new HistoryTypeBuffer(nbLines);
}
int HistoryScrollBuffer::adjustLineNb(int lineno)
@@ -426,8 +456,9 @@ bool HistoryTypeNone::isOn() const
return false;
}
-HistoryScroll* HistoryTypeNone::getScroll() const
+HistoryScroll* HistoryTypeNone::getScroll(HistoryScroll *old) const
{
+ delete old;
return new HistoryScrollNone();
}
@@ -453,8 +484,9 @@ unsigned int HistoryTypeBlockArray::getS
return m_size;
}
-HistoryScroll* HistoryTypeBlockArray::getScroll() const
+HistoryScroll* HistoryTypeBlockArray::getScroll(HistoryScroll *old) const
{
+ delete old;
return new HistoryScrollBlockArray(m_size);
}
@@ -483,8 +515,18 @@ unsigned int HistoryTypeBuffer::getSize(
return getNbLines();
}
-HistoryScroll* HistoryTypeBuffer::getScroll() const
+HistoryScroll* HistoryTypeBuffer::getScroll(HistoryScroll *old) const
{
+ if (old)
+ {
+ HistoryScrollBuffer *oldBuffer = dynamic_cast<HistoryScrollBuffer*>(old);
+ if (oldBuffer)
+ {
+ oldBuffer->setMaxNbLines(m_nbLines);
+ return oldBuffer;
+ }
+ delete old;
+ }
return new HistoryScrollBuffer(m_nbLines);
}
@@ -505,8 +547,9 @@ const QString& HistoryTypeFile::getFileN
return m_fileName;
}
-HistoryScroll* HistoryTypeFile::getScroll() const
+HistoryScroll* HistoryTypeFile::getScroll(HistoryScroll *old) const
{
+ delete old;
return new HistoryScrollFile(m_fileName);
}
Index: src/TEScreen.C
===================================================================
RCS file: /home/kde/kdebase/konsole/src/TEScreen.C,v
retrieving revision 1.50
diff -u -3 -d -p -r1.50 TEScreen.C
--- src/TEScreen.C 2001/07/14 19:03:31 1.50
+++ src/TEScreen.C 2001/07/23 04:52:34
@@ -1223,9 +1223,8 @@ int TEScreen::getHistLines()
void TEScreen::setScroll(const HistoryType& t)
{
- delete hist;
- hist = t.getScroll();
- histCursor = 0;
+ hist = t.getScroll(hist);
+ histCursor = hist->getLines();
}
bool TEScreen::hasScroll()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic