work save
This commit is contained in:
parent
9272b767d5
commit
0c6be9b93c
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue