* work save

This commit is contained in:
royqh1979@gmail.com 2021-05-01 23:42:37 +08:00
parent 70af9a9120
commit 8feda5d762
7 changed files with 608 additions and 72 deletions

View File

@ -43,6 +43,107 @@ void InternalFillRect(QPainter *painter, const QRect &rcPaint, const QColor& col
painter->fillRect(rcPaint,color);
}
bool IsPowerOfTwo(int TabWidth) {
if (TabWidth<2)
return false;
int nW = 2;
do {
if (nW >= TabWidth)
break;
nW <<= 1;
} while (nW<0x10000);
return (nW == TabWidth);
}
QString ConvertTabs1Ex(const QString &Line, int TabWidth, bool &HasTabs) {
QString Result = Line; // increment reference count only
int nBeforeTab;
if (GetHasTabs(Line, nBeforeTab)) {
QChar* pDest;
HasTabs = true;
pDest = Result.data()+nBeforeTab+1;
// this will make a copy of Line
// We have at least one tab in the string, and the tab width is 1.
// pDest points to the first tab char. We overwrite all tabs with spaces.
while (*pDest!=0) {
if (*pDest == '\t') {
*pDest = ' ';
};
pDest++;
}
} else
HasTabs = false;
return Result;
}
QString ConvertTabs1(const QString &Line, int TabWidth) {
bool HasTabs;
return ConvertTabs1Ex(Line, TabWidth, HasTabs);
}
QString ConvertTabs2nEx(const QString &Line, int TabWidth, bool &HasTabs) {
QString Result = Line; // increment reference count only
int DestLen;
if (GetHasTabs(Line, DestLen)) {
HasTabs = true;
int pSrc = 1 + DestLen;
// We have at least one tab in the string, and the tab width equals 2^n.
// pSrc points to the first tab char in Line. We get the number of tabs
// and the length of the expanded string now.
int TabCount = 0;
int TabMask = (TabWidth - 1) ^ 0x7FFFFFFF;
do {
if (Line[pSrc] == '\t') {
DestLen = (DestLen + TabWidth) & TabMask;
TabCount++;
} else
DestLen ++ ;
} while (pSrc < Line.length());
// Set the length of the expanded string.
Result.resize(DestLen);
DestLen = 0;
pSrc = 0;
QChar * pDest = Result.data();
// We use another TabMask here to get the difference to 2^n.
TabMask = TabWidth - 1;
do {
if (Line[pSrc] == '\t') {
int i = TabWidth - (DestLen & TabMask);
DestLen += i;
//This is used for both drawing and other stuff and is meant to be #9 and not #32
do {
*pDest = '\t';
pDest ++ ;
i--;
} while (i > 0);
TabCount -- ;
if (TabCount == 0) {
do {
pSrc++ ;
*pDest = Line[pSrc];
pDest++;
} while (pSrc < Line.length());
return Result;
}
} else {
*pDest = Line[pSrc];
pDest ++ ;
DestLen ++;
}
pSrc++;
} while (pSrc < Line.length());
} else
HasTabs = false;
return Result;
}
QString ConvertTabs2n(const QString &Line, int TabWidth) {
bool HasTabs;
return ConvertTabs2nEx(Line, TabWidth, HasTabs);
}
ConvertTabsProc GetBestConvertTabsProc(int TabWidth)
{
if (TabWidth < 2)
@ -50,7 +151,7 @@ ConvertTabsProc GetBestConvertTabsProc(int TabWidth)
else if (IsPowerOfTwo(TabWidth))
return &ConvertTabs2n;
else
return @ConvertTabs;
return &ConvertTabs;
}
QString ConvertTabs(const QString &Line, int TabWidth)
@ -66,7 +167,7 @@ ConvertTabsProcEx GetBestConvertTabsProcEx(int TabWidth)
else if (IsPowerOfTwo(TabWidth))
return &ConvertTabs2nEx;
else
return @ConvertTabsEx;
return &ConvertTabsEx;
}
QString ConvertTabsEx(const QString &Line, int TabWidth, bool &HasTabs)
@ -90,7 +191,7 @@ QString ConvertTabsEx(const QString &Line, int TabWidth, bool &HasTabs)
DestLen ++;
}
pSrc++;
} while (pSrc<Line.size());
} while (pSrc<Line.length());
// Set the length of the expanded string.
Result.resize(DestLen);
DestLen = 0;
@ -111,7 +212,7 @@ QString ConvertTabsEx(const QString &Line, int TabWidth, bool &HasTabs)
pSrc++;
*pDest = Line[pSrc];
pDest++;
} while (pSrc<Line.size());
} while (pSrc<Line.length());
return Result;
}
} else {
@ -120,7 +221,7 @@ QString ConvertTabsEx(const QString &Line, int TabWidth, bool &HasTabs)
DestLen++;
}
pSrc++;
} while (pSrc<Line.size());
} while (pSrc<Line.length());
} else
HasTabs = false;
return Result;
@ -173,7 +274,7 @@ int CharIndex2CaretPos(int Index, int TabWidth, const QString &Line)
Index -= iChar;
int pNext = iChar;
while (Index > 0) {
if (pNext>=Line.size()) {
if (pNext>=Line.length()) {
Result += Index;
break;
}
@ -212,7 +313,7 @@ int CaretPos2CharIndex(int Position, int TabWidth, const QString &Line, bool &In
// for easier computation go zero-based (mod-operation)
Position -=1;
while (iPos < Position) {
if (pNext>=Line.size())
if (pNext>=Line.length())
break;
if (Line[pNext] == '\t') {
iPos+=TabWidth;
@ -235,7 +336,7 @@ int CaretPos2CharIndex(int Position, int TabWidth, const QString &Line, bool &In
int StrScanForCharInSet(const QString &Line, int Start, const QSet<QChar>& AChars)
{
for (int i=Start;i<Line.size();i++) {
for (int i=Start;i<Line.length();i++) {
if (AChars.contains(Line[i])) {
return i;
}
@ -317,17 +418,6 @@ QString DecodeString(const QString &s)
return Result;
}
var
i: Integer;
begin
Result := 1;
for i := 0 to HighlighterList.Count - 1 do
if HighlighterList[i] = Highlighter then
Exit
else if Assigned(HighlighterList[i]) and (TObject(HighlighterList[i]).ClassType = Highlighter.ClassType) then
inc(Result);
end;
bool InternalEnumHighlighterAttris(PSynHighlighter Highlighter,
bool SkipDuplicates,
HighlighterAttriProc highlighterAttriProc,

View File

@ -20,6 +20,7 @@ using IntArray = QVector<int>;
using PIntArray = std::shared_ptr<IntArray>;
int MinMax(int x, int mi, int ma);
int MulDiv(int a, int b, int c);
void SwapInt(int& l, int &r);
QPoint MaxPoint(const QPoint& P1, const QPoint& P2);
QPoint MinPoint(const QPoint& P1, const QPoint& P2);

View File

@ -1,6 +1,352 @@
#include "TextBuffer.h"
#include <stdexcept>
#include "../utils.h"
SynEditStringList::SynEditStringList()
{
mAppendNewLineAtEOF = true;
mFileFormat = SynEditFileFormat::Windows;
mIndexOfLongestLine = -1;
mUpdateCount = 0;
setTabWidth(8);
}
int SynEditStringList::parenthesisLevels(int Index)
{
if (Index>=0 && Index < mList.size()) {
return mList[Index]->fParenthesisLevel;
} else
return 0;
}
int SynEditStringList::bracketLevels(int Index)
{
if (Index>=0 && Index < mList.size()) {
return mList[Index]->fBracketLevel;
} else
return 0;
}
int SynEditStringList::braceLevels(int Index)
{
if (Index>=0 && Index < mList.size()) {
return mList[Index]->fBraceLevel;
} else
return 0;
}
QString SynEditStringList::expandedStrings(int Index)
{
if (Index>=0 && Index < mList.size()) {
if (mList[Index]->fFlags & SynEditStringFlag::sfHasNoTabs)
return mList[Index]->fString;
else
return ExpandString(Index);
} else
return QString();
}
int SynEditStringList::expandedStringLength(int Index)
{
if (Index>=0 && Index < mList.size()) {
if (mList[Index]->fFlags & sfExpandedLengthUnknown)
return ExpandString(Index).length();
else
return mList[Index]->fExpandedLength;
} else
return 0;
}
int SynEditStringList::lengthOfLongestLine()
{
if (mIndexOfLongestLine < 0) {
int MaxLen = -1;
mIndexOfLongestLine = -1;
if (mList.count() > 0 ) {
for (int i=0;i<mList.size();i++) {
int len = expandedStringLength(i);
if (len > MaxLen) {
MaxLen = len;
mIndexOfLongestLine = i;
}
}
}
}
if (mIndexOfLongestLine >= 0)
return mList[mIndexOfLongestLine]->fExpandedLength;
else
return 0;
}
SynRangeState SynEditStringList::ranges(int Index)
{
if (Index>=0 && Index < mList.size()) {
return mList[Index]->fRange;
} else
return {0,0};
}
void SynEditStringList::InsertItem(int Index, const QString &s)
{
beginUpdate();
PSynEditStringRec line;
line->fString=s;
line->fObject = nullptr;
line->fRange = {0,0};
line->fExpandedLength = -1;
line->fParenthesisLevel = 0;
line->fBracketLevel = 0;
line->fBraceLevel = 0;
line->fFlags = SynEditStringFlag::sfExpandedLengthUnknown;
mIndexOfLongestLine = -1;
mList.insert(Index,line);
endUpdate();
}
ConvertTabsProcEx SynEditStringList::getConvertTabsProc() const
{
return mConvertTabsProc;
}
bool SynEditStringList::getAppendNewLineAtEOF() const
{
return mAppendNewLineAtEOF;
}
void SynEditStringList::setAppendNewLineAtEOF(bool appendNewLineAtEOF)
{
mAppendNewLineAtEOF = appendNewLineAtEOF;
}
void SynEditStringList::setRange(int Index, SynRangeState ARange)
{
if (Index<0 || Index>=mList.count()) {
throw new std::out_of_range(QObject::tr("Index % s out of range").arg(Index).toLocal8Bit());
}
beginUpdate();
mList[Index]->fRange = ARange;
endUpdate();
}
void SynEditStringList::setParenthesisLevel(int Index, int level)
{
if (Index<0 || Index>=mList.count()) {
throw new std::out_of_range(QObject::tr("Index % s out of range").arg(Index).toLocal8Bit());
}
beginUpdate();
mList[Index]->fParenthesisLevel = level;
endUpdate();
}
void SynEditStringList::setBracketLevel(int Index, int level)
{
if (Index<0 || Index>=mList.count()) {
throw new std::out_of_range(QObject::tr("Index % s out of range").arg(Index).toLocal8Bit());
}
beginUpdate();
mList[Index]->fBracketLevel = level;
endUpdate();
}
void SynEditStringList::setBraceLevel(int Index, int level)
{
if (Index<0 || Index>=mList.count()) {
throw new std::out_of_range(QObject::tr("Index % s out of range").arg(Index).toLocal8Bit());
}
beginUpdate();
mList[Index]->fBraceLevel = level;
endUpdate();
}
QString SynEditStringList::get(int Index)
{
if (Index<0 || Index>=mList.count()) {
return QString();
}
return mList[Index]->fString;
}
int SynEditStringList::count()
{
return mList.count();
}
void *SynEditStringList::getObject(int Index)
{
if (Index<0 || Index>=mList.count()) {
return nullptr;
}
return mList[Index]->fObject;
}
QString SynEditStringList::text()
{
return GetTextStr();
}
void SynEditStringList::beginUpdate()
{
if (mUpdateCount == 0) {
SetUpdateState(true);
}
mUpdateCount++;
}
void SynEditStringList::endUpdate()
{
FUpdateCount--;
if (mUpdateCount == 0) {
SetUpdateState(false);
}
}
int SynEditStringList::tabWidth()
{
return mTabWidth;
}
void SynEditStringList::setTabWidth(int value)
{
if (value != mTabWidth) {
mTabWidth = value;
mConvertTabsProc = GetBestConvertTabsProcEx(mTabWidth);
mIndexOfLongestLine = -1;
for (PSynEditStringRec& line:mList) {
line->fExpandedLength = -1;
line->fFlags = SynEditStringFlag::sfExpandedLengthUnknown;
}
}
}
int SynEditStringList::Add(const QString &s)
{
beginUpdate();
int Result = mList.count();
InsertItem(Result, s);
emit inserted(Result,1);
endUpdate();
return Result;
}
int SynEditStringList::AddStrings(const QStringList &Strings)
{
if (Strings.count() > 0) {
mIndexOfLongestLine = -1;
beginUpdate();
auto action = finally([this]{
endUpdate();
});
int FirstAdded = mList.count();
for (const QString& s:Strings) {
Add(s);
}
emit inserted(FirstAdded,Strings.count());
}
}
int SynEditStringList::getTextLength()
{
int Result = 0;
for (const PSynEditStringRec& line: mList ) {
Result += line->fString.length();
if (mFileFormat == SynEditFileFormat::Windows) {
Result += 2;
} else {
Result += 1;
}
}
}
void SynEditStringList::Clear()
{
if (!mList.isEmpty()) {
beginUpdate();
mIndexOfLongestLine = -1;
mList.clear();
endUpdate();
}
}
void SynEditStringList::Delete(int Index)
{
if ((Index < 0) || (Index >= mList.count())) {
throw new std::out_of_range(QObject::tr("Index % s out of range").arg(Index).toLocal8Bit());
}
beginUpdate();
mList.removeAt(Index);
mIndexOfLongestLine = -1;
emit deleted(Index,1);
endUpdate();
}
QString SynEditStringList::GetTextStr()
{
QString Result;
for (PSynEditStringRec& line:mList) {
Result.append(line->fString);
switch(mFileFormat) {
case SynEditFileFormat::Linux:
Result.append('\n');
case SynEditFileFormat::Windows:
Result.append("\r\n");
case SynEditFileFormat::Mac:
Result.append("\r");
}
return Result;
}
void SynEditStringList::put(int Index, const QString &s)
{
if (Index == mList.count()) {
Add(s);
} else {
if (Index<0 || Index>=mList.count()) {
throw new std::out_of_range(QObject::tr("Index % s out of range").arg(Index).toLocal8Bit());
}
beginUpdate();
mIndexOfLongestLine = -1;
mList[Index]->fFlags = SynEditStringFlag::sfExpandedLengthUnknown;
mList[Index]->fString = s;
emit putted(Index,1);
endUpdate();
}
}
void SynEditStringList::putObject(int Index, void *AObject)
{
if (Index<0 || Index>=mList.count()) {
throw new std::out_of_range(QObject::tr("Index % s out of range").arg(Index).toLocal8Bit());
}
beginUpdate();
mList[Index]->fObject = AObject;
endUpdate();
}
void SynEditStringList::SetUpdateState(bool Updating)
{
if (Updating)
emit changing();
else
emit changed();
}
QString SynEditStringList::ExpandString(int Index)
{
QString Result("");
PSynEditStringRec line = mList[Index];
if (line->fString.isEmpty()) {
line->fFlags = SynEditStringFlag::sfHasNoTabs;
line->fExpandedLength = 0;
} else {
bool hasTabs;
Result = mConvertTabsProc(line->fString,mTabWidth,hasTabs);
line->fExpandedLength = Result.length();
if (hasTabs) {
line->fFlags = SynEditStringFlag::sfHasTabs;
} else {
line->fFlags = SynEditStringFlag::sfHasNoTabs;
}
}
return Result;
}

View File

@ -3,7 +3,9 @@
#include <QStringList>
#include "highlighter/base.h"
#include <QList>
#include <memory>
#include "MiscProcs.h"
enum SynEditStringFlag {
sfHasTabs = 0x0001,
@ -26,7 +28,7 @@ struct SynEditStringRec {
typedef std::shared_ptr<SynEditStringRec> PSynEditStringRec;
typedef std::vector<PSynEditStringRec> SynEditStringRecList;
typedef QList<PSynEditStringRec> SynEditStringRecList;
typedef std::shared_ptr<SynEditStringRecList> PSynEditStringRecList;
@ -43,12 +45,101 @@ enum class SynEditFileFormat {
};// Windows: CRLF, UNIX: LF, Mac: CR
class SynEditStringList : public QStringList
{
class SynEditStringList : public QObject
{
Q_OBJECT
public:
SynEditStringList();
explicit SynEditStringList();
int parenthesisLevels(int Index);
int bracketLevels(int Index);
int braceLevels(int Index);
QString expandedStrings(int Index);
int expandedStringLength(int Index);
int lengthOfLongestLine();
SynRangeState ranges(int Index);
void setRange(int Index, SynRangeState ARange);
void setParenthesisLevel(int Index, int level);
void setBracketLevel(int Index, int level);
void setBraceLevel(int Index, int level);
QString get(int Index);
int count();
void* getObject(int Index);
QString text();
void put(int Index, const QString& s);
void putObject(int Index, void * AObject);
void beginUpdate();
void endUpdate();
int tabWidth();
void setTabWidth(int value);
int Add(const QString& s);
int AddStrings(const QStringList& Strings);
int getTextLength();
void Clear();
void Delete(int Index);
procedure DeleteLines(Index, NumLines: integer);
procedure Exchange(Index1, Index2: integer); override;
procedure Insert(Index: integer; const S: string); override;
procedure InsertLines(Index, NumLines: integer);
procedure InsertStrings(Index: integer; NewStrings: TStrings);
procedure InsertText(Index: integer; NewText: string);
procedure LoadFromFile(const FileName: string); override;
procedure SaveToFile(const FileName: string); override;
procedure SaveToStream(Stream: TStream); override;
procedure LoadFromStream(Stream: TStream); override;
property AppendNewLineAtEOF: Boolean read fAppendNewLineAtEOF write fAppendNewLineAtEOF;
property FileFormat: TSynEditFileFormat read fFileFormat write fFileFormat;
property ExpandedStrings[Index: integer]: string read expandedStrings;
property ExpandedStringLengths[Index: integer]: integer read expandedStringLength;
property LengthOfLongestLine: integer read lengthOfLongestLine;
property Ranges[Index: integer]: TSynEditRange read GetRange write setRange;
property ParenthesisLevels[Index: integer]: integer read GetParenthesisLevel write setParenthesisLevel;
property BracketLevels[Index: integer]: integer read GetBracketLevel write setBracketLevel;
property BraceLevels[Index: integer]: integer read GetBraceLevel write setBraceLevel;
property TabWidth: integer read fTabWidth write setTabWidth;
property OnChange: TNotifyEvent read fOnChange write fOnChange;
property OnChanging: TNotifyEvent read fOnChanging write fOnChanging;
property OnCleared: TNotifyEvent read fOnCleared write fOnCleared;
property OnDeleted: TStringListChangeEvent read fOnDeleted write fOnDeleted;
property OnInserted: TStringListChangeEvent read fOnInserted
write fOnInserted;
property OnPutted: TStringListChangeEvent read fOnPutted write fOnPutted;
property ConvertTabsProc: TConvertTabsProcEx read fConvertTabsProc;
bool getAppendNewLineAtEOF() const;
void setAppendNewLineAtEOF(bool appendNewLineAtEOF);
ConvertTabsProcEx getConvertTabsProc() const;
signals:
void changed();
void changing();
void cleared();
void deleted(int index, int count);
void inserted(int index, int count);
void putted(int index, int count);
protected:
QString GetTextStr();
void SetUpdateState(bool Updating);
void InsertItem(int Index, const QString& s);
private:
SynEditStringRecList mList;
//int mCount;
//int mCapacity;
SynEditFileFormat mFileFormat;
bool mAppendNewLineAtEOF;
ConvertTabsProcEx mConvertTabsProc;
int mIndexOfLongestLine;
int mTabWidth;
int mUpdateCount;
QString ExpandString(int Index);
};

View File

@ -1,7 +1,7 @@
#include "base.h"
#include "../Constants.h"
SynHighligterBase::SynHighligterBase(QObject *parent) : QObject(parent),
SynHighlighter::SynHighlighter(QObject *parent) : QObject(parent),
mWordBreakChars{ SynWordBreakChars },
mEnabled(true),
mUpdateCount(0)
@ -9,64 +9,64 @@ SynHighligterBase::SynHighligterBase(QObject *parent) : QObject(parent),
}
const QMap<QString, PSynHighlighterAttribute>& SynHighligterBase::attributes() const
const QMap<QString, PSynHighlighterAttribute>& SynHighlighter::attributes() const
{
return mAttributes;
}
const QSet<QChar>& SynHighligterBase::wordBreakChars() const
const QSet<QChar>& SynHighlighter::wordBreakChars() const
{
return mWordBreakChars;
}
PSynHighlighterAttribute SynHighligterBase::commentAttribute() const
PSynHighlighterAttribute SynHighlighter::commentAttribute() const
{
return mCommentAttribute;
}
PSynHighlighterAttribute SynHighligterBase::identifierAttribute() const
PSynHighlighterAttribute SynHighlighter::identifierAttribute() const
{
return mIdentifierAttribute;
}
PSynHighlighterAttribute SynHighligterBase::keywordAttribute() const
PSynHighlighterAttribute SynHighlighter::keywordAttribute() const
{
return mKeywordAttribute;
}
PSynHighlighterAttribute SynHighligterBase::stringAttribute() const
PSynHighlighterAttribute SynHighlighter::stringAttribute() const
{
return mStringAttribute;
}
PSynHighlighterAttribute SynHighligterBase::whitespaceAttribute() const
PSynHighlighterAttribute SynHighlighter::whitespaceAttribute() const
{
return mWhitespaceAttribute;
}
PSynHighlighterAttribute SynHighligterBase::symbolAttribute() const
PSynHighlighterAttribute SynHighlighter::symbolAttribute() const
{
return mSymbolAttribute;
}
void SynHighligterBase::onAttributeChanged()
void SynHighlighter::onAttributeChanged()
{
setAttributesChanged();
}
void SynHighligterBase::setAttributesChanged()
void SynHighlighter::setAttributesChanged()
{
if (mUpdateCount == 0) {
emit attributesChanged();
}
}
void SynHighligterBase::beginUpdate()
void SynHighlighter::beginUpdate()
{
mUpdateCount++;
}
void SynHighligterBase::endUpdate()
void SynHighlighter::endUpdate()
{
mUpdateCount--;
if (mUpdateCount == 0) {
@ -77,48 +77,48 @@ void SynHighligterBase::endUpdate()
}
}
SynRangeState SynHighligterBase::getRangeState() const
SynRangeState SynHighlighter::getRangeState() const
{
return {0,0};
}
int SynHighligterBase::getBraceLevel() const
int SynHighlighter::getBraceLevel() const
{
return 0;
}
int SynHighligterBase::getBracketLevel() const
int SynHighlighter::getBracketLevel() const
{
return 0;
}
int SynHighligterBase::getParenthesisLevel() const
int SynHighlighter::getParenthesisLevel() const
{
return 0;
}
SynHighlighterTokenType SynHighligterBase::getTokenType()
SynHighlighterTokenType SynHighlighter::getTokenType()
{
return SynHighlighterTokenType::Default;
}
bool SynHighligterBase::isKeyword(const QString &)
bool SynHighlighter::isKeyword(const QString &)
{
return false;
}
void SynHighligterBase::nextToEol()
void SynHighlighter::nextToEol()
{
while (!eol())
next();
}
bool SynHighligterBase::isSpaceChar(const QChar &ch)
bool SynHighlighter::isSpaceChar(const QChar &ch)
{
return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n';
}
bool SynHighligterBase::isIdentChar(const QChar &ch) const
bool SynHighlighter::isIdentChar(const QChar &ch) const
{
if (ch == '_') {
return true;
@ -135,24 +135,24 @@ bool SynHighligterBase::isIdentChar(const QChar &ch) const
}
void SynHighligterBase::addAttribute(PSynHighlighterAttribute attribute)
void SynHighlighter::addAttribute(PSynHighlighterAttribute attribute)
{
mAttributes[attribute->name()]=attribute;
connect(attribute.get(), &SynHighlighterAttribute::changed,
this, &SynHighligterBase::setAttributesChanged);
this, &SynHighlighter::setAttributesChanged);
}
void SynHighligterBase::clearAttributes()
void SynHighlighter::clearAttributes()
{
mAttributes.clear();
}
int SynHighligterBase::attributesCount() const
int SynHighlighter::attributesCount() const
{
return mAttributes.size();
}
PSynHighlighterAttribute SynHighligterBase::getAttribute(const QString &name) const
PSynHighlighterAttribute SynHighlighter::getAttribute(const QString &name) const
{
auto search = mAttributes.find(name);
if (search!=mAttributes.end()) {

View File

@ -12,6 +12,7 @@ typedef struct {
int state;
int spaceState;
} SynRangeState;
typedef int SynTokenKind;
enum class SynHighlighterTokenType {
@ -94,6 +95,7 @@ public:
virtual bool isIdentChar(const QChar& ch) const;
virtual SynHighlighterClass getClass() const = 0;
virtual QString getName() const = 0;
void beginUpdate();
void endUpdate();

View File

@ -13,11 +13,28 @@ using OnCheckMarker = void (*)(PSynSchema Sender,int &StartPos, int &MarkerLen,
class SynScheme : public QObject {
Q_OBJECT
public:
explicit SynScheme(QObject& parent=nullptr);
explicit SynScheme(QObject* parent=nullptr);
QString endExpr() const;
void setEndExpr(const QString &endExpr);
QString getStartExpr() const;
void setStartExpr(const QString &value);
PSynHighlighter getHighlighter() const;
void setHighlighter(const PSynHighlighter &highlighter);
PSynHighlighterAttribute getMarkerAttribute() const;
QString getSchemeName() const;
void setSchemeName(const QString &schemeName);
int getCaseSensitive() const;
void setCaseSensitive(int caseSensitive);
private:
QString mEndExpr;
QString StartExpr;
PSynHighligterBase mHighlighter;
PSynHighlighter mHighlighter;
PSynHighlighterAttribute mMarkerAttribute;
QString mSchemeName;
int mCaseSensitive;
@ -28,29 +45,18 @@ private slots:
void MarkerAttriChanged();
};
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
published
property CaseSensitive: Boolean read fCaseSensitive write SetCaseSensitive
default True;
property StartExpr: string read fStartExpr write SetStartExpr;
property EndExpr: string read fEndExpr write SetEndExpr;
property Highlighter: TSynCustomHighlighter read fHighlighter
write SetHighlighter;
property MarkerAttri: TSynHighlighterAttributes read fMarkerAttri
write SetMarkerAttri;
property SchemeName: TComponentName read fSchemeName write fSchemeName;
property OnCheckStartMarker: TOnCheckMarker read fOnCheckStartMarker write fOnCheckStartMarker;
property OnCheckEndMarker: TOnCheckMarker read fOnCheckEndMarker write fOnCheckEndMarker;
end;
class SynHighlightComposition : public SynHighligterBase
class SynHighlightComposition : public SynHighlighter
{
Q_OBJECT
public:
explicit SynHighlightComposition(QObject *parent = nullptr);
// SynHighligterBase interface
public:
SynHighlighterClass getClass() const override;
QString getName() const override;
};
#endif // SYNHIGHLIGHTCOMPOSITION_H