diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index ed05d697..f6b56e7e 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -311,37 +311,39 @@ void Editor::focusOutEvent(QFocusEvent *event) void Editor::keyPressEvent(QKeyEvent *event) { bool handled = false; - switch (event->key()) { - case Qt::Key_Delete: - // remove completed character - //fLastIdCharPressed:=0; - undoSymbolCompletion(caretX()); - break;; - case Qt::Key_Backspace: - // remove completed character - //fLastIdCharPressed:=0; - undoSymbolCompletion(caretX()-1); - break;; - default: { - QString t = event->text(); - if (!t.isEmpty()) { - QChar ch = t[0]; - switch (ch.unicode()) { - case '"': - case '\'': - case '(': - case ')': - case '{': - case '}': - case '[': - case ']': - case '<': - case '>': - case '*': - handled = handleSymbolCompletion(ch); + if (!readOnly()) { + switch (event->key()) { + case Qt::Key_Delete: + // remove completed character + //fLastIdCharPressed:=0; + undoSymbolCompletion(caretX()); + break;; + case Qt::Key_Backspace: + // remove completed character + //fLastIdCharPressed:=0; + undoSymbolCompletion(caretX()-1); + break;; + default: { + QString t = event->text(); + if (!t.isEmpty()) { + QChar ch = t[0]; + switch (ch.unicode()) { + case '"': + case '\'': + case '(': + case ')': + case '{': + case '}': + case '[': + case ']': + case '<': + case '>': + case '*': + handled = handleSymbolCompletion(ch); + } } } - } + } } if (!handled) { SynEdit::keyPressEvent(event); diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 59556aa7..eb7aa89e 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -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 ((itext.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 ((itext.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