2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* 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 3 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, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-05-14 23:56:43 +08:00
|
|
|
#ifndef CODEFOLDING_H
|
|
|
|
#define CODEFOLDING_H
|
|
|
|
#include <QColor>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
struct SynEditFoldRegion;
|
|
|
|
typedef std::shared_ptr<SynEditFoldRegion> PSynEditFoldRegion;
|
|
|
|
|
|
|
|
class SynEditFoldRegions {
|
|
|
|
private:
|
|
|
|
std::vector<PSynEditFoldRegion> fRegions;
|
|
|
|
public:
|
|
|
|
int count();
|
2021-06-21 22:01:35 +08:00
|
|
|
PSynEditFoldRegion add(bool addEnding, const QChar& openSymbol, const QChar& closeSymbol, const QString& highlight);
|
2021-05-14 23:56:43 +08:00
|
|
|
PSynEditFoldRegion get(int index);
|
|
|
|
};
|
|
|
|
typedef std::shared_ptr<SynEditFoldRegions> PSynFoldRegions;
|
|
|
|
|
|
|
|
|
|
|
|
struct SynEditFoldRegion {
|
|
|
|
bool addEnding;
|
|
|
|
SynEditFoldRegions subFoldRegions;
|
|
|
|
QChar openSymbol;
|
|
|
|
QChar closeSymbol;
|
|
|
|
QString highlight;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SynEditCodeFolding {
|
|
|
|
bool indentGuides;
|
2021-10-20 11:14:49 +08:00
|
|
|
bool fillIndents;
|
2021-05-14 23:56:43 +08:00
|
|
|
bool showCollapsedLine;
|
|
|
|
QColor collapsedLineColor;
|
|
|
|
QColor folderBarLinesColor;
|
|
|
|
QColor indentGuidesColor;
|
|
|
|
SynEditFoldRegions foldRegions;
|
|
|
|
SynEditCodeFolding();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SynEditFoldRange;
|
|
|
|
typedef std::shared_ptr<SynEditFoldRange> PSynEditFoldRange;
|
|
|
|
class SynEditFoldRanges;
|
|
|
|
typedef std::shared_ptr<SynEditFoldRanges> PSynEditFoldRanges;
|
|
|
|
|
|
|
|
class SynEditFoldRanges{
|
|
|
|
private:
|
|
|
|
QVector<PSynEditFoldRange> mRanges;
|
|
|
|
public:
|
|
|
|
PSynEditFoldRange range(int index);
|
|
|
|
void clear();
|
2021-06-08 21:41:42 +08:00
|
|
|
int count() const;
|
2021-05-14 23:56:43 +08:00
|
|
|
SynEditFoldRanges();
|
|
|
|
PSynEditFoldRange addByParts(PSynEditFoldRange aParent, PSynEditFoldRanges aAllFold,
|
|
|
|
int aFromLine, PSynEditFoldRegion aFoldRegion, int aToLine);
|
|
|
|
|
|
|
|
void insert(int index, PSynEditFoldRange range);
|
2021-06-21 22:01:35 +08:00
|
|
|
void remove(int index);
|
2021-05-14 23:56:43 +08:00
|
|
|
void add(PSynEditFoldRange foldRange);
|
2021-06-08 21:41:42 +08:00
|
|
|
PSynEditFoldRange operator[](int index) const;
|
2021-05-14 23:56:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// A single fold
|
|
|
|
class SynEditFoldRange {
|
|
|
|
public:
|
|
|
|
int fromLine; // Beginning line
|
|
|
|
int toLine; // End line
|
|
|
|
int linesCollapsed; // Number of collapsed lines
|
|
|
|
PSynEditFoldRanges subFoldRanges; // Sub fold ranges
|
|
|
|
bool collapsed; // Is collapsed?
|
|
|
|
PSynEditFoldRanges allFoldRanges;// TAllFoldRanges pointer
|
|
|
|
PSynEditFoldRegion foldRegion; // FoldRegion
|
|
|
|
int hintMarkLeft;
|
|
|
|
PSynEditFoldRange parent;
|
|
|
|
bool parentCollapsed();
|
|
|
|
void move(int count);
|
|
|
|
explicit SynEditFoldRange(PSynEditFoldRange aParent, PSynEditFoldRanges aAllFold,
|
|
|
|
int aFromLine, PSynEditFoldRegion aFoldRegion, int aToLine);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CODEFOLDING_H
|