work save

This commit is contained in:
royqh1979@gmail.com 2021-08-18 13:42:32 +08:00
parent 9272b767d5
commit 0c6be9b93c
2 changed files with 117 additions and 29 deletions

View File

@ -311,6 +311,7 @@ void Editor::focusOutEvent(QFocusEvent *event)
void Editor::keyPressEvent(QKeyEvent *event)
{
bool handled = false;
if (!readOnly()) {
switch (event->key()) {
case Qt::Key_Delete:
// remove completed character
@ -343,6 +344,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
}
}
}
}
if (!handled) {
SynEdit::keyPressEvent(event);
} else {

View File

@ -776,6 +776,92 @@ void CppParser::handleEnum()
mIndex++;
}
void CppParser::handleForBlock()
{
int startLine = mTokenizer[mIndex]->line;
mIndex++; // skip for/catch;
if (!(mIndex < mTokenizer.tokenCount()))
return;
int i=mIndex;
while ((i<mTokenizer.tokenCount()) && !mTokenizer[i]->text.startsWith(';'))
i++;
if (i>=mTokenizer.tokenCount())
return;
int i2 = i+1; //skip over ';' (tokenizer have change for(;;) to for(;)
if (i2>=mTokenizer.tokenCount())
return;
if (mTokenizer[i2]->text.startsWith('{')) {
mBlockBeginSkips.append(i2);
i=skipBraces(i2);
if (i==i2)
mBlockEndSkips.append(mTokenizer.tokenCount());
else
mBlockEndSkips.append(i);
} else {
i=i2;
while ((i<mTokenizer.tokenCount()) && !mTokenizer[i]->text.startsWith(';'))
i++;
mBlockEndSkips.append(i);
}
// add a block
PStatement block = addStatement(
getCurrentScope(),
mCurrentFile,
"", // override hint
"",
"",
"",
"",
startLine,
StatementKind::skBlock,
getScope(),
mClassScope,
true,
false);
addSoloScopeLevel(block,startLine);
}
void CppParser::handleKeyword()
{
// Skip
SkipType skipType = CppKeywords.value(mTokenizer[mIndex]->text,SkipType::skNone);
switch (skipType) {
case SkipType::skItself:
// skip it;
mIndex++;
break;
case SkipType::skToSemicolon:
// Skip to ;
while (mIndex < mTokenizer.tokenCount() && !mTokenizer[mIndex]->text.startsWith(';'))
mIndex++;
mIndex++;// step over
break;
case SkipType::skToColon:
// Skip to :
while (mIndex < mTokenizer.tokenCount() && !mTokenizer[mIndex]->text.startsWith(':'))
mIndex++;
break;
case SkipType::skToRightParenthesis:
// skip to )
while (mIndex < mTokenizer.tokenCount() && !mTokenizer[mIndex]->text.startsWith(')'))
mIndex++;
mIndex++; // step over
break;
case SkipType::skToLeftBrace:
// Skip to {
while (mIndex < mTokenizer.tokenCount() && !mTokenizer[mIndex]->text.startsWith('{'))
mIndex++;
break;
case SkipType::skToRightBrace:
// Skip to }
while (mIndex < mTokenizer.tokenCount() && !mTokenizer[mIndex]->text.startsWith('}'))
mIndex++;
mIndex++; // step over
break;
}
}
QString CppParser::expandMacroType(const QString &name)
{
//its done in the preprocessor