File indexing completed on 2024-05-05 05:53:47
0001 /* 0002 SPDX-FileCopyrightText: 1997, 1998 Lars Doelle <lars.doelle@on-line.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef HISTORYSCROLL_H 0008 #define HISTORYSCROLL_H 0009 0010 // STD 0011 #include <memory> 0012 0013 #include "konsoleprivate_export.h" 0014 0015 // Konsole 0016 #include "../characters/Character.h" 0017 0018 // Qt 0019 #include <QVector> 0020 0021 namespace Konsole 0022 { 0023 ////////////////////////////////////////////////////////////////////// 0024 // Abstract base class for file and buffer versions 0025 ////////////////////////////////////////////////////////////////////// 0026 class HistoryType; 0027 0028 class KONSOLEPRIVATE_EXPORT HistoryScroll 0029 { 0030 public: 0031 explicit HistoryScroll(HistoryType *); 0032 virtual ~HistoryScroll(); 0033 0034 virtual bool hasScroll() const; 0035 0036 // access to history 0037 virtual int getLines() const = 0; 0038 virtual int getMaxLines() const = 0; 0039 virtual int getLineLen(const int lineno) const = 0; 0040 virtual void getCells(const int lineno, const int colno, const int count, Character res[]) const = 0; 0041 virtual bool isWrappedLine(const int lineNumber) const = 0; 0042 virtual LineProperty getLineProperty(const int lineno) const = 0; 0043 virtual void setLineProperty(const int lineno, LineProperty prop) = 0; 0044 0045 // adding lines. 0046 virtual void addCells(const Character a[], const int count) = 0; 0047 virtual void addCellsMove(Character a[], const int count) = 0; 0048 // convenience method - this is virtual so that subclasses can take advantage 0049 // of QVector's implicit copying 0050 virtual void addCellsVector(const QVector<Character> &cells) 0051 { 0052 addCells(cells.data(), cells.size()); 0053 } 0054 0055 virtual void addLine(const LineProperty lineProperty = LineProperty()) = 0; 0056 0057 // modify history 0058 virtual void removeCells() = 0; 0059 virtual int reflowLines(const int columns, std::map<int, int> *deltas = nullptr) = 0; 0060 0061 // 0062 // FIXME: Passing around constant references to HistoryType instances 0063 // is very unsafe, because those references will no longer 0064 // be valid if the history scroll is deleted. 0065 // 0066 const HistoryType &getType() const 0067 { 0068 return *_historyType; 0069 } 0070 0071 protected: 0072 std::unique_ptr<HistoryType> _historyType; 0073 const int MAX_REFLOW_LINES = 20000; 0074 }; 0075 0076 } 0077 0078 #endif