diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index add34d82..5f13d7ee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,6 +65,7 @@ set(konsoleprivate_SRCS ${sessionadaptors_SRCS} Filter.cpp History.cpp HistoryFile.cpp + HistoryScroll.cpp HistorySizeDialog.cpp widgets/HistorySizeWidget.cpp widgets/IncrementalSearchBar.cpp diff --git a/src/History.cpp b/src/History.cpp index 20e5f5a1..1e434a79 100644 --- a/src/History.cpp +++ b/src/History.cpp @@ -58,23 +58,6 @@ using namespace Konsole; at constant costs. */ -// History Scroll abstract base class ////////////////////////////////////// - -HistoryScroll::HistoryScroll(HistoryType *t) : - _historyType(t) -{ -} - -HistoryScroll::~HistoryScroll() -{ - delete _historyType; -} - -bool HistoryScroll::hasScroll() -{ - return true; -} - // History Scroll File ////////////////////////////////////// /* diff --git a/src/History.h b/src/History.h index 5598f7fd..19d20e85 100644 --- a/src/History.h +++ b/src/History.h @@ -33,56 +33,13 @@ // History #include "HistoryFile.h" +#include "HistoryScroll.h" // Konsole #include "Character.h" namespace Konsole { -////////////////////////////////////////////////////////////////////// -// Abstract base class for file and buffer versions -////////////////////////////////////////////////////////////////////// -class HistoryType; - -class KONSOLEPRIVATE_EXPORT HistoryScroll -{ -public: - explicit HistoryScroll(HistoryType *); - virtual ~HistoryScroll(); - - virtual bool hasScroll(); - - // access to history - virtual int getLines() = 0; - virtual int getLineLen(int lineno) = 0; - virtual void getCells(int lineno, int colno, int count, Character res[]) = 0; - virtual bool isWrappedLine(int lineNumber) = 0; - - // adding lines. - virtual void addCells(const Character a[], int count) = 0; - // convenience method - this is virtual so that subclasses can take advantage - // of QVector's implicit copying - virtual void addCellsVector(const QVector &cells) - { - addCells(cells.data(), cells.size()); - } - - virtual void addLine(bool previousWrapped = false) = 0; - - // - // FIXME: Passing around constant references to HistoryType instances - // is very unsafe, because those references will no longer - // be valid if the history scroll is deleted. - // - const HistoryType &getType() const - { - return *_historyType; - } - -protected: - HistoryType *_historyType; -}; - ////////////////////////////////////////////////////////////////////// // File-based history (e.g. file log, no limitation in length) ////////////////////////////////////////////////////////////////////// diff --git a/src/HistoryScroll.cpp b/src/HistoryScroll.cpp new file mode 100644 index 00000000..1b5a1ea2 --- /dev/null +++ b/src/HistoryScroll.cpp @@ -0,0 +1,41 @@ +/* + This file is part of Konsole, an X terminal. + Copyright 1997,1998 by Lars Doelle + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. +*/ + +// Own +#include "HistoryScroll.h" + +#include "History.h" + +using namespace Konsole; + +HistoryScroll::HistoryScroll(HistoryType *t) : + _historyType(t) +{ +} + +HistoryScroll::~HistoryScroll() +{ + delete _historyType; +} + +bool HistoryScroll::hasScroll() +{ + return true; +} diff --git a/src/HistoryScroll.h b/src/HistoryScroll.h new file mode 100644 index 00000000..a9708e9c --- /dev/null +++ b/src/HistoryScroll.h @@ -0,0 +1,80 @@ +/* + This file is part of Konsole, an X terminal. + Copyright 1997,1998 by Lars Doelle + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. +*/ + +#ifndef HISTORYSCROLL_H +#define HISTORYSCROLL_H + +#include "konsoleprivate_export.h" + +// Konsole +#include "Character.h" + +// Qt +#include + +namespace Konsole +{ +////////////////////////////////////////////////////////////////////// +// Abstract base class for file and buffer versions +////////////////////////////////////////////////////////////////////// +class HistoryType; + +class KONSOLEPRIVATE_EXPORT HistoryScroll +{ +public: + explicit HistoryScroll(HistoryType *); + virtual ~HistoryScroll(); + + virtual bool hasScroll(); + + // access to history + virtual int getLines() = 0; + virtual int getLineLen(int lineno) = 0; + virtual void getCells(int lineno, int colno, int count, Character res[]) = 0; + virtual bool isWrappedLine(int lineNumber) = 0; + + // adding lines. + virtual void addCells(const Character a[], int count) = 0; + // convenience method - this is virtual so that subclasses can take advantage + // of QVector's implicit copying + virtual void addCellsVector(const QVector &cells) + { + addCells(cells.data(), cells.size()); + } + + virtual void addLine(bool previousWrapped = false) = 0; + + // + // FIXME: Passing around constant references to HistoryType instances + // is very unsafe, because those references will no longer + // be valid if the history scroll is deleted. + // + const HistoryType &getType() const + { + return *_historyType; + } + +protected: + HistoryType *_historyType; +}; + +} + +#endif