- enhancement: correctly highlight multiline raw string literals.
- change: remove "Assembly" color scheme item (it's not used anymore).
This commit is contained in:
parent
8ad9e22976
commit
e5e322dea4
2
NEWS.md
2
NEWS.md
|
@ -16,6 +16,8 @@ Red Panda C++ Version 2.23
|
||||||
- enhancement: When deleteing files in the files/project view, try moving to the trash bin instead.
|
- enhancement: When deleteing files in the files/project view, try moving to the trash bin instead.
|
||||||
- fix: GNU assembly files (.s) are not shown in the files view.
|
- fix: GNU assembly files (.s) are not shown in the files view.
|
||||||
- fix: "typedef struct" that don't have definition of the struct is not correctly parsed.
|
- fix: "typedef struct" that don't have definition of the struct is not correctly parsed.
|
||||||
|
- enhancement: correctly highlight multiline raw string literals.
|
||||||
|
- change: remove "Assembly" color scheme item (it's not used anymore).
|
||||||
|
|
||||||
Red Panda C++ Version 2.22
|
Red Panda C++ Version 2.22
|
||||||
|
|
||||||
|
|
|
@ -429,10 +429,10 @@ void ColorManager::loadSchemesInDir(const QString &dirName, bool isBundled, bool
|
||||||
void ColorManager::initItemDefines()
|
void ColorManager::initItemDefines()
|
||||||
{
|
{
|
||||||
//Token highlight colors
|
//Token highlight colors
|
||||||
addDefine(SYNS_AttrAssembler,
|
// addDefine(SYNS_AttrAssembler,
|
||||||
QObject::tr("Assembler"),
|
// QObject::tr("Assembler"),
|
||||||
QObject::tr("Syntax"),
|
// QObject::tr("Syntax"),
|
||||||
true,true,true);
|
// true,true,true);
|
||||||
addDefine(SYNS_AttrCharacter,
|
addDefine(SYNS_AttrCharacter,
|
||||||
QObject::tr("Character"),
|
QObject::tr("Character"),
|
||||||
QObject::tr("Syntax"),
|
QObject::tr("Syntax"),
|
||||||
|
|
|
@ -3338,7 +3338,7 @@ bool CppParser::handleStatement()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppParser::handleStructs(bool isTypedef)
|
void CppParser::handleStructs(bool isTypedef)
|
||||||
{
|
{
|
||||||
bool isFriend = false;
|
bool isFriend = false;
|
||||||
QString prefix = mTokenizer[mIndex]->text;
|
QString prefix = mTokenizer[mIndex]->text;
|
||||||
if (prefix == "friend") {
|
if (prefix == "friend") {
|
||||||
|
|
|
@ -154,9 +154,6 @@ const QSet<QString> CppSyntaxer::Keywords {
|
||||||
};
|
};
|
||||||
CppSyntaxer::CppSyntaxer(): Syntaxer()
|
CppSyntaxer::CppSyntaxer(): Syntaxer()
|
||||||
{
|
{
|
||||||
mAsmAttribute = std::make_shared<TokenAttribute>(SYNS_AttrAssembler,
|
|
||||||
TokenType::Embeded);
|
|
||||||
addAttribute(mAsmAttribute);
|
|
||||||
mCharAttribute = std::make_shared<TokenAttribute>(SYNS_AttrCharacter,
|
mCharAttribute = std::make_shared<TokenAttribute>(SYNS_AttrCharacter,
|
||||||
TokenType::Character);
|
TokenType::Character);
|
||||||
addAttribute(mCharAttribute);
|
addAttribute(mCharAttribute);
|
||||||
|
@ -201,11 +198,6 @@ CppSyntaxer::CppSyntaxer(): Syntaxer()
|
||||||
resetState();
|
resetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
const PTokenAttribute &CppSyntaxer::asmAttribute() const
|
|
||||||
{
|
|
||||||
return mAsmAttribute;
|
|
||||||
}
|
|
||||||
|
|
||||||
const PTokenAttribute &CppSyntaxer::preprocessorAttribute() const
|
const PTokenAttribute &CppSyntaxer::preprocessorAttribute() const
|
||||||
{
|
{
|
||||||
return mPreprocessorAttribute;
|
return mPreprocessorAttribute;
|
||||||
|
@ -273,13 +265,7 @@ const PTokenAttribute &CppSyntaxer::localVarAttribute() const
|
||||||
|
|
||||||
CppSyntaxer::TokenId CppSyntaxer::getTokenId()
|
CppSyntaxer::TokenId CppSyntaxer::getTokenId()
|
||||||
{
|
{
|
||||||
if ((mRange.state == RangeState::rsAsm || mRange.state == RangeState::rsAsmBlock)
|
return mTokenId;
|
||||||
&& !mAsmStart && !(mTokenId == TokenId::Comment || mTokenId == TokenId::Space
|
|
||||||
|| mTokenId == TokenId::Null)) {
|
|
||||||
return TokenId::Asm;
|
|
||||||
} else {
|
|
||||||
return mTokenId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppSyntaxer::procAndSymbol()
|
void CppSyntaxer::procAndSymbol()
|
||||||
|
@ -334,11 +320,7 @@ void CppSyntaxer::procAnsiCStyleComment()
|
||||||
case '*':
|
case '*':
|
||||||
if (mRun+1<mLineSize && mLine[mRun+1] == '/') {
|
if (mRun+1<mLineSize && mLine[mRun+1] == '/') {
|
||||||
mRun += 2;
|
mRun += 2;
|
||||||
if (mRange.state == RangeState::rsAnsiCAsm) {
|
if (mRange.state == RangeState::rsDirectiveComment &&
|
||||||
mRange.state = RangeState::rsAsm;
|
|
||||||
} else if (mRange.state == RangeState::rsAnsiCAsmBlock){
|
|
||||||
mRange.state = RangeState::rsAsmBlock;
|
|
||||||
} else if (mRange.state == RangeState::rsDirectiveComment &&
|
|
||||||
mRun<mLineSize && mLine[mRun]!='\r' && mLine[mRun]!='\n') {
|
mRun<mLineSize && mLine[mRun]!='\r' && mLine[mRun]!='\n') {
|
||||||
mRange.state = RangeState::rsMultiLineDirective;
|
mRange.state = RangeState::rsMultiLineDirective;
|
||||||
} else {
|
} else {
|
||||||
|
@ -376,9 +358,7 @@ void CppSyntaxer::procBraceClose()
|
||||||
{
|
{
|
||||||
mRun += 1;
|
mRun += 1;
|
||||||
mTokenId = TokenId::Symbol;
|
mTokenId = TokenId::Symbol;
|
||||||
if (mRange.state == RangeState::rsAsmBlock) {
|
if (mRange.state == RangeState::rsDefineRemaining)
|
||||||
mRange.state = rsUnknown;
|
|
||||||
} else if (mRange.state == RangeState::rsDefineRemaining)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mRange.braceLevel -= 1;
|
mRange.braceLevel -= 1;
|
||||||
|
@ -399,10 +379,7 @@ void CppSyntaxer::procBraceOpen()
|
||||||
{
|
{
|
||||||
mRun += 1;
|
mRun += 1;
|
||||||
mTokenId = TokenId::Symbol;
|
mTokenId = TokenId::Symbol;
|
||||||
if (mRange.state == RangeState::rsAsm) {
|
if (mRange.state == RangeState::rsDefineRemaining)
|
||||||
mRange.state = RangeState::rsAsmBlock;
|
|
||||||
mAsmStart = true;
|
|
||||||
} else if (mRange.state == RangeState::rsDefineRemaining)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mRange.braceLevel += 1;
|
mRange.braceLevel += 1;
|
||||||
|
@ -950,30 +927,30 @@ void CppSyntaxer::procQuestion()
|
||||||
|
|
||||||
void CppSyntaxer::procRawString()
|
void CppSyntaxer::procRawString()
|
||||||
{
|
{
|
||||||
bool noEscaping = false;
|
|
||||||
mTokenId = TokenId::RawString;
|
mTokenId = TokenId::RawString;
|
||||||
|
|
||||||
while (mRun<mLineSize) {
|
while (mRun<mLineSize) {
|
||||||
if (!noEscaping && (mLine[mRun]=='"')) {
|
if (mRange.state!=RangeState::rsRawStringNotEscaping && (mLine[mRun]=='"')) {
|
||||||
|
mRange.state = RangeState::rsUnknown;
|
||||||
mRun+=1;
|
mRun+=1;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
switch (mLine[mRun].unicode()) {
|
switch (mLine[mRun].unicode()) {
|
||||||
case ' ':
|
case ' ':
|
||||||
case '\t':
|
case '\t':
|
||||||
return;
|
return;
|
||||||
case '(':
|
case '(':
|
||||||
if (!noEscaping)
|
if (mRange.state==RangeState::rsRawString)
|
||||||
noEscaping = true;
|
mRange.state = RangeState::rsRawStringNotEscaping;
|
||||||
break;
|
break;
|
||||||
case ')':
|
case ')':
|
||||||
if (noEscaping)
|
if (mRange.state == RangeState::rsRawStringNotEscaping)
|
||||||
noEscaping = false;
|
mRange.state = RangeState::rsRawStringEnd;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mRun+=1;
|
mRun+=1;
|
||||||
}
|
}
|
||||||
mRange.state = RangeState::rsUnknown;
|
if (mRun>=mLineSize && mRange.state != RangeState::rsRawStringNotEscaping)
|
||||||
|
mRange.state = RangeState::rsUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppSyntaxer::procRoundClose()
|
void CppSyntaxer::procRoundClose()
|
||||||
|
@ -998,8 +975,6 @@ void CppSyntaxer::procSemiColon()
|
||||||
{
|
{
|
||||||
mRun += 1;
|
mRun += 1;
|
||||||
mTokenId = TokenId::Symbol;
|
mTokenId = TokenId::Symbol;
|
||||||
if (mRange.state == RangeState::rsAsm)
|
|
||||||
mRange.state = RangeState::rsUnknown;
|
|
||||||
while (mRange.getLastIndentType() == IndentType::Statement) {
|
while (mRange.getLastIndentType() == IndentType::Statement) {
|
||||||
popIndents(IndentType::Statement);
|
popIndents(IndentType::Statement);
|
||||||
}
|
}
|
||||||
|
@ -1019,11 +994,7 @@ void CppSyntaxer::procSlash()
|
||||||
return;
|
return;
|
||||||
case '*': // C style comment
|
case '*': // C style comment
|
||||||
mTokenId = TokenId::Comment;
|
mTokenId = TokenId::Comment;
|
||||||
if (mRange.state == RangeState::rsAsm) {
|
if (mRange.state == RangeState::rsDirective) {
|
||||||
mRange.state = RangeState::rsAnsiCAsm;
|
|
||||||
} else if (mRange.state == RangeState::rsAsmBlock) {
|
|
||||||
mRange.state = RangeState::rsAnsiCAsmBlock;
|
|
||||||
} else if (mRange.state == RangeState::rsDirective) {
|
|
||||||
mRange.state = RangeState::rsDirectiveComment;
|
mRange.state = RangeState::rsDirectiveComment;
|
||||||
} else {
|
} else {
|
||||||
mRange.state = RangeState::rsAnsiC;
|
mRange.state = RangeState::rsAnsiC;
|
||||||
|
@ -1484,8 +1455,6 @@ bool CppSyntaxer::getTokenFinished() const
|
||||||
bool CppSyntaxer::isLastLineCommentNotFinished(int state) const
|
bool CppSyntaxer::isLastLineCommentNotFinished(int state) const
|
||||||
{
|
{
|
||||||
return (state == RangeState::rsAnsiC ||
|
return (state == RangeState::rsAnsiC ||
|
||||||
state == RangeState::rsAnsiCAsm ||
|
|
||||||
state == RangeState::rsAnsiCAsmBlock ||
|
|
||||||
state == RangeState::rsDirectiveComment||
|
state == RangeState::rsDirectiveComment||
|
||||||
state == RangeState::rsCppComment);
|
state == RangeState::rsCppComment);
|
||||||
}
|
}
|
||||||
|
@ -1508,8 +1477,6 @@ QString CppSyntaxer::getToken() const
|
||||||
const PTokenAttribute &CppSyntaxer::getTokenAttribute() const
|
const PTokenAttribute &CppSyntaxer::getTokenAttribute() const
|
||||||
{
|
{
|
||||||
switch (mTokenId) {
|
switch (mTokenId) {
|
||||||
case TokenId::Asm:
|
|
||||||
return mAsmAttribute;
|
|
||||||
case TokenId::Comment:
|
case TokenId::Comment:
|
||||||
return mCommentAttribute;
|
return mCommentAttribute;
|
||||||
case TokenId::Directive:
|
case TokenId::Directive:
|
||||||
|
@ -1555,17 +1522,18 @@ int CppSyntaxer::getTokenPos()
|
||||||
|
|
||||||
void CppSyntaxer::next()
|
void CppSyntaxer::next()
|
||||||
{
|
{
|
||||||
mAsmStart = false;
|
|
||||||
mTokenPos = mRun;
|
mTokenPos = mRun;
|
||||||
do {
|
do {
|
||||||
|
if (mRun>=mLineSize) {
|
||||||
|
procNull();
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (mRun<mLineSize && isSpaceChar(mLine[mRun])) {
|
if (mRun<mLineSize && isSpaceChar(mLine[mRun])) {
|
||||||
procSpace();
|
procSpace();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (mRange.state) {
|
switch (mRange.state) {
|
||||||
case RangeState::rsAnsiC:
|
case RangeState::rsAnsiC:
|
||||||
case RangeState::rsAnsiCAsm:
|
|
||||||
case RangeState::rsAnsiCAsmBlock:
|
|
||||||
case RangeState::rsDirectiveComment:
|
case RangeState::rsDirectiveComment:
|
||||||
//qDebug()<<"*0-0-0*";
|
//qDebug()<<"*0-0-0*";
|
||||||
procAnsiCStyleComment();
|
procAnsiCStyleComment();
|
||||||
|
@ -1610,6 +1578,12 @@ void CppSyntaxer::next()
|
||||||
//qDebug()<<"*9-0-0*";
|
//qDebug()<<"*9-0-0*";
|
||||||
procDefineRemaining();
|
procDefineRemaining();
|
||||||
break;
|
break;
|
||||||
|
case RangeState::rsRawStringNotEscaping:
|
||||||
|
case RangeState::rsRawString:
|
||||||
|
case RangeState::rsRawStringEnd:
|
||||||
|
//qDebug()<<"*9-0-0*";
|
||||||
|
procRawString();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
//qDebug()<<"*a-0-0*";
|
//qDebug()<<"*a-0-0*";
|
||||||
mRange.state = RangeState::rsUnknown;
|
mRange.state = RangeState::rsUnknown;
|
||||||
|
@ -1619,6 +1593,7 @@ void CppSyntaxer::next()
|
||||||
} else if (mRun+1<mLineSize && mLine[mRun] == 'R' && mLine[mRun+1] == '"') {
|
} else if (mRun+1<mLineSize && mLine[mRun] == 'R' && mLine[mRun+1] == '"') {
|
||||||
//qDebug()<<"*c-0-0*";
|
//qDebug()<<"*c-0-0*";
|
||||||
mRun+=2;
|
mRun+=2;
|
||||||
|
mRange.state = RangeState::rsRawString;
|
||||||
procRawString();
|
procRawString();
|
||||||
} else if (mRun+1<mLineSize && (mLine[mRun] == 'L' || mLine[mRun] == 'u' || mLine[mRun]=='U') && mLine[mRun+1]=='\"') {
|
} else if (mRun+1<mLineSize && (mLine[mRun] == 'L' || mLine[mRun] == 'u' || mLine[mRun]=='U') && mLine[mRun+1]=='\"') {
|
||||||
//qDebug()<<"*d-0-0*";
|
//qDebug()<<"*d-0-0*";
|
||||||
|
@ -1680,7 +1655,6 @@ void CppSyntaxer::resetState()
|
||||||
mRange.indents.clear();
|
mRange.indents.clear();
|
||||||
mRange.lastUnindent=IndentInfo{IndentType::None,0};
|
mRange.lastUnindent=IndentInfo{IndentType::None,0};
|
||||||
mRange.hasTrailingSpaces = false;
|
mRange.hasTrailingSpaces = false;
|
||||||
mAsmStart = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CppSyntaxer::languageName()
|
QString CppSyntaxer::languageName()
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace QSynedit {
|
||||||
class CppSyntaxer: public Syntaxer
|
class CppSyntaxer: public Syntaxer
|
||||||
{
|
{
|
||||||
enum class TokenId {
|
enum class TokenId {
|
||||||
Asm,
|
|
||||||
Comment,
|
Comment,
|
||||||
Directive,
|
Directive,
|
||||||
Identifier,
|
Identifier,
|
||||||
|
@ -46,8 +45,7 @@ class CppSyntaxer: public Syntaxer
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RangeState {
|
enum RangeState {
|
||||||
rsUnknown, rsAnsiC, rsAnsiCAsm, rsAnsiCAsmBlock, rsAsm,
|
rsUnknown, rsAnsiC, rsDirective, rsDirectiveComment, rsString,
|
||||||
rsAsmBlock, rsDirective, rsDirectiveComment, rsString,
|
|
||||||
rsMultiLineString, rsMultiLineDirective, rsCppComment,
|
rsMultiLineString, rsMultiLineDirective, rsCppComment,
|
||||||
rsStringEscapeSeq,
|
rsStringEscapeSeq,
|
||||||
rsRawString, rsSpace,rsRawStringNotEscaping,rsRawStringEnd,rsChar,
|
rsRawString, rsSpace,rsRawStringNotEscaping,rsRawStringEnd,rsChar,
|
||||||
|
@ -59,8 +57,6 @@ public:
|
||||||
CppSyntaxer(const CppSyntaxer&)=delete;
|
CppSyntaxer(const CppSyntaxer&)=delete;
|
||||||
CppSyntaxer operator=(const CppSyntaxer&)=delete;
|
CppSyntaxer operator=(const CppSyntaxer&)=delete;
|
||||||
|
|
||||||
const PTokenAttribute &asmAttribute() const;
|
|
||||||
|
|
||||||
const PTokenAttribute &preprocessorAttribute() const;
|
const PTokenAttribute &preprocessorAttribute() const;
|
||||||
|
|
||||||
const PTokenAttribute &invalidAttribute() const;
|
const PTokenAttribute &invalidAttribute() const;
|
||||||
|
@ -148,7 +144,6 @@ private:
|
||||||
void pushIndents(IndentType indentType, int line=-1);
|
void pushIndents(IndentType indentType, int line=-1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mAsmStart;
|
|
||||||
SyntaxState mRange;
|
SyntaxState mRange;
|
||||||
// SynRangeState mSpaceRange;
|
// SynRangeState mSpaceRange;
|
||||||
QString mLine;
|
QString mLine;
|
||||||
|
@ -164,7 +159,6 @@ private:
|
||||||
|
|
||||||
QSet<QString> mCustomTypeKeywords;
|
QSet<QString> mCustomTypeKeywords;
|
||||||
|
|
||||||
PTokenAttribute mAsmAttribute;
|
|
||||||
PTokenAttribute mPreprocessorAttribute;
|
PTokenAttribute mPreprocessorAttribute;
|
||||||
PTokenAttribute mInvalidAttribute;
|
PTokenAttribute mInvalidAttribute;
|
||||||
PTokenAttribute mNumberAttribute;
|
PTokenAttribute mNumberAttribute;
|
||||||
|
|
Loading…
Reference in New Issue