work save

This commit is contained in:
royqh1979@gmail.com 2021-08-26 20:18:20 +08:00
parent f8fae59dcc
commit ddbd302af3
3 changed files with 19 additions and 9 deletions

View File

@ -390,6 +390,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
setSelText(ch);
showCompletion(false);
handled=true;
return;
}
}
@ -434,7 +435,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
// Spawn code completion window if we are allowed to
// if devCodeCompletion.Enabled then begin
handleCodeCompletion(ch);
handled = handleCodeCompletion(ch);
// end;
}
@ -1143,29 +1144,36 @@ bool Editor::handleGlobalIncludeSkip()
return false;
}
void Editor::handleCodeCompletion(QChar key)
bool Editor::handleCodeCompletion(QChar key)
{
if (!mCompletionPopup->isEnabled())
return;
return false;
switch(key.unicode()) {
case '.':
setSelText(key);
showCompletion(false);
break;
return true;
case '>':
setSelText(key);
if ((caretX() > 1) && (lineText().length() >= 1) &&
(lineText()[caretX() - 2] == '-'))
showCompletion(false);
break;
return true;
case ':':
setSelText(key);
if ((caretX() > 1) && (lineText().length() >= 1) &&
(lineText()[caretX() - 2] == ':'))
showCompletion(false);
break;
return true;
case '/':
case '\\':
setSelText(key);
if (mParser->isIncludeLine(lineText())) {
showHeaderCompletion(false);
}
return true;
default:
return false;
}
}
@ -1683,7 +1691,7 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
}
// Get end result
result = s.mid(wordBegin + 1, wordEnd - wordBegin);
result = s.mid(wordBegin+1, wordEnd - wordBegin);
pWordBegin.Line = p.Line;
pWordBegin.Char = wordBegin+1;
pWordEnd.Line = p.Line;

View File

@ -156,7 +156,7 @@ private:
bool handleGlobalIncludeCompletion();
bool handleGlobalIncludeSkip();
void handleCodeCompletion(QChar key);
bool handleCodeCompletion(QChar key);
void initParser();
void undoSymbolCompletion(int pos);
QuoteStatus getQuoteStatus();

View File

@ -820,7 +820,7 @@ void SynEditCppHighlighter::pointProc()
if (mLine[mRun+1] == '.' && mLine[mRun+2] == '.') {
mRun+=3;
mExtTokenId = ExtTokenKind::Ellipse;
} else if (mLine[mRun+1]>=0 && mLine[mRun+1]<='9') {
} else if (mLine[mRun+1]>='0' && mLine[mRun+1]<='9') {
numberProc();
} else {
mRun+=1;
@ -1538,6 +1538,8 @@ SynHighlighterTokenType SynEditCppHighlighter::getTokenType()
return SynHighlighterTokenType::Character;
case TokenKind::Symbol:
return SynHighlighterTokenType::Symbol;
case TokenKind::Number:
return SynHighlighterTokenType::Number;
default:
return SynHighlighterTokenType::Default;
}