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 HISTORYSCROLLFILE_H
0008 #define HISTORYSCROLLFILE_H
0009 
0010 #include "konsoleprivate_export.h"
0011 
0012 // History
0013 #include "HistoryFile.h"
0014 #include "HistoryScroll.h"
0015 
0016 namespace Konsole
0017 {
0018 //////////////////////////////////////////////////////////////////////
0019 // File-based history (e.g. file log, no limitation in length)
0020 //////////////////////////////////////////////////////////////////////
0021 
0022 class KONSOLEPRIVATE_EXPORT HistoryScrollFile : public HistoryScroll
0023 {
0024 public:
0025     explicit HistoryScrollFile();
0026     ~HistoryScrollFile() override;
0027 
0028     int getLines() const override;
0029     int getMaxLines() const override;
0030     int getLineLen(const int lineno) const override;
0031     void getCells(const int lineno, const int colno, const int count, Character res[]) const override;
0032     bool isWrappedLine(const int lineno) const override;
0033     LineProperty getLineProperty(const int lineno) const override;
0034     void setLineProperty(const int lineno, LineProperty prop) override;
0035 
0036     void addCells(const Character text[], const int count) override;
0037     void addCellsMove(Character text[], const int count) override
0038     {
0039         addCells(text, count);
0040     } // TODO: optimize, if there's any point
0041     void addLine(LineProperty lineProperty = LineProperty()) override;
0042 
0043     // Modify history
0044     void removeCells() override;
0045     int reflowLines(const int columns, std::map<int, int> * = nullptr) override;
0046 
0047 private:
0048     qint64 startOfLine(const int lineno) const;
0049 
0050     mutable HistoryFile _index; // lines Row(qint64)
0051     mutable HistoryFile _cells; // text  Row(Character)
0052     mutable HistoryFile _lineflags; // flags Row(unsigned char)
0053 
0054     struct reflowData { // data to reflow lines
0055         qint64 index;
0056         LineProperty lineFlag;
0057     };
0058 };
0059 
0060 }
0061 
0062 #endif