RedPanda-CPP/RedPandaIDE/qsynedit/CodeFolding.h

77 lines
2.2 KiB
C
Raw Normal View History

2021-04-29 20:54:44 +08:00
#ifndef CODEFOLDING_H
#define CODEFOLDING_H
#include <QColor>
#include <vector>
#include <memory>
2021-05-06 20:55:55 +08:00
#include <QVector>
2021-04-29 20:54:44 +08:00
2021-05-06 20:55:55 +08:00
struct SynEditFoldRegion;
typedef std::shared_ptr<SynEditFoldRegion> PSynEditFoldRegion;
2021-04-29 20:54:44 +08:00
2021-05-06 20:55:55 +08:00
class SynEditFoldRegions {
2021-04-29 20:54:44 +08:00
private:
2021-05-06 20:55:55 +08:00
std::vector<PSynEditFoldRegion> fRegions;
2021-04-29 20:54:44 +08:00
public:
int count();
int add(bool addEnding, const QChar& openSymbol, const QChar& closeSymbol, const QString& highlight);
2021-05-06 20:55:55 +08:00
PSynEditFoldRegion get(int index);
2021-04-29 20:54:44 +08:00
};
2021-05-06 20:55:55 +08:00
typedef std::shared_ptr<SynEditFoldRegions> PSynFoldRegions;
2021-04-29 20:54:44 +08:00
2021-05-06 20:55:55 +08:00
struct SynEditFoldRegion {
2021-04-29 20:54:44 +08:00
bool addEnding;
2021-05-06 20:55:55 +08:00
SynEditFoldRegions subFoldRegions;
2021-04-29 20:54:44 +08:00
QChar openSymbol;
QChar closeSymbol;
QString highlight;
};
2021-05-06 20:55:55 +08:00
struct SynEditCodeFolding {
2021-04-29 20:54:44 +08:00
bool indentGuides;
bool showCollapsedLine;
QColor collapsedLineColor;
QColor folderBarLinesColor;
QColor indentGuidesColor;
2021-05-06 20:55:55 +08:00
SynEditFoldRegions foldRegions;
SynEditCodeFolding();
2021-04-29 20:54:44 +08:00
};
2021-05-06 20:55:55 +08:00
class SynEditFoldRange;
typedef std::shared_ptr<SynEditFoldRange> PSynEditFoldRange;
class SynEditFoldRanges;
typedef std::shared_ptr<SynEditFoldRanges> PSynEditFoldRanges;
2021-04-29 20:54:44 +08:00
2021-05-06 20:55:55 +08:00
class SynEditFoldRanges{
2021-04-29 20:54:44 +08:00
public:
2021-05-06 20:55:55 +08:00
QVector<PSynEditFoldRange> ranges;
2021-04-29 20:54:44 +08:00
PSynEditFoldRange foldRange(int index);
int count();
2021-05-06 20:55:55 +08:00
SynEditFoldRanges();
2021-04-29 20:54:44 +08:00
PSynEditFoldRange addByParts(PSynEditFoldRange aParent, PSynEditFoldRanges aAllFold,
2021-05-06 20:55:55 +08:00
int aFromLine, PSynEditFoldRegion aFoldRegion, int aToLine);
2021-04-29 20:54:44 +08:00
int remove(int index);
void addObject(PSynEditFoldRange foldRange);
};
// A single fold
2021-05-06 20:55:55 +08:00
class SynEditFoldRange {
2021-04-29 20:54:44 +08:00
public:
int fromLine; // Beginning line
int toLine; // End line
int linesCollapsed; // Number of collapsed lines
2021-05-06 20:55:55 +08:00
SynEditFoldRanges subFoldRanges; // Sub fold ranges
2021-04-29 20:54:44 +08:00
bool collapsed; // Is collapsed?
PSynEditFoldRanges allFoldRanges;// TAllFoldRanges pointer
2021-05-06 20:55:55 +08:00
PSynEditFoldRegion foldRegion; // FoldRegion
2021-04-29 20:54:44 +08:00
int hintMarkLeft;
PSynEditFoldRange parent;
bool parentCollapsed();
void move(int count);
2021-05-06 20:55:55 +08:00
explicit SynEditFoldRange(PSynEditFoldRange aParent, PSynEditFoldRanges aAllFold,
int aFromLine, PSynEditFoldRegion aFoldRegion, int aToLine);
2021-04-29 20:54:44 +08:00
};
#endif // CODEFOLDING_H