- fix: wrong font size of exported RTF file

- fix: correct tokenize statements like "using ::memcpy";
This commit is contained in:
Roy Qu 2022-03-15 21:33:27 +08:00
parent d45c0b87b3
commit 54592276c8
9 changed files with 93 additions and 47 deletions

View File

@ -24,7 +24,10 @@ Red Panda C++ Version 1.0.0
- fix: error when delete contents in column mode on lines that has wide-chars
- fix: error when create folder in files view
- fix: "ok" button should be disabled when no template selected in new project dialog
- fix: saveas an openned project file shouldn't be treated as rename
- enhancement: auto add parentheis when complete function like MARCOs
- fix: wrong font size of exported RTF file
- fix: correct tokenize statements like "using ::memcpy";
Red Panda C++ Version 0.14.5
- fix: the "gnu c++ 20" option in compiler set options is wrong

View File

@ -1271,11 +1271,11 @@ Are you really want to continue?</oldsource>
</message>
<message>
<location filename="editor.cpp" line="258"/>
<location filename="editor.cpp" line="337"/>
<location filename="editor.cpp" line="1241"/>
<location filename="editor.cpp" line="1246"/>
<location filename="editor.cpp" line="1264"/>
<location filename="editor.cpp" line="1269"/>
<location filename="editor.cpp" line="338"/>
<location filename="editor.cpp" line="1245"/>
<location filename="editor.cpp" line="1250"/>
<location filename="editor.cpp" line="1268"/>
<location filename="editor.cpp" line="1273"/>
<source>Error</source>
<translation></translation>
</message>
@ -1289,34 +1289,34 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="1242"/>
<location filename="editor.cpp" line="1246"/>
<source>The text to be copied exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="1247"/>
<location filename="editor.cpp" line="1251"/>
<source>The text to be copied exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="1265"/>
<location filename="editor.cpp" line="1269"/>
<source>The text to be cut exceeds count limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="1270"/>
<location filename="editor.cpp" line="1274"/>
<source>The text to be cut exceeds character limit!</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="2693"/>
<location filename="editor.cpp" line="2697"/>
<source>Print Document</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="3290"/>
<location filename="editor.cpp" line="3329"/>
<location filename="editor.cpp" line="3383"/>
<location filename="editor.cpp" line="3302"/>
<location filename="editor.cpp" line="3341"/>
<location filename="editor.cpp" line="3395"/>
<source>Ctrl+click for more info</source>
<translation>Ctrl+</translation>
</message>
@ -1325,27 +1325,27 @@ Are you really want to continue?</oldsource>
<translation type="vanished">&apos;%1&apos;!</translation>
</message>
<message>
<location filename="editor.cpp" line="4118"/>
<location filename="editor.cpp" line="4130"/>
<source>astyle not found</source>
<translation>astyle程序</translation>
</message>
<message>
<location filename="editor.cpp" line="4119"/>
<location filename="editor.cpp" line="4131"/>
<source>Can&apos;t find astyle in &quot;%1&quot;.</source>
<translation>astyle程序&quot;%1&quot;.</translation>
</message>
<message>
<location filename="editor.cpp" line="4269"/>
<location filename="editor.cpp" line="4281"/>
<source>Break point condition</source>
<translation></translation>
</message>
<message>
<location filename="editor.cpp" line="4270"/>
<location filename="editor.cpp" line="4282"/>
<source>Enter the condition of the breakpoint:</source>
<translation>:</translation>
</message>
<message>
<location filename="editor.cpp" line="4485"/>
<location filename="editor.cpp" line="4497"/>
<source>Readonly</source>
<translation></translation>
</message>
@ -5473,7 +5473,7 @@ Are you really want to continue?</oldsource>
<message>
<location filename="mainwindow.cpp" line="3612"/>
<source>New Folder %1</source>
<translation type="unfinished">%1</translation>
<translation>%1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3623"/>
@ -6071,8 +6071,8 @@ Are you really want to continue?</oldsource>
<translation>%1</translation>
</message>
<message>
<location filename="widgets/newprojectdialog.cpp" line="143"/>
<location filename="widgets/newprojectdialog.cpp" line="164"/>
<location filename="widgets/newprojectdialog.cpp" line="145"/>
<location filename="widgets/newprojectdialog.cpp" line="166"/>
<source>Default</source>
<translation></translation>
</message>
@ -6767,32 +6767,40 @@ Are you really want to continue?</oldsource>
<context>
<name>ProjectTemplate</name>
<message>
<location filename="projecttemplate.cpp" line="89"/>
<location filename="projecttemplate.cpp" line="91"/>
<source>Read failed.</source>
<translation>.</translation>
</message>
<message>
<location filename="projecttemplate.cpp" line="90"/>
<location filename="projecttemplate.cpp" line="92"/>
<source>Can&apos;t read template file &apos;%1&apos;.</source>
<translation>&apos;%1&apos;.</translation>
</message>
<message>
<location filename="projecttemplate.cpp" line="96"/>
<location filename="projecttemplate.cpp" line="98"/>
<source>Can&apos;t Open Template</source>
<translation></translation>
</message>
<message>
<location filename="projecttemplate.cpp" line="99"/>
<source>Can&apos;t open template file &apos;%1&apos; for read.</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<source>Template not exist</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="projecttemplate.cpp" line="97"/>
<source>Template file &apos;%1&apos; doesn&apos;t exist.</source>
<translation>&apos;%1&apos;.</translation>
<translation type="vanished">&apos;%1&apos;.</translation>
</message>
<message>
<location filename="projecttemplate.cpp" line="105"/>
<location filename="projecttemplate.cpp" line="107"/>
<source>Old version template</source>
<translation></translation>
</message>
<message>
<location filename="projecttemplate.cpp" line="106"/>
<location filename="projecttemplate.cpp" line="108"/>
<source>Template file &apos;%1&apos; has version &apos;%2&apos;, which is unsupported.</source>
<translation>&apos;%1&apos;(%2)</translation>
</message>
@ -7569,12 +7577,12 @@ Are you really want to continue?</oldsource>
<translation></translation>
</message>
<message>
<location filename="parser/cppparser.cpp" line="980"/>
<location filename="parser/cppparser.cpp" line="991"/>
<source>constructor</source>
<translation></translation>
</message>
<message>
<location filename="parser/cppparser.cpp" line="987"/>
<location filename="parser/cppparser.cpp" line="998"/>
<source>destructor</source>
<translation></translation>
</message>

View File

@ -3022,6 +3022,11 @@ void Editor::completionInsert(bool appendFunc)
// if we are inserting a function,
if (appendFunc) {
if (statement->kind == StatementKind::skAlias) {
PStatement newStatement = mParser->findAliasedStatement(statement);
if (newStatement)
statement = newStatement;
}
if (statement->kind == StatementKind::skFunction
|| statement->kind == StatementKind::skConstructor
|| statement->kind == StatementKind::skDestructor

View File

@ -334,6 +334,8 @@ QPixmap IconsManager::getPixmapForStatement(PStatement statement)
return *(pIconsManager->getPixmap(IconsManager::PARSER_KEYWORD));
case StatementKind::skUserCodeSnippet:
return *(pIconsManager->getPixmap(IconsManager::PARSER_CODE_SNIPPET));
case StatementKind::skAlias:
return *(pIconsManager->getPixmap(IconsManager::PARSER_TYPE));
default:
break;
}

View File

@ -478,6 +478,17 @@ PStatement CppParser::findStatementOf(const QString &fileName, const QStringList
return findStatementOf(fileName,expression,findAndScanBlockAt(fileName,line));
}
PStatement CppParser::findAliasedStatement(const PStatement &statement)
{
QMutexLocker locker(&mMutex);
if (mParsing)
return PStatement();
if (!statement)
return PStatement();
return findTypeDefinitionOf(statement->fileName,statement->type, statement->parentScope.lock());
}
PStatement CppParser::findStatementStartingFrom(const QString &fileName, const QString &phrase, const PStatement& startScope)
{
PStatement scopeStatement = startScope;
@ -1802,7 +1813,8 @@ PStatement CppParser::getTypeDef(const PStatement& statement,
|| statement->kind == StatementKind::skEnumType
|| statement->kind == StatementKind::skEnumClassType) {
return statement;
} else if (statement->kind == StatementKind::skTypedef) {
} else if (statement->kind == StatementKind::skTypedef
|| statement->kind == StatementKind::skAlias) {
if (statement->type == aType) // prevent infinite loop
return statement;
PStatement result = findTypeDefinitionOf(fileName,statement->type, statement->parentScope.lock());
@ -3218,9 +3230,9 @@ void CppParser::internalParse(const QString &fileName)
//reduce memory usage
mPreprocessor.clearResult();
#ifdef QT_DEBUG
// StringsToFile(mPreprocessor.result(),"f:\\preprocess.txt");
// mPreprocessor.dumpDefinesTo("f:\\defines.txt");
// mPreprocessor.dumpIncludesListTo("f:\\includes.txt");
// StringsToFile(mPreprocessor.result(),"z:\\preprocess.txt");
// mPreprocessor.dumpDefinesTo("z:\\defines.txt");
// mPreprocessor.dumpIncludesListTo("z:\\includes.txt");
#endif
// Tokenize the preprocessed buffer file
@ -3239,9 +3251,9 @@ void CppParser::internalParse(const QString &fileName)
//reduce memory usage
internalClear();
#ifdef QT_DEBUG
// mTokenizer.dumpTokens("f:\\tokens.txt");
// mStatementList.dump("f:\\stats.txt");
// mStatementList.dumpAll("f:\\all-stats.txt");
// mTokenizer.dumpTokens("z:\\tokens.txt");
// mStatementList.dump("z:\\stats.txt");
// mStatementList.dumpAll("z:\\all-stats.txt");
#endif
//reduce memory usage
mTokenizer.reset();

View File

@ -73,6 +73,7 @@ public:
PStatement findStatementOf(const QString& fileName,
const QStringList& expression,
int line);
PStatement findAliasedStatement(const PStatement& statement);
/**
* @brief evaluate the expression

View File

@ -193,11 +193,24 @@ QString CppTokenizer::getNextToken(bool /* bSkipParenthesis */, bool bSkipArray,
case '/':
advance();
break;
case ':':
if (*(mCurrent + 1) == ':') {
countLines();
mCurrent+=2;
// Append next token to this one
result = "::"+getWord(true, bSkipArray, bSkipBlock);
done = true;
} else {
countLines();
result = *mCurrent;
advance();
done = true;
}
break;
case '{':
case '}':
case ';':
case ',':
case ':': //just return the brace or the ';'
case ',': //just return the brace or the ';'
countLines();
result = *mCurrent;
advance();
@ -333,11 +346,13 @@ QString CppTokenizer::getWord(bool bSkipParenthesis, bool bSkipArray, bool bSkip
result+=QString(mCurrent,2);
mCurrent+=2;
} else if ((*mCurrent == ':') && (*(mCurrent + 1) == ':')) {
result+=QString(mCurrent,2);
mCurrent+=2;
// Append next token to this one
QString s = getWord(bSkipParenthesis, bSkipArray, bSkipBlock);
result += s;
if (result != "using") {
result+=QString(mCurrent,2);
mCurrent+=2;
// Append next token to this one
QString s = getWord(bSkipParenthesis, bSkipArray, bSkipBlock);
result += s;
}
}
}
return result;

View File

@ -132,7 +132,7 @@ void SynExporter::SaveToFile(const QString &AFileName)
if (file.open(QIODevice::WriteOnly)) {
SaveToStream(file);
} else {
throw FileError(QObject::tr("Can't open file '%1' to write!"));
throw FileError(QObject::tr("Can't open file '%1' to write!").arg(AFileName));
}
}

View File

@ -156,7 +156,7 @@ QString SynRTFExporter::GetHeader()
Result = Result + "{\\title " + mTitle + "}}" + lineBreak();
// if (mUseBackground)
// Result = Result + { TODO } #13#10;
Result = Result + QString("\\deflang1033\\pard\\plain\\f0\\fs%1 ").arg(2 * mFont.pointSize());
Result = Result + QString("\\deflang1033\\pard\\plain\\f0\\fs%1 ").arg((int)(2 * pixelToPoint(mFont.pixelSize())));
if (mUseBackground)
Result = Result + QString("\\chshdng0\\chcbpat%1\\cb%2\\highlight%3 ")
.arg(GetColorIndex(mLastBG))