- enhancement: better support of ligatures

- enhancement: use the expression evaluation logic to handle "goto declaration"/"goto definition"
This commit is contained in:
Roy Qu 2022-03-04 16:40:16 +08:00
parent df7aba015d
commit 96de964484
3 changed files with 30 additions and 23 deletions

View File

@ -11,6 +11,8 @@ Red Panda C++ Version 0.14.5
- enhancement: group undo will stop at spaces
- fix: menu font size is wrong when dpi changed
- enhancement: better processing of symbol completion
- enhancement: better support of ligatures
- enhancement: use the expression evaluation logic to handle "goto declaration"/"goto definition"
Red Panda C++ Version 0.14.4
- enhancement: git - log

View File

@ -1120,7 +1120,6 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
QString s = lines()->getString(p.Line - 1);
if (mParser->isIncludeLine(s)) {
QString filename = mParser->getHeaderFileName(mFilename,s);
qDebug()<<filename;
Editor * e = pMainWindow->editorList()->getEditorByFilename(filename);
if (e) {
e->setCaretPositionAndActivate(1,1);
@ -3658,17 +3657,25 @@ void Editor::setInProject(bool newInProject)
void Editor::gotoDeclaration(const BufferCoord &pos)
{
// Exit early, don't bother creating a stream (which is slow)
BufferCoord pBeginPos, pEndPos;
QString phrase = getWordAtPosition(this,pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
if (phrase.isEmpty())
if (!parser())
return;
// Exit early, don't bother creating a stream (which is slow)
QStringList expression = getExpressionAtPosition(pos);
PStatement statement = mParser->findStatementOf(
mFilename,phrase,pos.Line);
// Find it's definition
PStatement statement = parser()->findStatementOf(
filename(),
expression,
pos.Line);
// QString phrase = getWordAtPosition(this,pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
// if (phrase.isEmpty())
// return;
// PStatement statement = mParser->findStatementOf(
// mFilename,phrase,pos.Line);
if (!statement) {
pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
// pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
return;
}
QString filename;
@ -3688,17 +3695,16 @@ void Editor::gotoDeclaration(const BufferCoord &pos)
void Editor::gotoDefinition(const BufferCoord &pos)
{
// Exit early, don't bother creating a stream (which is slow)
BufferCoord pBeginPos, pEndPos;
QString phrase = getWordAtPosition(this,pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
if (phrase.isEmpty())
return;
QStringList expression = getExpressionAtPosition(pos);
PStatement statement = mParser->findStatementOf(
mFilename,phrase,pos.Line);
// Find it's definition
PStatement statement = parser()->findStatementOf(
filename(),
expression,
pos.Line);
if (!statement) {
pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
// pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
return;
}
QString filename;

View File

@ -400,7 +400,6 @@ void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int Col
} else {
int tokenColLen=0;
startPaint = false;
bool isAscii = true;
for (int i=0;i<Token.length();i++) {
int charCols=0;
QString textToPaint = Token[i];
@ -419,24 +418,24 @@ void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int Col
break;
//painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent()*edit->dpiFactor() , Token[i]);
if (startPaint) {
if (Token[i].unicode()<255)
isAscii=true;
bool drawed = false;
if (painter->fontInfo().fixedPitch()
&& edit->mOptions.testFlag(eoLigatureSupport)
&& isAscii) {
&& !Token[i].isSpace()
&& (Token[i].unicode()<=0xFF)) {
while(i+1<Token.length()) {
if (Token[i+1].unicode()>=255)
if (Token[i+1].unicode()>0xFF || Token[i+1].isSpace())
break;
i+=1;
charCols += edit->charColumns(Token[i]);
textToPaint+=Token[i];
}
painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent() , textToPaint);
qDebug()<<textToPaint;
drawed = true;
}
if (!drawed) {
if (Token[i].unicode()<=255)
if (Token[i].unicode()<=0xFF)
painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent() , Token[i]);
else {
painter->setFont(fontForNonAscii);