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); setSelText(ch);
showCompletion(false); showCompletion(false);
handled=true; handled=true;
return;
} }
} }
@ -434,7 +435,7 @@ void Editor::keyPressEvent(QKeyEvent *event)
// Spawn code completion window if we are allowed to // Spawn code completion window if we are allowed to
// if devCodeCompletion.Enabled then begin // if devCodeCompletion.Enabled then begin
handleCodeCompletion(ch); handled = handleCodeCompletion(ch);
// end; // end;
} }
@ -1143,29 +1144,36 @@ bool Editor::handleGlobalIncludeSkip()
return false; return false;
} }
void Editor::handleCodeCompletion(QChar key) bool Editor::handleCodeCompletion(QChar key)
{ {
if (!mCompletionPopup->isEnabled()) if (!mCompletionPopup->isEnabled())
return; return false;
switch(key.unicode()) { switch(key.unicode()) {
case '.': case '.':
setSelText(key);
showCompletion(false); showCompletion(false);
break; return true;
case '>': case '>':
setSelText(key);
if ((caretX() > 1) && (lineText().length() >= 1) && if ((caretX() > 1) && (lineText().length() >= 1) &&
(lineText()[caretX() - 2] == '-')) (lineText()[caretX() - 2] == '-'))
showCompletion(false); showCompletion(false);
break; return true;
case ':': case ':':
setSelText(key);
if ((caretX() > 1) && (lineText().length() >= 1) && if ((caretX() > 1) && (lineText().length() >= 1) &&
(lineText()[caretX() - 2] == ':')) (lineText()[caretX() - 2] == ':'))
showCompletion(false); showCompletion(false);
break; return true;
case '/': case '/':
case '\\': case '\\':
setSelText(key);
if (mParser->isIncludeLine(lineText())) { if (mParser->isIncludeLine(lineText())) {
showHeaderCompletion(false); showHeaderCompletion(false);
} }
return true;
default:
return false;
} }
} }

View File

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

View File

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