- ehhancement: Show selected char counts in status bar.

- enhancement: Differentiate /* and /** when calculate auto indents.
This commit is contained in:
Roy Qu 2023-10-18 14:37:31 +08:00
parent c2421054a2
commit 38a55dcdb4
9 changed files with 459 additions and 388 deletions

View File

@ -15,6 +15,8 @@ Red Panda C++ Version 2.25
- fix: Icon position not correct under hiPDI devices.
- change: Add Mesa3D for windows opengl driver to the integrated mingw-gcc for windows 32 version.
- enhancement: After compiler settings changed, run/debug current file will auto recompile.
- ehhancement: Show selected char counts in status bar.
- enhancement: Differentiate /* and /** when calculate auto indents.
Red Panda C++ Version 2.24

View File

@ -1418,10 +1418,19 @@ void MainWindow::updateStatusbarForLineCol(const Editor* e, bool clear)
{
if (!clear && e!=nullptr) {
int col = e->charToColumn(e->caretY(),e->caretX());
QString msg = tr("Line: %1 Col: %2 Lines: %3")
QString msg;
if (e->selAvail()) {
msg = tr("Line: %1 Col: %2 (%3 chars) Lines: %4")
.arg(e->caretY())
.arg(col)
.arg(e->selText().length())
.arg(e->document()->count());
} else {
msg = tr("Line: %1 Col: %2 Lines: %3")
.arg(e->caretY())
.arg(col)
.arg(e->document()->count());
}
mFileInfoStatus->setText(msg);
} else {
mFileInfoStatus->setText("");

View File

@ -5387,6 +5387,10 @@
<source>Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line: %1 Col: %2 (%3 chars) Lines: %4</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MemoryModel</name>

File diff suppressed because it is too large Load Diff

View File

@ -5108,6 +5108,10 @@
<source>Do you want to proceed?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line: %1 Col: %2 (%3 chars) Lines: %4</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MemoryModel</name>

View File

@ -78,7 +78,7 @@ namespace QSynedit {
if (trimmedLineText.startsWith('#')
&& attr == ((CppSyntaxer *)editor->syntaxer().get())->preprocessorAttribute()) {
indentSpaces=0;
} else if (editor->syntaxer()->isLastLineCommentNotFinished(rangePreceeding.state)
} else if (editor->syntaxer()->isDocstringNotFinished(rangePreceeding.state)
) {
// last line is a not finished comment,
if (trimmedLineText.startsWith("*")) {

View File

@ -304,6 +304,35 @@ void CppSyntaxer::procCppStyleComment()
mRange.state = RangeState::rsUnknown;
}
void CppSyntaxer::procDocstring()
{
bool finishProcess = false;
mTokenId = TokenId::Comment;
if (mRun>=mLineSize) {
procNull();
return;
}
while (mRun<mLineSize) {
switch(mLine[mRun].unicode()) {
case ' ':
case '\t':
return;
case '*':
if (mRun+1<mLineSize && mLine[mRun+1] == '/') {
mRun += 2;
mRange.state = RangeState::rsUnknown;
finishProcess = true;
} else
mRun+=1;
break;
default:
mRun+=1;
}
if (finishProcess)
break;
}
}
void CppSyntaxer::procAnsiCStyleComment()
{
bool finishProcess = false;
@ -1006,8 +1035,13 @@ void CppSyntaxer::procSlash()
mRange.state = RangeState::rsAnsiC;
}
mRun += 2;
if (mRun < mLineSize)
if (mRun < mLineSize) {
if (mRange.state == RangeState::rsAnsiC && mLine[mRun] == '*' ) {
mRange.state = RangeState::rsDocstring;
procDocstring();
} else
procAnsiCStyleComment();
}
return;
case '=':
mRun+=2;
@ -1463,6 +1497,7 @@ bool CppSyntaxer::isLastLineCommentNotFinished(int state) const
{
return (state == RangeState::rsAnsiC ||
state == RangeState::rsDirectiveComment||
state == RangeState::rsDocstring ||
state == RangeState::rsCppComment);
}
@ -1471,6 +1506,11 @@ bool CppSyntaxer::isLastLineStringNotFinished(int state) const
return state == RangeState::rsString;
}
bool CppSyntaxer::isDocstringNotFinished(int state) const
{
return state == RangeState::rsDocstring;
}
bool CppSyntaxer::eol() const
{
return mTokenId == TokenId::Null;
@ -1547,6 +1587,9 @@ void CppSyntaxer::next()
//qDebug()<<"*0-0-0*";
procAnsiCStyleComment();
break;
case RangeState::rsDocstring:
procDocstring();
break;
case RangeState::rsString:
//qDebug()<<"*1-0-0*";
procString();

View File

@ -47,6 +47,7 @@ class CppSyntaxer: public Syntaxer
enum RangeState {
rsUnknown, rsAnsiC, rsDirective, rsDirectiveComment, rsString,
rsMultiLineString, rsMultiLineDirective, rsCppComment,
rsDocstring,
rsStringEscapeSeq,
rsRawString, rsSpace,rsRawStringNotEscaping,rsRawStringEnd,rsChar,
rsDefineIdentifier, rsDefineRemaining
@ -91,6 +92,7 @@ public:
private:
void procAndSymbol();
void procCppStyleComment();
void procDocstring();
void procAnsiCStyleComment();
void procAsciiChar();
void procBraceClose();
@ -178,6 +180,7 @@ public:
bool getTokenFinished() const override;
bool isLastLineCommentNotFinished(int state) const override;
bool isLastLineStringNotFinished(int state) const override;
bool isDocstringNotFinished(int state) const override;
bool eol() const override;
QString getToken() const override;
const PTokenAttribute &getTokenAttribute() const override;

View File

@ -148,6 +148,7 @@ public:
virtual bool getTokenFinished() const = 0;
virtual bool isLastLineCommentNotFinished(int state) const = 0;
virtual bool isLastLineStringNotFinished(int state) const = 0;
virtual bool isDocstringNotFinished(int state) const { return false; }
virtual bool eol() const = 0;
virtual SyntaxState getState() const = 0;
virtual QString getToken() const=0;