- enhancement: set caret to the corresponding line in the editor after "run"/"generate assembly"

- fix: syntax highlighting for cpp style line comment is not correct.
This commit is contained in:
Roy Qu 2023-01-12 21:58:04 +08:00
parent 7503f553fc
commit d8fae209c6
3 changed files with 44 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Red Panda C++ Version 2.9
- enhancement: set caret to the corresponding line in the editor after "run"/"generate assembly"
- fix: syntax highlighting for cpp style line comment is not correct.
Red Panda C++ Version 2.8 Red Panda C++ Version 2.8
- fix: Crash when editing makefile - fix: Crash when editing makefile

View File

@ -5541,8 +5541,33 @@ void MainWindow::onCompileFinished(QString filename, bool isCheckSyntax)
if (!mCompileSuccessionTask->isExecutable) { if (!mCompileSuccessionTask->isExecutable) {
switch (mCompileSuccessionTask->type) { switch (mCompileSuccessionTask->type) {
case MainWindow::CompileSuccessionTaskType::RunNormal: case MainWindow::CompileSuccessionTaskType::RunNormal:
if (fileExists(mCompileSuccessionTask->execName)) if (fileExists(mCompileSuccessionTask->execName)) {
openFile(mCompileSuccessionTask->execName); Editor * editor = openFile(mCompileSuccessionTask->execName);
if (e && editor) {
int line = e->caretY();
int startLine = 1;
QString s = " # "+e->filename()+":";
for(int i=0;i<editor->document()->count();i++) {
QString t=editor->document()->getLine(i);
if (t.startsWith(s,PATH_SENSITIVITY)) {
t=t.mid(s.length());
int pos = t.indexOf(":");
if (pos>0) {
QString numstring=t.mid(0,pos);
bool isOk;
int l=numstring.toInt(&isOk);
if (isOk) {
if (l<=line)
startLine=i+1;
if (l>=line)
break;
}
}
}
}
editor->setCaretPositionAndActivate(startLine,1);
}
}
break; break;
case MainWindow::CompileSuccessionTaskType::RunProblemCases: case MainWindow::CompileSuccessionTaskType::RunProblemCases:
case MainWindow::CompileSuccessionTaskType::RunCurrentProblemCase: case MainWindow::CompileSuccessionTaskType::RunCurrentProblemCase:

View File

@ -289,6 +289,10 @@ void CppSyntaxer::andSymbolProc()
void CppSyntaxer::ansiCppProc() void CppSyntaxer::ansiCppProc()
{ {
if (mRun>=mLineSize) {
nullProc();
return;
}
mTokenId = TokenId::Comment; mTokenId = TokenId::Comment;
while (mRun<mLineSize) { while (mRun<mLineSize) {
if (isSpaceChar(mLine[mRun])) if (isSpaceChar(mLine[mRun]))
@ -933,7 +937,10 @@ void CppSyntaxer::slashProc()
case '/': // Cpp style comment case '/': // Cpp style comment
mTokenId = TokenId::Comment; mTokenId = TokenId::Comment;
mRun+=2; mRun+=2;
mRange.state = RangeState::rsCppComment; if (mRun<mLineSize)
mRange.state = RangeState::rsCppComment;
else
mRange.state = RangeState::rsUnknown;
return; return;
case '*': // C style comment case '*': // C style comment
mTokenId = TokenId::Comment; mTokenId = TokenId::Comment;
@ -976,8 +983,11 @@ void CppSyntaxer::spaceProc()
mTokenId = TokenId::Space; mTokenId = TokenId::Space;
while (mRun<mLineSize && mLine[mRun]>=1 && mLine[mRun]<=32) while (mRun<mLineSize && mLine[mRun]>=1 && mLine[mRun]<=32)
mRun+=1; mRun+=1;
if (mRun>=mLineSize) if (mRun>=mLineSize) {
mRange.hasTrailingSpaces = true; mRange.hasTrailingSpaces = true;
if (mRange.state==RangeState::rsCppComment)
mRange.state = RangeState::rsUnknown;
}
} }
void CppSyntaxer::squareCloseProc() void CppSyntaxer::squareCloseProc()