diff --git a/NEWS.md b/NEWS.md index 4140fab4..f62f9c52 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,11 +8,15 @@ Red Panda C++ Version 1.5 - change: clear tools output panel when start to compile - change: don't show syntax check messages in the tools output panel (to reduce longtime memory usage) - fix: minor memory leaks when set itemmodels - - fix: thread for parsing doesn't correctly released when parsing finished ( so and the parser) + - fix: threads for code parsing doesn't correctly released when parsing finished ( so and the parsers they use) - enhancement: save project's bookmark in it's own bookmark file - enhancement: project and non-project files use different bookmark view (auto switch when switch editors) - enhancement: auto merge when save bookmarks. - enhancement: add option "max undo memory usage" in the options / editor / misc page + - fix: icons in options dialogs not correctly updated when change icon set + - enhancement: set compilation stage in the options / compiler set pages + - enhancement: set custom compilation output suffix in the options / compiler set pages + Red Panda C++ Version 1.4 diff --git a/RedPandaIDE/compiler/compilerinfo.cpp b/RedPandaIDE/compiler/compilerinfo.cpp index 2ff153a2..0fc6f3da 100644 --- a/RedPandaIDE/compiler/compilerinfo.cpp +++ b/RedPandaIDE/compiler/compilerinfo.cpp @@ -160,15 +160,15 @@ void CompilerInfo::prepareCompilerOptions() // Output - groupName = QObject::tr("Output"); - addOption(CC_CMD_OPT_VERBOSE_ASM, QObject::tr("Put comments in generated assembly code (-fverbose-asm)"), groupName, true, true, false, "-fverbose-asm"); - addOption(CC_CMD_OPT_ONLY_GEN_ASM_CODE, QObject::tr("Do not assemble, compile and generate the assemble code (-S)"), groupName, true, true, false, "-S"); - addOption(CC_CMD_OPT_STOP_AFTER_PREPROCESSING, QObject::tr("Do not compile, stop after the preprocessing stage (-E)"), groupName, true, true, false, "-E"); - addOption(CC_CMD_OPT_USE_PIPE, QObject::tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, "-pipe"); + //groupName = QObject::tr("Output"); + //addOption(CC_CMD_OPT_VERBOSE_ASM, QObject::tr("Put comments in generated assembly code (-fverbose-asm)"), groupName, true, true, false, "-fverbose-asm"); + //addOption(CC_CMD_OPT_ONLY_GEN_ASM_CODE, QObject::tr("Do not assemble, compile and generate the assemble code (-S)"), groupName, true, true, false, "-S"); + //addOption(CC_CMD_OPT_STOP_AFTER_PREPROCESSING, QObject::tr("Do not compile, stop after the preprocessing stage (-E)"), groupName, true, true, false, "-E"); // Linker groupName = QObject::tr("Linker"); - addOption(LINK_CMD_OPT_LINK_OBJC, QObject::tr("Link an Objective C program (-lobjc)"), groupName, false, false, true, "-lobjc"); + addOption(CC_CMD_OPT_USE_PIPE, QObject::tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, "-pipe"); + //addOption(LINK_CMD_OPT_LINK_OBJC, QObject::tr("Link an Objective C program (-lobjc)"), groupName, false, false, true, "-lobjc"); addOption(LINK_CMD_OPT_NO_LINK_STDLIB,QObject::tr("Do not use standard system libraries (-nostdlib)"), groupName, false, false, true, "-nostdlib"); addOption(LINK_CMD_OPT_NO_CONSOLE, QObject::tr("Do not create a console window (-mwindows)"), groupName,false, false, true, "-mwindows"); addOption(LINK_CMD_OPT_STRIP_EXE, QObject::tr("Strip executable (-s)"), groupName, false, false, true, "-s"); diff --git a/RedPandaIDE/compiler/filecompiler.cpp b/RedPandaIDE/compiler/filecompiler.cpp index 8b436b2c..043b385f 100644 --- a/RedPandaIDE/compiler/filecompiler.cpp +++ b/RedPandaIDE/compiler/filecompiler.cpp @@ -41,12 +41,23 @@ bool FileCompiler::prepareForCompile() FileType fileType = getFileType(mFilename); mArguments= QString(" \"%1\"").arg(mFilename); if (!mOnlyCheckSyntax) { - if (compilerSet()->getCompileOptionValue(CC_CMD_OPT_STOP_AFTER_PREPROCESSING)==COMPILER_OPTION_ON) - mOutputFile=changeFileExt(mFilename,"expanded.cpp"); - else if (compilerSet()->getCompileOptionValue(CC_CMD_OPT_ONLY_GEN_ASM_CODE)==COMPILER_OPTION_ON) - mOutputFile=changeFileExt(mFilename,"s"); - else - mOutputFile = getCompiledExecutableName(mFilename); + switch(compilerSet()->compilationStage()) { + case Settings::CompilerSet::CompilationStage::PreprocessingOnly: + mOutputFile=changeFileExt(mFilename,compilerSet()->preprocessingSuffix()); + mArguments+=" -E"; + break; + case Settings::CompilerSet::CompilationStage::CompilationProperOnly: + mOutputFile=changeFileExt(mFilename,compilerSet()->compilationProperSuffix()); + mArguments+=" -S -fverbose-asm"; + break; + case Settings::CompilerSet::CompilationStage::AssemblingOnly: + mOutputFile=changeFileExt(mFilename,compilerSet()->assemblingSuffix()); + mArguments+=" -c"; + break; + case Settings::CompilerSet::CompilationStage::GenerateExecutable: + mOutputFile = changeFileExt(mFilename,compilerSet()->executableSuffix()); + } + mArguments+=QString(" -o \"%1\"").arg(mOutputFile); //remove the old file if it exists @@ -97,7 +108,8 @@ bool FileCompiler::prepareForCompile() bool FileCompiler::prepareForRebuild() { - QString exeName = getCompiledExecutableName(mFilename); + QString exeName=compilerSet()->getCompileOptionValue(mFilename); + QFile file(exeName); if (file.exists() && !file.remove()) { diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 90ff47a2..cc18691b 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1648,6 +1648,7 @@ bool MainWindow::compile(bool rebuild) mProject->buildPrivateResource(); if (mCompileSuccessionTask) { mCompileSuccessionTask->execName = mProject->executable(); + mCompileSuccessionTask->isExecutable = true; } stretchMessagesPanel(true); ui->tabMessages->setCurrentWidget(ui->tabToolsOutput); @@ -1663,7 +1664,14 @@ bool MainWindow::compile(bool rebuild) return false; } if (mCompileSuccessionTask) { - mCompileSuccessionTask->execName = getCompiledExecutableName(editor->filename()); + Settings::PCompilerSet compilerSet =pSettings->compilerSets().defaultSet(); + if (compilerSet) { + mCompileSuccessionTask->execName = compilerSet->getOutputFilename(editor->filename()); + mCompileSuccessionTask->isExecutable = compilerSet->isOutputExecutable(); + } else { + mCompileSuccessionTask->execName = changeFileExt(editor->filename(),DEFAULT_EXECUTABLE_SUFFIX); + mCompileSuccessionTask->isExecutable = true; + } } stretchMessagesPanel(true); ui->tabMessages->setCurrentWidget(ui->tabToolsOutput); @@ -1761,6 +1769,7 @@ void MainWindow::runExecutable(RunType runType) mCompileSuccessionTask=std::make_shared(); mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal; mCompileSuccessionTask->execName=mProject->executable(); + mCompileSuccessionTask->isExecutable=true; mCompileSuccessionTask->binDirs=binDirs; compile(); return; @@ -1776,8 +1785,27 @@ void MainWindow::runExecutable(RunType runType) return; } QStringList binDirs = getDefaultCompilerSetBinDirs(); - QString exeName= getCompiledExecutableName(editor->filename()); - runExecutable(exeName,editor->filename(),runType,binDirs); + QString exeName; + Settings::PCompilerSet compilerSet =pSettings->compilerSets().defaultSet(); + bool isExecutable; + if (compilerSet) { + exeName = compilerSet->getOutputFilename(editor->filename()); + isExecutable = compilerSet->compilationStage()==Settings::CompilerSet::CompilationStage::GenerateExecutable; + } else { + exeName = changeFileExt(editor->filename(), DEFAULT_EXECUTABLE_SUFFIX); + isExecutable = true; + } + if (isExecutable) + runExecutable(exeName,editor->filename(),runType,binDirs); + else if (runType==RunType::Normal) { + if (fileExists(exeName)) + openFile(exeName); + } else { + QMessageBox::critical(this,tr("Wrong Compiler Settings"), + tr("Compiler is set not to generate executable.")+"

" + +tr("We need the executabe to run problem case.")); + return; + } } } } @@ -1821,6 +1849,7 @@ void MainWindow::debug() mCompileSuccessionTask=std::make_shared(); mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug; mCompileSuccessionTask->execName = mProject->executable(); + mCompileSuccessionTask->isExecutable = true; mCompileSuccessionTask->binDirs = binDirs; compile(); @@ -1837,6 +1866,7 @@ void MainWindow::debug() mCompileSuccessionTask=std::make_shared(); mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug; mCompileSuccessionTask->execName = mProject->executable(); + mCompileSuccessionTask->isExecutable = true; mCompileSuccessionTask->binDirs = binDirs; compile(); } @@ -1851,6 +1881,7 @@ void MainWindow::debug() mCompileSuccessionTask=std::make_shared(); mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug; mCompileSuccessionTask->execName = mProject->executable(); + mCompileSuccessionTask->isExecutable = true; mCompileSuccessionTask->binDirs = binDirs; compile(); return; @@ -1897,9 +1928,7 @@ void MainWindow::debug() pSettings->debugger().skipProjectLibraries()); break; case CompileTarget::File: { - if (pSettings->compilerSets().defaultSet()) { - binDirs = pSettings->compilerSets().defaultSet()->binDirs(); - } + binDirs = compilerSet->binDirs(); // Check if we enabled proper options debugEnabled = compilerSet->getCompileOptionValue(CC_CMD_OPT_DEBUG_INFO) == COMPILER_OPTION_ON; @@ -1934,7 +1963,25 @@ void MainWindow::debug() } // Did we compiled? - filePath = getCompiledExecutableName(e->filename()); + Settings::PCompilerSet compilerSet =pSettings->compilerSets().defaultSet(); + bool isExecutable; + if (compilerSet) { + filePath = compilerSet->getOutputFilename(e->filename()); + isExecutable = compilerSet->compilationStage()==Settings::CompilerSet::CompilationStage::GenerateExecutable; + } else { + filePath = changeFileExt(e->filename(), DEFAULT_EXECUTABLE_SUFFIX); + isExecutable = true; + } + if (!isExecutable) { + QMessageBox::warning( + this, + tr("Wrong Compiler Settings"), + tr("Compiler is set not to generate executable.")+"

" + +tr("Please correct this before start debugging")); + compile(); + return; + } + debugFile.setFile(filePath); if (!debugFile.exists()) { if (QMessageBox::question(this,tr("Compile"), @@ -3449,6 +3496,7 @@ void MainWindow::onProblemRunCurrentCase() return; showHideMessagesTab(ui->tabProblem,ui->actionProblem); applyCurrentProblemCaseChanges(); + runExecutable(RunType::CurrentProblemCase); } @@ -4828,21 +4876,47 @@ void MainWindow::onCompileFinished(bool isCheckSyntax) if (!isCheckSyntax) { //run succession task if there aren't any errors if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) { - switch (mCompileSuccessionTask->type) { - case MainWindow::CompileSuccessionTaskType::RunNormal: - runExecutable(mCompileSuccessionTask->execName,QString(),RunType::Normal, mCompileSuccessionTask->binDirs); - break; - case MainWindow::CompileSuccessionTaskType::RunProblemCases: - runExecutable(mCompileSuccessionTask->execName,QString(),RunType::ProblemCases, mCompileSuccessionTask->binDirs); - break; - case MainWindow::CompileSuccessionTaskType::RunCurrentProblemCase: - runExecutable(mCompileSuccessionTask->execName,QString(),RunType::CurrentProblemCase, mCompileSuccessionTask->binDirs); - break; - case MainWindow::CompileSuccessionTaskType::Debug: - debug(); - break; - default: - break; + if (!mCompileSuccessionTask->isExecutable) { + switch (mCompileSuccessionTask->type) { + case MainWindow::CompileSuccessionTaskType::RunNormal: + if (fileExists(mCompileSuccessionTask->execName)) + openFile(mCompileSuccessionTask->execName); + break; + case MainWindow::CompileSuccessionTaskType::RunProblemCases: + case MainWindow::CompileSuccessionTaskType::RunCurrentProblemCase: + QMessageBox::critical(this,tr("Wrong Compiler Settings"), + tr("Compiler is set not to generate executable.")+"

" + +tr("We need the executabe to run problem case.")); + break; + case MainWindow::CompileSuccessionTaskType::Debug: + QMessageBox::critical( + this, + tr("Wrong Compiler Settings"), + tr("Compiler is set not to generate executable.")+"

" + +tr("Please correct this before start debugging")); + compile(); + return; + break; + default: + break; + } + } else { + switch (mCompileSuccessionTask->type) { + case MainWindow::CompileSuccessionTaskType::RunNormal: + runExecutable(mCompileSuccessionTask->execName,QString(),RunType::Normal, mCompileSuccessionTask->binDirs); + break; + case MainWindow::CompileSuccessionTaskType::RunProblemCases: + runExecutable(mCompileSuccessionTask->execName,QString(),RunType::ProblemCases, mCompileSuccessionTask->binDirs); + break; + case MainWindow::CompileSuccessionTaskType::RunCurrentProblemCase: + runExecutable(mCompileSuccessionTask->execName,QString(),RunType::CurrentProblemCase, mCompileSuccessionTask->binDirs); + break; + case MainWindow::CompileSuccessionTaskType::Debug: + debug(); + break; + default: + break; + } } mCompileSuccessionTask.reset(); // Jump to problem location, sorted by significance diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 500bdc2a..0a2094bb 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -90,6 +90,7 @@ class MainWindow : public QMainWindow CompileSuccessionTaskType type; QString execName; QStringList binDirs; + bool isExecutable; }; using PCompileSuccessionTask = std::shared_ptr; diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index c8c7ad05..b94dbe57 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -133,7 +133,7 @@ QString Project::executable() const exeFileName = changeFileExt(extractFileName(mFilename),DYNAMIC_LIB_EXT); break; default: - exeFileName = changeFileExt(extractFileName(mFilename),EXECUTABLE_EXT); + exeFileName = changeFileExt(extractFileName(mFilename),DEFAULT_EXECUTABLE_SUFFIX); } } QString exePath; diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index e02fcef5..cf081034 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -1382,8 +1382,8 @@ void Settings::Editor::doLoad() else mDefaultEncoding = value("default_encoding", ENCODING_UTF8).toByteArray(); mAutoDetectFileEncoding = boolValue("auto_detect_file_encoding",true); - mUndoLimit = intValue("undo_limit",5000); - mUndoMemoryUsage = intValue("undo_memory_usage", 50); + mUndoLimit = intValue("undo_limit",0); + mUndoMemoryUsage = intValue("undo_memory_usage", 10); //tooltips mEnableTooltips = boolValue("enable_tooltips",true); @@ -1478,7 +1478,12 @@ Settings::CompilerSet::CompilerSet(): mFullLoaded(false), mAutoAddCharsetParams(true), mExecCharset(ENCODING_SYSTEM_DEFAULT), - mStaticLink(true) + mStaticLink(true), + mPreprocessingSuffix(DEFAULT_PREPROCESSING_SUFFIX), + mCompilationProperSuffix(DEFAULT_COMPILATION_SUFFIX), + mAssemblingSuffix(DEFAULT_ASSEMBLING_SUFFIX), + mExecutableSuffix(DEFAULT_EXECUTABLE_SUFFIX), + mCompilationStage(Settings::CompilerSet::CompilationStage::GenerateExecutable) { } @@ -1487,7 +1492,12 @@ Settings::CompilerSet::CompilerSet(): Settings::CompilerSet::CompilerSet(const QString& compilerFolder, const QString& cc_prog): mAutoAddCharsetParams(true), mExecCharset(ENCODING_SYSTEM_DEFAULT), - mStaticLink(true) + mStaticLink(true), + mPreprocessingSuffix(DEFAULT_PREPROCESSING_SUFFIX), + mCompilationProperSuffix(DEFAULT_COMPILATION_SUFFIX), + mAssemblingSuffix(DEFAULT_ASSEMBLING_SUFFIX), + mExecutableSuffix(DEFAULT_EXECUTABLE_SUFFIX), + mCompilationStage(Settings::CompilerSet::CompilationStage::GenerateExecutable) { if (QDir(compilerFolder).exists()) { setProperties(compilerFolder, cc_prog); @@ -1542,6 +1552,11 @@ Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set): mAutoAddCharsetParams(set.mAutoAddCharsetParams), mExecCharset(set.mExecCharset), mStaticLink(set.mStaticLink), + mPreprocessingSuffix(set.mPreprocessingSuffix), + mCompilationProperSuffix(set.mCompilationProperSuffix), + mAssemblingSuffix(set.mAssemblingSuffix), + mExecutableSuffix(set.mExecutableSuffix), + mCompilationStage(set.mCompilationStage), mCompileOptions(set.mCompileOptions) { @@ -2357,6 +2372,76 @@ QByteArray Settings::CompilerSet::getCompilerOutput(const QString &binDir, const return result.trimmed(); } +Settings::CompilerSet::CompilationStage Settings::CompilerSet::compilationStage() const +{ + return mCompilationStage; +} + +void Settings::CompilerSet::setCompilationStage(CompilationStage newCompilationStage) +{ + mCompilationStage = newCompilationStage; +} + +QString Settings::CompilerSet::getOutputFilename(const QString &sourceFilename) +{ + switch(compilationStage()) { + case Settings::CompilerSet::CompilationStage::PreprocessingOnly: + return changeFileExt(sourceFilename, preprocessingSuffix()); + case Settings::CompilerSet::CompilationStage::CompilationProperOnly: + return changeFileExt(sourceFilename, compilationProperSuffix()); + case Settings::CompilerSet::CompilationStage::AssemblingOnly: + return changeFileExt(sourceFilename, assemblingSuffix()); + case Settings::CompilerSet::CompilationStage::GenerateExecutable: + return changeFileExt(sourceFilename, executableSuffix()); + } + return changeFileExt(sourceFilename,DEFAULT_EXECUTABLE_SUFFIX); +} + +bool Settings::CompilerSet::isOutputExecutable() +{ + return mCompilationStage == CompilationStage::GenerateExecutable; +} + +const QString &Settings::CompilerSet::assemblingSuffix() const +{ + return mAssemblingSuffix; +} + +void Settings::CompilerSet::setAssemblingSuffix(const QString &newAssemblingSuffix) +{ + mAssemblingSuffix = newAssemblingSuffix; +} + +const QString &Settings::CompilerSet::compilationProperSuffix() const +{ + return mCompilationProperSuffix; +} + +void Settings::CompilerSet::setCompilationProperSuffix(const QString &newCompilationProperSuffix) +{ + mCompilationProperSuffix = newCompilationProperSuffix; +} + +const QString &Settings::CompilerSet::preprocessingSuffix() const +{ + return mPreprocessingSuffix; +} + +void Settings::CompilerSet::setPreprocessingSuffix(const QString &newPreprocessingSuffix) +{ + mPreprocessingSuffix = newPreprocessingSuffix; +} + +const QString &Settings::CompilerSet::executableSuffix() const +{ + return mExecutableSuffix; +} + +void Settings::CompilerSet::setExecutableSuffix(const QString &newExecutableSuffix) +{ + mExecutableSuffix = newExecutableSuffix; +} + const QMap &Settings::CompilerSet::compileOptions() const { return mCompileOptions; @@ -2800,6 +2885,12 @@ void Settings::CompilerSets::saveSet(int index) mSettings->mSettings.setValue("StaticLink", pSet->staticLink()); mSettings->mSettings.setValue("ExecCharset", pSet->execCharset()); + mSettings->mSettings.setValue("preprocessingSuffix", pSet->preprocessingSuffix()); + mSettings->mSettings.setValue("compilationProperSuffix", pSet->compilationProperSuffix()); + mSettings->mSettings.setValue("assemblingSuffix", pSet->assemblingSuffix()); + mSettings->mSettings.setValue("executableSuffix", pSet->executableSuffix()); + mSettings->mSettings.setValue("compilationStage", (int)pSet->compilationStage()); + // Misc. properties mSettings->mSettings.setValue("DumpMachine", pSet->dumpMachine()); mSettings->mSettings.setValue("Version", pSet->version()); @@ -2873,6 +2964,13 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index) if (pSet->execCharset().isEmpty()) { pSet->setExecCharset(ENCODING_SYSTEM_DEFAULT); } + pSet->setPreprocessingSuffix(mSettings->mSettings.value("preprocessingSuffix", DEFAULT_PREPROCESSING_SUFFIX).toString()); + pSet->setCompilationProperSuffix(mSettings->mSettings.value("compilationProperSuffix",DEFAULT_COMPILATION_SUFFIX).toString()); + pSet->setAssemblingSuffix(mSettings->mSettings.value("assemblingSuffix", DEFAULT_ASSEMBLING_SUFFIX).toString()); + pSet->setExecutableSuffix(mSettings->mSettings.value("executableSuffix", DEFAULT_EXECUTABLE_SUFFIX).toString()); + pSet->setCompilationStage((Settings::CompilerSet::CompilationStage)mSettings->mSettings.value( + "compilationStage", + (int)Settings::CompilerSet::CompilationStage::GenerateExecutable).toInt()); // Load options QByteArray iniOptions = mSettings->mSettings.value("Options","").toByteArray(); diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index f3ceea34..241b65c0 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -1174,6 +1174,13 @@ public: class CompilerSet { public: + enum class CompilationStage { + PreprocessingOnly, + CompilationProperOnly, + AssemblingOnly, + GenerateExecutable + }; + explicit CompilerSet(); explicit CompilerSet(const QString& compilerFolder, const QString& cc_prog); explicit CompilerSet(const CompilerSet& set); @@ -1265,6 +1272,24 @@ public: const QMap &compileOptions() const; + const QString &executableSuffix() const; + void setExecutableSuffix(const QString &newExecutableSuffix); + + const QString &preprocessingSuffix() const; + void setPreprocessingSuffix(const QString &newPreprocessingSuffix); + + const QString &compilationProperSuffix() const; + void setCompilationProperSuffix(const QString &newCompilationProperSuffix); + + const QString &assemblingSuffix() const; + void setAssemblingSuffix(const QString &newAssemblingSuffix); + + CompilationStage compilationStage() const; + void setCompilationStage(CompilationStage newCompilationStage); + + QString getOutputFilename(const QString& sourceFilename); + bool isOutputExecutable(); + private: void setDirectories(const QString& binDir, const QString& mCompilerType); //load hard defines @@ -1316,6 +1341,13 @@ public: QString mExecCharset; bool mStaticLink; + QString mPreprocessingSuffix; + QString mCompilationProperSuffix; + QString mAssemblingSuffix; + QString mExecutableSuffix; + + CompilationStage mCompilationStage; + // Options QMap mCompileOptions; }; diff --git a/RedPandaIDE/settingsdialog/compilersetdirectorieswidget.cpp b/RedPandaIDE/settingsdialog/compilersetdirectorieswidget.cpp index 51058d13..cedb2cb2 100644 --- a/RedPandaIDE/settingsdialog/compilersetdirectorieswidget.cpp +++ b/RedPandaIDE/settingsdialog/compilersetdirectorieswidget.cpp @@ -35,8 +35,6 @@ CompilerSetDirectoriesWidget::CompilerSetDirectoriesWidget(QWidget *parent) : this, &CompilerSetDirectoriesWidget::selectionChanged); ui->listView->setSelectionMode(QAbstractItemView::SingleSelection); onUpdateIcons(); - connect(pIconsManager, &IconsManager::actionIconsUpdated, - this, &CompilerSetDirectoriesWidget::onUpdateIcons); } CompilerSetDirectoriesWidget::~CompilerSetDirectoriesWidget() diff --git a/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp b/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp index 05a380df..69c278a9 100644 --- a/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp +++ b/RedPandaIDE/settingsdialog/compilersetoptionwidget.cpp @@ -47,9 +47,10 @@ CompilerSetOptionWidget::CompilerSetOptionWidget(const QString& name, const QStr connect(ui->chkUseCustomLinkParams, &QCheckBox::stateChanged, ui->txtCustomLinkParams, &QPlainTextEdit::setEnabled); - connect(pIconsManager, &IconsManager::actionIconsUpdated, - this, &CompilerSetOptionWidget::updateIcons); - updateIcons(); + updateIcons(pIconsManager->actionIconSize()); +#ifdef Q_OS_WIN + ui->txtExecutableSuffix->setReadOnly(true); +#endif } CompilerSetOptionWidget::~CompilerSetOptionWidget() @@ -117,6 +118,20 @@ static void loadCompilerSetSettings(Settings::PCompilerSet pSet, Ui::CompilerSet } ui->cbEncodingDetails->setCurrentText(encoding); } + + ui->txtPreprocessingSuffix->setText(pSet->preprocessingSuffix()); + ui->txtCompilationSuffix->setText(pSet->compilationProperSuffix()); + ui->txtExecutableSuffix->setText(pSet->executableSuffix()); + switch(pSet->compilationStage()) { + case Settings::CompilerSet::CompilationStage::PreprocessingOnly: + ui->rbPreprocessingOnly->setChecked(true); + break; + case Settings::CompilerSet::CompilationStage::CompilationProperOnly: + ui->rbCompilationProperOnly->setChecked(true); + break; + default: + ui->rbGenerateExecutable->setChecked(true); + } } void CompilerSetOptionWidget::doLoad() @@ -208,6 +223,16 @@ void CompilerSetOptionWidget::saveCurrentCompilerSet() //read values in the options widget pSet->setCompileOptions(ui->optionTabs->arguments(false)); + if (ui->rbPreprocessingOnly->isChecked()) { + pSet->setCompilationStage(Settings::CompilerSet::CompilationStage::PreprocessingOnly); + } else if (ui->rbCompilationProperOnly->isChecked()) { + pSet->setCompilationStage(Settings::CompilerSet::CompilationStage::CompilationProperOnly); + } else if (ui->rbGenerateExecutable->isChecked()) { + pSet->setCompilationStage(Settings::CompilerSet::CompilationStage::GenerateExecutable); + } + pSet->setPreprocessingSuffix(ui->txtPreprocessingSuffix->text()); + pSet->setCompilationProperSuffix(ui->txtCompilationSuffix->text()); + pSet->setExecutableSuffix(ui->txtExecutableSuffix->text()); } void CompilerSetOptionWidget::on_btnFindCompilers_pressed() @@ -272,7 +297,7 @@ void CompilerSetOptionWidget::on_btnRemoveCompilerSet_pressed() doLoad(); } -void CompilerSetOptionWidget::updateIcons() +void CompilerSetOptionWidget::updateIcons(const QSize& /*size*/) { pIconsManager->setIcon(ui->btnFindCompilers, IconsManager::ACTION_EDIT_SEARCH); pIconsManager->setIcon(ui->btnAddCompilerSetByFolder, IconsManager::ACTION_FILE_OPEN_FOLDER); diff --git a/RedPandaIDE/settingsdialog/compilersetoptionwidget.h b/RedPandaIDE/settingsdialog/compilersetoptionwidget.h index 0c0d4b9b..b2e6c1ea 100644 --- a/RedPandaIDE/settingsdialog/compilersetoptionwidget.h +++ b/RedPandaIDE/settingsdialog/compilersetoptionwidget.h @@ -47,6 +47,7 @@ public: protected: void doLoad() override; void doSave() override; + void updateIcons(const QSize& size) override; private: void reloadCurrentCompilerSet(); @@ -59,7 +60,6 @@ private slots: void on_btnAddCompilerSetByFolder_pressed(); void on_btnRenameCompilerSet_pressed(); void on_btnRemoveCompilerSet_pressed(); - void updateIcons(); void on_cbEncoding_currentTextChanged(const QString &arg1); void on_cbEncodingDetails_currentTextChanged(const QString &arg1); diff --git a/RedPandaIDE/settingsdialog/compilersetoptionwidget.ui b/RedPandaIDE/settingsdialog/compilersetoptionwidget.ui index edfb6b0d..690954eb 100644 --- a/RedPandaIDE/settingsdialog/compilersetoptionwidget.ui +++ b/RedPandaIDE/settingsdialog/compilersetoptionwidget.ui @@ -110,7 +110,7 @@ - 0 + 4 false @@ -240,19 +240,6 @@ Programs - - - - - 0 - 0 - - - - TextLabel - - - @@ -451,6 +438,102 @@ + + + Output + + + + + + + + + + + + Compilation Stages + + + + + + Stop after the preprocessing stage + + + + + + + Stop after the compilation proper stage + + + + + + + Link and generate the executable + + + true + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Executable suffix + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Preprocessing output suffix + + + + + + + Compiling output suffix + + + + + diff --git a/RedPandaIDE/settingsdialog/editorcolorschemewidget.cpp b/RedPandaIDE/settingsdialog/editorcolorschemewidget.cpp index b6bf5459..ce40088c 100644 --- a/RedPandaIDE/settingsdialog/editorcolorschemewidget.cpp +++ b/RedPandaIDE/settingsdialog/editorcolorschemewidget.cpp @@ -182,7 +182,7 @@ void EditorColorSchemeWidget::setCurrentSchemeModified() EditorColorSchemeWidget::~EditorColorSchemeWidget() { delete ui; - mDefinesModel.clear(); + //mDefinesModel.clear(); } static void setColorProp(ColorEdit* ce, QCheckBox* cb, const QColor& color) { diff --git a/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.h b/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.h index a69d673f..c7665b30 100644 --- a/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.h +++ b/RedPandaIDE/settingsdialog/projectcompileparamaterswidget.h @@ -44,7 +44,7 @@ private slots: // SettingsWidget interface protected: - void updateIcons(const QSize &size) Q_DECL_OVERRIDE; + void updateIcons(const QSize &size) override; }; #endif // PROJECTCOMPILEPARAMATERSWIDGET_H diff --git a/RedPandaIDE/settingsdialog/settingswidget.cpp b/RedPandaIDE/settingsdialog/settingswidget.cpp index 850a957f..09ca08f2 100644 --- a/RedPandaIDE/settingsdialog/settingswidget.cpp +++ b/RedPandaIDE/settingsdialog/settingswidget.cpp @@ -91,7 +91,7 @@ void SettingsWidget::disconnectAbstractItemView(QAbstractItemView *pView) } -void SettingsWidget::updateIcons(const QSize &) +void SettingsWidget::updateIcons(const QSize & /*size*/) { } diff --git a/RedPandaIDE/settingsdialog/settingswidget.h b/RedPandaIDE/settingsdialog/settingswidget.h index a89f4b80..2f1f0366 100644 --- a/RedPandaIDE/settingsdialog/settingswidget.h +++ b/RedPandaIDE/settingsdialog/settingswidget.h @@ -32,13 +32,15 @@ public: void save(); signals: void settingsChanged(bool changed); +public slots: + void onUpdateIcons(); protected: virtual void doLoad() = 0; virtual void doSave() = 0; void connectAbstractItemView(QAbstractItemView* pView); void disconnectAbstractItemView(QAbstractItemView* pView); - virtual void updateIcons(const QSize& size); + virtual void updateIcons(const QSize &size) ; public: const QString& group(); const QString& name(); @@ -49,8 +51,6 @@ public slots: void setSettingsChanged(); void clearSettingsChanged(); private: -private slots: - void onUpdateIcons(); private: bool mSettingsChanged; diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index 5c245717..274aaf44 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -97,7 +97,10 @@ # define PATH_SEPARATOR ";" # define LINE_BREAKER "\r\n" # define NULL_FILE "NUL" -# define EXECUTABLE_EXT "exe" +# define DEFAULT_EXECUTABLE_SUFFIX "exe" +# define DEFAULT_PREPROCESSING_SUFFIX "p" +# define DEFAULT_COMPILATION_SUFFIX "s" +# define DEFAULT_ASSEMBLING_SUFFIX "o" # define STATIC_LIB_EXT "a" # define DYNAMIC_LIB_EXT "dll" # define MAKEFILE_NAME "makefile.win" @@ -107,7 +110,10 @@ # define PATH_SEPARATOR ":" # define LINE_BREAKER "\n" # define NULL_FILE "/dev/null" -# define EXECUTABLE_EXT "" +# define DEFAULT_EXECUTABLE_SUFFIX "" +# define DEFAULT_PREPROCESSING_SUFFIX "p" +# define DEFAULT_COMPILATION_SUFFIX "s" +# define DEFAULT_ASSEMBLING_SUFFIX "o" # define STATIC_LIB_EXT "a" # define DYNAMIC_LIB_EXT "d" # define MAKEFILE_NAME "makefile" diff --git a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts index 7faaf51f..a13b039b 100644 --- a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts +++ b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts @@ -585,7 +585,7 @@ TextLabel - Label + Label Choose make @@ -687,6 +687,46 @@ New name Novo nome + + Output + Saída + + + Compilation Stages + + + + Stop after the preprocessing stage + + + + Stop after the compilation proper stage + + + + Stop after the assembling stage + + + + Link and generate the executable + + + + Preprocessing output suffix + + + + Assembling output suffix + + + + Compiling output suffix + + + + Executable suffix + + CppRefacter @@ -4604,6 +4644,22 @@ Template %1 already exists. Do you want to overwrite? + + Wrong Compiler Settings + + + + Compiler is set not to generate executable. + + + + We need the executabe to run problem case. + + + + Please correct this before start debugging + + NewClassDialog @@ -5842,7 +5898,7 @@ Link an Objective C program (-lobjc) - Link para um programa Objective C (-lobjc) + Link para um programa Objective C (-lobjc) Do not use standard system libraries (-nostdlib) @@ -5862,11 +5918,11 @@ Output - Saída + Saída Put comments in generated assembly code (-fverbose-asm) - Colocar comentários no código gerado em assembly (-fverbose-asm) + Colocar comentários no código gerado em assembly (-fverbose-asm) Do not assemble, compile and generate the assembly code (-S) @@ -5974,7 +6030,7 @@ Do not compile, stop after the preprocessing stage (-E) - Não compilar, parar após o estágio de preprocessamento (-E) + Não compilar, parar após o estágio de preprocessamento (-E) Leaving those directories will lead to problems during compilation. @@ -5984,10 +6040,6 @@ Gloabal Variable - - Do not assemble, compile and generate the assemble code (-S) - - Compiler set not configuared. diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts index f2ee00bb..ae81cc71 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts @@ -741,7 +741,7 @@ p, li { white-space: pre-wrap; } 删除非法文件夹 - + Choose Folder 选择文件夹 @@ -759,13 +759,13 @@ p, li { white-space: pre-wrap; } 编译器配置方案 - - - - - - - + + + + + + + ... ... @@ -845,42 +845,91 @@ p, li { white-space: pre-wrap; } 程序 - - TextLabel - 选项 + + Output + 输出 - + + Compilation Stages + 编译阶段 + + + + Stop after the preprocessing stage + 在完成预处理后停止编译 + + + + Stop after the compilation proper stage + 在完成编译仪式(compilation proper)后停止。 + + + + Stop after the assembling stage + 在完成汇编后停止。 + + + + Link and generate the executable + 链接得到可执行文件。 + + + + Preprocessing output suffix + 预处理输出后缀 + + + + Assembling output suffix + 编译输出后缀 + + + + Compiling output suffix + 编译仪式(Compilation proper)输出后缀 + + + + Executable suffix + 可执行文件后缀 + + + TextLabel + 选项 + + + gdb gdb - + gdb server gdb server - + Resource Compiler(windres) 资源编辑器(winres) - + C++ Compiler(g++) C++编译器(g++) - + Choose C++ Compiler 选择C++编译器 - + Choose C Compiler 选择C编译器 - + C Compiler(gcc) C编译器(gcc) @@ -889,42 +938,42 @@ p, li { white-space: pre-wrap; } 调试器(gdb) - + Profiler(gprof) 性能分析器(gprof) - + make - + Choose make 选择make - + Choose Debugger 选择调试器 - + Choose Resource Compiler 选择资源编译器 - + Choose Profiler 选择性能分析器 - + Confirm 确认 - + Red Panda C++ will clear current compiler list and search for compilers in the following locations:<br /> '%1'<br /> '%2'<br />Are you really want to continue? Red Panda C++ will clear current compiler list and search for compilers in the following locations: '%1' @@ -933,50 +982,50 @@ Are you really want to continue? 小熊猫C++ 将会清除现有的编译器配置列表,然后在下列文件夹中搜索编译器:<br/> '%1'<br/> '%2'<br />你确定要继续吗? - + ANSI ANSI - + UTF-8 UTF-8 - + Red Panda C++ will clear current compiler list and search for compilers in the the PATH. <br />Are you really want to continue? 小熊猫C++ 将会清除现有的编译器配置列表,然后在PATH路径中搜索gcc编译器.<br />你确定要继续吗? - - + + Failed 失败 - - + + Can't find any compiler. 找不到编译器 - - + + Compiler Set Name 编译器配置名称 - + Name 名称 - + Compiler Set Folder 编译器所在文件夹 - + New name 新名称 @@ -2505,35 +2554,35 @@ Are you really want to continue? - 编译器配置: %1 - - + + Can't delete the old executable file "%1". 无法删除旧的可执行文件"%1". - + Can't find the compiler for file %1 Can't the compiler for file %1 找不到适合文件%1的编译器 - + The Compiler '%1' doesn't exists! 编译器程序"%1"不存在! - + Processing %1 source file: 正在处理%1源程序文件: - + %1 Compiler: %2 %1编译器: %2 - + Command: %1 %2 命令: %1 %2 @@ -3835,11 +3884,11 @@ Are you really want to continue? - - - - - + + + + + Issues 编译器 @@ -4047,8 +4096,8 @@ Are you really want to continue? - - + + Compile 编译 @@ -4126,9 +4175,9 @@ Are you really want to continue? - - - + + + Copy 复制 @@ -4139,7 +4188,7 @@ Are you really want to continue? - + Paste 粘贴 @@ -4150,8 +4199,8 @@ Are you really want to continue? - - + + Select All 选择全部 @@ -4277,7 +4326,7 @@ Are you really want to continue? - + New Problem Set 新建试题集 @@ -4296,14 +4345,14 @@ Are you really want to continue? - + Save Problem Set 保存试题集 - + Load Problem Set 载入试题集 @@ -4364,7 +4413,7 @@ Are you really want to continue? - + Run All Cases Run Current Case 运行所有案例 @@ -4657,7 +4706,7 @@ Are you really want to continue? - + Clear all breakpoints 删除所有断点 @@ -4822,7 +4871,7 @@ Are you really want to continue? 保存为模板... - + New File 新建文件 @@ -4863,7 +4912,7 @@ Are you really want to continue? - + Rename Symbol 重命名符号 @@ -4884,13 +4933,13 @@ Are you really want to continue? - + Export As RTF 导出为RTF - + Export As HTML 导出为HTML @@ -5159,7 +5208,7 @@ Are you really want to continue? 运行参数... - + File Encoding 文件编码 @@ -5234,166 +5283,188 @@ Are you really want to continue? 你确定要关闭'%1'吗? - - + + Confirm 确认 - - - + + + Source file is not compiled. 源文件尚未编译。 - - + + Compile now? 现在编译? - - + + Source file is more recent than executable. 源文件比可执行程序新。 - + Recompile now? 重新编译? - + + + Wrong Compiler Settings + 错误的编译器设置 + + + + + Compiler is set not to generate executable. + 编译器被设置为不生成可执行文件。 + + + + We need the executabe to run problem case. + 我们需要可执行文件来运行试题案例。 + + + No compiler set 无编译器设置 - + No compiler set is configured. 没有配置编译器设置。 - + Can't start debugging. 无法启动调试器 - - + + Enable debugging 启用调试参数 - - + + You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now? 当前编译设置中未启用调试选项(-g3),或启用了信息剥除选项(-s)<br /><br/>是否纠正这一问题? - + Project not built 项目尚未构建 - + Project hasn't been built. Build it now? 项目尚未构建。是否构建? - + Host applcation missing 宿主程序不存在 - + DLL project needs a host application to run. 动态链接库(DLL)需要一个宿主程序来运行。 - + But it's missing. 但它不存在。 - + Host application not exists 宿主程序不存在 - + Host application file '%1' doesn't exist. 宿主程序'%1'不存在。 - + + Please correct this before start debugging + 请在调试前改正设置。 + + + Recompile? 重新编译? - - + + Save last open info error 保存上次打开信息失败 - + Can't remove old last open information file '%1' 无法删除旧上次打开信息文件'%1' - + Can't save last open info file '%1' 无法保存上次打开信息文件'%1' - + Load last open info error 载入上次打开信息失败 - + Can't load last open info file '%1' 无法载入上次打开信息文件'%1' - + Open Source File 打开源代码文件 - - + + Batch Set Cases 批量设置案例 - + Show detail debug logs 显示详细调试器日志 - + Copy all 全部复制 - + Go to Line 跳转到行 - + Line - + Template Exists 模板已存在 - + Template %1 already exists. Do you want to overwrite? 模板%1已存在。是否覆盖? @@ -5401,9 +5472,9 @@ Are you really want to continue? - - - + + + Clear 清除 @@ -5419,7 +5490,7 @@ Are you really want to continue? - + Problem Set %1 试题集%1 @@ -5440,68 +5511,68 @@ Are you really want to continue? 或者选择使用其他的网络端口。 - - + + Rebuild Project 重新构建项目 - - + + Project has been modified, do you want to rebuild it? 项目已经被修改过,是否需要重新构建? - + Auto Save Error 自动保存出错 - + Auto save "%1" to "%2" failed:%3 自动保存"%1"到"%2"失败:%3 - + Properties... 试题属性... - + Set Problem Set Name 设置试题集名称 - + Problem Set Name: 试题集名称: - + Remove 删除 - + Remove All Bookmarks 删除全部书签 - + Modify Description 修改描述 - - - + + + Bookmark Description 书签描述 - - - + + + Description: 描述: @@ -5510,179 +5581,179 @@ Are you really want to continue? 在调试主控台中显示调试器输出 - + Remove this search 清除这次搜索 - + Clear all searches 删除所有搜索 - + Breakpoint condition... 断点条件... - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Remove All Breakpoints Remove all breakpoints 删除所有断点 - + Remove Breakpoint 删除当前断点 - + Rename File 重命名文件 - - + + Add Folder 添加文件夹 - - + + New folder 新文件夹 - + Folder name: 文件夹: - + Rename Folder 重命名 - + Run Current Case 运行当前案例 - + Remove Folder 删除文件夹 - + Switch to normal view 切换为普通视图 - + Switch to custom view 切换为自定义视图 - + Sort By Type 按类型排序 - + Sort alphabetically 按名称排序 - + Show inherited members 显示继承的成员 - + Goto declaration 跳转到声明处 - + Goto definition 跳转到定义处 - - + + New Folder 新建文件夹 - + Rename 重命名 - - - - + + + + Delete 删除 - + Open in Editor 在编辑器中打开 - + Open in External Program 使用外部程序打开 - + Open in Terminal 在终端中打开 - + Open in Windows Explorer 在Windows浏览器中打开 - + Character sets 字符集 - + Convert to %1 转换为%1编码 - + %1 files autosaved 已自动保存%1个文件 - + Set answer to... 设置答案源代码... - + select other file... 选择其他文件... - + Select Answer Source File 选择答案源代码文件 @@ -5692,7 +5763,7 @@ Are you really want to continue? C/C++源代码文件 (*.c *.cpp *.cc *.cxx) - + New Folder %1 新建文件夹%1 @@ -5705,68 +5776,68 @@ Are you really want to continue? 无标题%1 - + Do you really want to delete %1? 你真的要删除%1吗? - + Do you really want to delete %1 files? 你真的要删除%1个文件吗? - + Save project 保存项目 - + The project '%1' has modifications. 项目'%1'有改动。 - - + + Do you want to save it? 需要保存吗? - - + + File Changed 文件已发生变化 - + New Project File? 新建项目文件? - + Do you want to add the new file to the project? 您是否要将新建的文件加入项目? - - - - + + + + Save Error 保存失败 - + Change Project Compiler Set 改变项目编译器配置集 - + Change the project's compiler set will lose all custom compiler set options. 改变项目的编译器配置集会导致所有的自定义编译器选项被重置。 - - + + Do you really want to do that? 你真的想要那么做吗? @@ -5775,119 +5846,119 @@ Are you really want to continue? 批量设置案例 - + Choose input files 选择输入数据文件 - + Input data files (*.in) 输入数据文件 (*.in) - + untitled%1 无标题%1 - + Modify Watch 修改监视表达式 - + Watch Expression 监视表达式 - + Do you really want to clear all breakpoints in this file? 您真的要清除该文件的所有断点吗? - + New project 新建项目 - + Close %1 and start new project? 关闭'%1'以打开新项目? - + Folder not exist 文件夹不存在 - + Folder '%1' doesn't exist. Create it now? 文件夹'%1'不存在。是否创建? - + Can't create folder 无法创建文件夹 - + Failed to create folder '%1'. 创建文件夹'%1'失败。 - + Save new project as - + Folder %1 is not empty. 文件夹%1不是空的。 - + Do you really want to delete it? 你真的要删除它吗? - + Change working folder 改变工作文件夹 - + File '%1' is not in the current working folder. File '%1' is not in the current working folder 文件'%1'不在当前工作文件夹中。 - + Do you want to change working folder to '%1'? 是否将工作文件夹改设为'%1'? - + Can't Commit 无法提交 - + Git needs user info to commit. Git需要用信息进行提交。 - + Choose Input Data File 选择输入数据文件 - - + + All files (*.*) 所有文件 (*.*) - + Choose Expected Output Data File Choose Expected Input Data File 选择期望输出文件 @@ -5899,59 +5970,59 @@ Are you really want to continue? - + Choose Working Folder 选择工作文件夹 - - + + Header Exists 头文件已存在 - - + + Header file "%1" already exists! 头文件"%1"已存在! - + Source Exists 源文件已存在! - + Source file "%1" already exists! 源文件"%1"已存在! - + Can't commit! 无法提交! - + The following files are in conflicting: 下列文件处于冲突状态,请解决后重新添加和提交: - + Commit Message 提交信息 - + Commit Message: 提交信息: - + Commit Failed 提交失败 - + Commit message shouldn't be empty! 提交信息不能为空! @@ -5960,137 +6031,137 @@ Are you really want to continue? 小熊猫Dev-C++项目文件 (*.dev) - + New project fail 新建项目失败 - + Can't assign project template 无法使用模板创建项目 - + Remove file 删除文件 - + Remove the file from disk? 同时从硬盘上删除文件? - - - + + + untitled 无标题 - + New Project File Name 新的项目文件名 - + File Name: 文件名: - + File Already Exists! 文件已存在! - + File '%1' already exists! 文件'%1'已经存在! - + Add to project 添加到项目 - + C/C++ Source Files (*.c *.cpp *.cc *.cxx) C/C++源代码文件 (*.c *.cpp *.cc *.cxx) - + This operation will remove all cases for the current problem. 本操作会删除此试题的所有案例。 - + Red Panda C++ project file (*.dev) 小熊猫C++项目文件(*.dev) - + Rename Error 重命名出错 - + Symbol '%1' is defined in system header. 符号'%1'在系统头文件中定义,无法修改。 - + New Name 新名称 - - + + Replace Error 替换出错 - + Can't open file '%1' for replace! 无法打开文件'%1'进行替换! - + Contents has changed since last search! 内容和上次查找时不一致。 - + Rich Text Format Files (*.rtf) RTF格式文件 (*.rtf) - + HTML Files (*.html) HTML文件 (*.html) - + The current problem set is not empty. 当前的试题集不是空的。 - + Problem %1 试题%1 - - + + Problem Set Files (*.pbs) 试题集文件 (*.pbs) - + Load Error 载入失败 - - + + Problem Case %1 试题案例%1 @@ -6102,15 +6173,15 @@ Are you really want to continue? - - - - - - - - - + + + + + + + + + Error 错误 @@ -6131,85 +6202,85 @@ Are you really want to continue? 清除历史 - - + + Version Control 版本控制 - + File '%1' was changed. 磁盘文件'%1'已被修改。 - + Reload its content from disk? 是否重新读取它的内容? - + File '%1' was removed. 磁盘文件'%1'已被删除。 - + Keep it open? 是否保持它在小熊猫C++中打开的编辑窗口? - + Open 打开 - + Compile Failed 编译失败 - + Run Failed 运行失败 - - - - + + + + Confirm Convertion 确认转换 - - - - + + + + The editing file will be saved using %1 encoding. <br />This operation can't be reverted. <br />Are you sure to continue? 当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗? - + New Watch Expression 新监视表达式 - + Enter Watch Expression (it is recommended to use 'this->' for class members): 输入监视表达式 - + Parsing file %1 of %2: "%3" (%1/%2)正在解析文件"%3" - - + + Done parsing %1 files in %2 seconds 完成%1个文件的解析,用时%2秒 - + (%1 files per second) (每秒%1个文件) @@ -7430,60 +7501,60 @@ Are you really want to continue? 无法载入自动链接设置 - - - - + + + + The following %1 directories don't exist: 下列%1文件夹不存在: - - + + binary 二进制 - + No %1 directories have been specified. 未指定%1文件夹 - + C include C包含 - - + + C++ include C++包含 - - - + + + Cannot find the %1 "%2" 无法找到%1程序"%2" - + C Compiler C编译器 - + C++ Compiler C++编译器 - + Maker 构建程序(Make) - + Debugger 调试器 @@ -7552,7 +7623,7 @@ Are you really want to continue? 生成调试信息(-g3) - + Would you like Red Panda C++ to search for compilers in PATH? 您同意小熊猫C++在PATH路径中寻找gcc编译器吗? @@ -7607,14 +7678,13 @@ Are you really want to continue? 遇到第一个错误后立即中止编译(-Wfatal-errors) - + Linker 链接器 - Link an Objective C program (-lobjc) - 链接Objective-C程序 (-lobjc) + 链接Objective-C程序 (-lobjc) @@ -7636,48 +7706,44 @@ Are you really want to continue? 链接Ojbective C程序(-lobjc) - Output - 输出 + 输出 - Put comments in generated assembly code (-fverbose-asm) - 在生成的汇编代码中加入注释(-fverbose-asm) + 在生成的汇编代码中加入注释(-fverbose-asm) - Do not compile, stop after the preprocessing stage (-E) - 仅预处理(-E) + 仅预处理(-E) - + Use pipes instead of temporary files during compilation (-pipe) 编译时使用管道而不是临时文件(-pipe) - Do not assemble, compile and generate the assemble code (-S) - 只生成汇编代码(-S) + 只生成汇编代码(-S) - - + + Confirm 确认 - + The following problems were found during validation of compiler set "%1": 在验证编译器设置"%1"时遇到了下列问题: - + Leaving those directories will lead to problems during compilation. 在配置中保留这些文件夹可能会导致编译出错。 - + Would you like Red Panda C++ to remove them for you and add the default paths to the valid paths? 是否让小熊猫C++删除这些配置,并尝试重新建立配置? @@ -7686,13 +7752,13 @@ Are you really want to continue? 如果仍然保留这些设置,可能会导致编译错误。<br /><br />请选择“是”,除非您清楚的知道选择“否”的后果, - - + + Compiler set not configuared. 未配置编译器设置。 - + Would you like Red Panda C++ to search for compilers in the following locations: <BR />'%1'<BR />'%2'? 您需要小熊猫C++在下列位置搜索编译器吗:<br />%1<br />%2 @@ -7734,22 +7800,22 @@ Are you really want to continue? 下标"%1"越界 - + bytes 字节 - + KB KB - + MB MB - + GB GB @@ -8509,14 +8575,14 @@ Are you really want to continue? 性能 - + Compiler Set 编译器配置集 - + Compiler @@ -8528,7 +8594,7 @@ Are you really want to continue? 自动链接 - + @@ -8604,15 +8670,15 @@ Are you really want to continue? 杂项 - - + + Program Runner 程序运行 - + Problem Set 试题集 diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts index 64dca603..e6066c0a 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts @@ -512,10 +512,6 @@ Programs - - TextLabel - - Choose make @@ -616,6 +612,46 @@ New name + + Output + + + + Compilation Stages + + + + Stop after the preprocessing stage + + + + Stop after the compilation proper stage + + + + Stop after the assembling stage + + + + Link and generate the executable + + + + Preprocessing output suffix + + + + Assembling output suffix + + + + Compiling output suffix + + + + Executable suffix + + CppRefacter @@ -4497,6 +4533,22 @@ Template %1 already exists. Do you want to overwrite? + + Wrong Compiler Settings + + + + Compiler is set not to generate executable. + + + + We need the executabe to run problem case. + + + + Please correct this before start debugging + + NewClassDialog @@ -5713,10 +5765,6 @@ Linker - - Link an Objective C program (-lobjc) - - Do not use standard system libraries (-nostdlib) @@ -5733,18 +5781,6 @@ Generate debugging information (-g3) - - Output - - - - Put comments in generated assembly code (-fverbose-asm) - - - - Do not assemble, compile and generate the assemble code (-S) - - Use pipes instead of temporary files during compilation (-pipe) @@ -5841,10 +5877,6 @@ This CPU - - Do not compile, stop after the preprocessing stage (-E) - - Leaving those directories will lead to problems during compilation. diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 43021e72..cb016401 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -173,11 +173,6 @@ QString genMakePath2(const QString &fileName) return genMakePath(fileName, true, false); } -QString getCompiledExecutableName(const QString& filename) -{ - return changeFileExt(filename,EXECUTABLE_EXT); -} - bool programHasConsole(const QString & filename) { #ifdef Q_OS_WIN @@ -236,12 +231,19 @@ QString parseMacros(const QString &s) } if (e!=nullptr && !e->inProject()) { // Non-project editor macros - result.replace("", extractFileName(changeFileExt(e->filename(),EXECUTABLE_EXT))); - result.replace("", localizePath(changeFileExt(e->filename(),EXECUTABLE_EXT))); - result.replace("", extractFileName(e->filename())); - result.replace("", localizePath(e->filename())); - result.replace("", extractFileName(e->filename())); - result.replace("", localizePath(extractFileDir(e->filename()))); + QString exeSuffix; + Settings::PCompilerSet compilerSet = pSettings->compilerSets().defaultSet(); + if (compilerSet) { + exeSuffix = compilerSet->executableSuffix(); + } else { + exeSuffix = DEFAULT_EXECUTABLE_SUFFIX; + } + result.replace("", extractFileName(changeFileExt(e->filename(), exeSuffix))); + result.replace("", localizePath(changeFileExt(e->filename(), exeSuffix))); + result.replace("", extractFileName(e->filename())); + result.replace("", localizePath(e->filename())); + result.replace("", extractFileName(e->filename())); + result.replace("", localizePath(extractFileDir(e->filename()))); } else if (pMainWindow->project()) { result.replace("", extractFileName(pMainWindow->project()->executable())); result.replace("", localizePath(pMainWindow->project()->executable())); diff --git a/RedPandaIDE/utils.h b/RedPandaIDE/utils.h index 023bda2b..b18febde 100644 --- a/RedPandaIDE/utils.h +++ b/RedPandaIDE/utils.h @@ -104,7 +104,6 @@ QStringList splitProcessCommand(const QString& cmd); QString genMakePath(const QString& fileName,bool escapeSpaces, bool encloseInQuotes); QString genMakePath1(const QString& fileName); QString genMakePath2(const QString& fileName); -QString getCompiledExecutableName(const QString& filename); bool programHasConsole(const QString& filename); QString parseMacros(const QString& s); diff --git a/RedPandaIDE/widgets/compileargumentswidget.h b/RedPandaIDE/widgets/compileargumentswidget.h index b85ed8e5..b84266bb 100644 --- a/RedPandaIDE/widgets/compileargumentswidget.h +++ b/RedPandaIDE/widgets/compileargumentswidget.h @@ -37,6 +37,8 @@ public: void resetUI(Settings::PCompilerSet pSet, const QMap& options); + void setBoolArgument(const QString &argKey, bool checked); + private: QString mCompilerType; }; diff --git a/libs/qsynedit/qsynedit/SynEdit.cpp b/libs/qsynedit/qsynedit/SynEdit.cpp index 21c9669f..09bce855 100644 --- a/libs/qsynedit/qsynedit/SynEdit.cpp +++ b/libs/qsynedit/qsynedit/SynEdit.cpp @@ -63,23 +63,23 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent), #error "Not supported!" #endif mFontDummy.setStyleStrategy(QFont::PreferAntialias); - mDocument = std::make_shared(mFontDummy, mFontDummy, this); + mDocument = std::make_shared(mFontDummy, mFontDummy, this); //fPlugins := TList.Create; mMouseMoved = false; mUndoing = false; - mDocument->connect(mDocument.get(), &SynDocument::changed, this, &SynEdit::onLinesChanged); - mDocument->connect(mDocument.get(), &SynDocument::changing, this, &SynEdit::onLinesChanging); - mDocument->connect(mDocument.get(), &SynDocument::cleared, this, &SynEdit::onLinesCleared); - mDocument->connect(mDocument.get(), &SynDocument::deleted, this, &SynEdit::onLinesDeleted); - mDocument->connect(mDocument.get(), &SynDocument::inserted, this, &SynEdit::onLinesInserted); - mDocument->connect(mDocument.get(), &SynDocument::putted, this, &SynEdit::onLinesPutted); + mDocument->connect(mDocument.get(), &Document::changed, this, &SynEdit::onLinesChanged); + mDocument->connect(mDocument.get(), &Document::changing, this, &SynEdit::onLinesChanging); + mDocument->connect(mDocument.get(), &Document::cleared, this, &SynEdit::onLinesCleared); + mDocument->connect(mDocument.get(), &Document::deleted, this, &SynEdit::onLinesDeleted); + mDocument->connect(mDocument.get(), &Document::inserted, this, &SynEdit::onLinesInserted); + mDocument->connect(mDocument.get(), &Document::putted, this, &SynEdit::onLinesPutted); mGutterWidth = 0; mScrollBars = ScrollStyle::ssBoth; - mUndoList = std::make_shared(); - mUndoList->connect(mUndoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::onUndoAdded); - mRedoList = std::make_shared(); + mUndoList = std::make_shared(); + mUndoList->connect(mUndoList.get(), &UndoList::addedUndo, this, &SynEdit::onUndoAdded); + mRedoList = std::make_shared(); // mRedoList->connect(mRedoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::onRedoAdded); mForegroundColor=palette().color(QPalette::Text); @@ -451,7 +451,7 @@ void SynEdit::endUndoBlock() void SynEdit::addCaretToUndo() { BufferCoord p=caretXY(); - mUndoList->addChange(SynChangeReason::Caret,p,p,QStringList(), mActiveSelectionMode); + mUndoList->addChange(ChangeReason::Caret,p,p,QStringList(), mActiveSelectionMode); } void SynEdit::addLeftTopToUndo() @@ -459,12 +459,12 @@ void SynEdit::addLeftTopToUndo() BufferCoord p; p.ch = leftChar(); p.line = topLine(); - mUndoList->addChange(SynChangeReason::LeftTop,p,p,QStringList(), mActiveSelectionMode); + mUndoList->addChange(ChangeReason::LeftTop,p,p,QStringList(), mActiveSelectionMode); } void SynEdit::addSelectionToUndo() { - mUndoList->addChange(SynChangeReason::Selection,mBlockBegin, + mUndoList->addChange(ChangeReason::Selection,mBlockBegin, mBlockEnd,QStringList(),mActiveSelectionMode); } @@ -1777,7 +1777,7 @@ void SynEdit::doComment() endLine = origBlockEnd.line - 1; for (int i = origBlockBegin.line - 1; i<=endLine; i++) { mDocument->putString(i, "//" + mDocument->getString(i)); - mUndoList->addChange(SynChangeReason::Insert, + mUndoList->addChange(ChangeReason::Insert, BufferCoord{1, i + 1}, BufferCoord{3, i + 1}, QStringList(), SelectionMode::Normal); @@ -1826,7 +1826,7 @@ void SynEdit::doUncomment() if ((j + 1 < s.length()) && (s[j] == '/') && (s[j + 1] == '/')) { s.remove(j,2); mDocument->putString(i,s); - mUndoList->addChange(SynChangeReason::Delete, + mUndoList->addChange(ChangeReason::Delete, BufferCoord{j+1, i + 1}, BufferCoord{j + 3, i + 1}, changeText, SelectionMode::Normal); @@ -2085,7 +2085,7 @@ void SynEdit::doDeleteLastChar() } } if ((Caret.ch != mCaretX) || (Caret.line != mCaretY)) { - mUndoList->addChange(SynChangeReason::Delete, caretXY(), Caret, helper, + mUndoList->addChange(ChangeReason::Delete, caretXY(), Caret, helper, mActiveSelectionMode); if (shouldAddGroupBreak) mUndoList->addGroupBreak(); @@ -2152,7 +2152,7 @@ void SynEdit::doDeleteCurrentChar() } } if ((Caret.ch != mCaretX) || (Caret.line != mCaretY)) { - mUndoList->addChange(SynChangeReason::Delete, caretXY(), Caret, + mUndoList->addChange(ChangeReason::Delete, caretXY(), Caret, helper, mActiveSelectionMode); if (shouldAddGroupBreak) mUndoList->addGroupBreak(); @@ -2237,7 +2237,7 @@ void SynEdit::doDeleteLine() if (mCaretY == mDocument->count()) { if (mDocument->count()==1) { mDocument->putString(mCaretY - 1,""); - mUndoList->addChange(SynChangeReason::Delete, + mUndoList->addChange(ChangeReason::Delete, BufferCoord{1, mCaretY}, BufferCoord{helper.length() + 1, mCaretY}, helper, SelectionMode::Normal); @@ -2245,7 +2245,7 @@ void SynEdit::doDeleteLine() QString s = mDocument->getString(mCaretY-2); mDocument->deleteAt(mCaretY - 1); helper.insert(0,""); - mUndoList->addChange(SynChangeReason::Delete, + mUndoList->addChange(ChangeReason::Delete, BufferCoord{s.length()+1, mCaretY-1}, BufferCoord{helper.length() + 1, mCaretY}, helper, SelectionMode::Normal); @@ -2255,7 +2255,7 @@ void SynEdit::doDeleteLine() } else { mDocument->deleteAt(mCaretY - 1); helper.append(""); - mUndoList->addChange(SynChangeReason::Delete, + mUndoList->addChange(ChangeReason::Delete, BufferCoord{1, mCaretY}, BufferCoord{helper.length() + 1, mCaretY}, helper, SelectionMode::Normal); @@ -2286,10 +2286,10 @@ void SynEdit::doDuplicateLine() doLinesInserted(mCaretY + 1, 1); mUndoList->beginBlock(); addCaretToUndo(); - mUndoList->addChange(SynChangeReason::LineBreak, + mUndoList->addChange(ChangeReason::LineBreak, BufferCoord{s.length()+1,mCaretY}, BufferCoord{s.length()+1,mCaretY}, QStringList(), SelectionMode::Normal); - mUndoList->addChange(SynChangeReason::Insert, + mUndoList->addChange(ChangeReason::Insert, BufferCoord{1,mCaretY+1}, BufferCoord{s.length()+1,mCaretY+1}, QStringList(), SelectionMode::Normal); mUndoList->endBlock(); @@ -2333,7 +2333,7 @@ void SynEdit::doMoveSelUp() BufferCoord{origBlockEnd.ch, origBlockEnd.line - 1} ); if (!mUndoing) { - mUndoList->addChange(SynChangeReason::MoveSelectionUp, + mUndoList->addChange(ChangeReason::MoveSelectionUp, origBlockBegin, origBlockEnd, QStringList(), @@ -2377,7 +2377,7 @@ void SynEdit::doMoveSelDown() ); if (!mUndoing) { - mUndoList->addChange(SynChangeReason::MoveSelectionDown, + mUndoList->addChange(ChangeReason::MoveSelectionDown, origBlockBegin, origBlockEnd, QStringList(), @@ -2444,7 +2444,7 @@ void SynEdit::insertLine(bool moveCaret) QString leftLineText = lineText().mid(0, mCaretX - 1); QString rightLineText = lineText().mid(mCaretX-1); if (!mUndoing) - mUndoList->addChange(SynChangeReason::LineBreak, caretXY(), caretXY(), QStringList(rightLineText), + mUndoList->addChange(ChangeReason::LineBreak, caretXY(), caretXY(), QStringList(rightLineText), SelectionMode::Normal); bool notInComment=true; properSetLine(mCaretY-1,leftLineText); @@ -2483,7 +2483,7 @@ void SynEdit::insertLine(bool moveCaret) indentSpacesForRightLineText = GetLeftSpacing(indentSpaces,true); mDocument->insert(mCaretY, indentSpacesForRightLineText); nLinesInserted++; - mUndoList->addChange(SynChangeReason::LineBreak, caretXY(), caretXY(), QStringList(), + mUndoList->addChange(ChangeReason::LineBreak, caretXY(), caretXY(), QStringList(), SelectionMode::Normal); } //insert new line in middle of "{" and "}" @@ -2495,7 +2495,7 @@ void SynEdit::insertLine(bool moveCaret) indentSpacesForRightLineText = GetLeftSpacing(indentSpaces,true); mDocument->insert(mCaretY, indentSpacesForRightLineText); nLinesInserted++; - mUndoList->addChange(SynChangeReason::LineBreak, caretXY(), caretXY(), QStringList(), + mUndoList->addChange(ChangeReason::LineBreak, caretXY(), caretXY(), QStringList(), SelectionMode::Normal); } } @@ -2776,8 +2776,8 @@ void SynEdit::doBlockIndent() // } // strToInsert.append(spaces); mUndoList->beginBlock(); - mUndoList->addChange(SynChangeReason::Caret, oldCaretPos, oldCaretPos,QStringList(), activeSelectionMode()); - mUndoList->addChange(SynChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode()); + mUndoList->addChange(ChangeReason::Caret, oldCaretPos, oldCaretPos,QStringList(), activeSelectionMode()); + mUndoList->addChange(ChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode()); int ch; if (mActiveSelectionMode == SelectionMode::Column) ch = std::min(BB.ch, BE.ch); @@ -2789,7 +2789,7 @@ void SynEdit::doBlockIndent() QString line=mDocument->getString(i-1); if (ch>line.length()) { mUndoList->addChange( - SynChangeReason::Insert, + ChangeReason::Insert, BufferCoord{line.length(), i}, BufferCoord{line.length()+spaces.length(), i}, QStringList(), @@ -2797,7 +2797,7 @@ void SynEdit::doBlockIndent() line+=spaces; } else { mUndoList->addChange( - SynChangeReason::Insert, + ChangeReason::Insert, BufferCoord{ch, i}, BufferCoord{ch+spaces.length(), i}, QStringList(), @@ -2834,8 +2834,8 @@ void SynEdit::doBlockUnindent() BufferCoord oldCaretPos = caretXY(); int x = 0; mUndoList->beginBlock(); - mUndoList->addChange(SynChangeReason::Caret, oldCaretPos, oldCaretPos,QStringList(), activeSelectionMode()); - mUndoList->addChange(SynChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode()); + mUndoList->addChange(ChangeReason::Caret, oldCaretPos, oldCaretPos,QStringList(), activeSelectionMode()); + mUndoList->addChange(ChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode()); int e = BE.line; // convert selection to complete lines @@ -2863,7 +2863,7 @@ void SynEdit::doBlockUnindent() x = charsToDelete; QString tempString = line.mid(charsToDelete); mDocument->putString(i-1,tempString); - mUndoList->addChange(SynChangeReason::Delete, + mUndoList->addChange(ChangeReason::Delete, BufferCoord{1,i}, BufferCoord{charsToDelete+1,i}, QStringList(line.left(charsToDelete)), @@ -2944,14 +2944,14 @@ void SynEdit::doAddChar(QChar AChar) setBlockBegin(caretXY()); setBlockEnd(caretXY()); mUndoList->addChange( - SynChangeReason::Delete, + ChangeReason::Delete, BufferCoord{1, oldCaretY}, BufferCoord{line.length()+1, oldCaretY}, QStringList(line), SelectionMode::Normal ); mUndoList->addChange( - SynChangeReason::Insert, + ChangeReason::Insert, BufferCoord{1, oldCaretY}, BufferCoord{newLine.length()+1, oldCaretY}, QStringList(), @@ -2970,14 +2970,14 @@ void SynEdit::doAddChar(QChar AChar) setBlockBegin(caretXY()); setBlockEnd(caretXY()); mUndoList->addChange( - SynChangeReason::Delete, + ChangeReason::Delete, BufferCoord{1, oldCaretY}, BufferCoord{line.length()+1, oldCaretY}, QStringList(line), SelectionMode::Normal ); mUndoList->addChange( - SynChangeReason::Insert, + ChangeReason::Insert, BufferCoord{1, oldCaretY}, BufferCoord{newLine.length()+1, oldCaretY}, QStringList(), @@ -3000,14 +3000,14 @@ void SynEdit::doAddChar(QChar AChar) setBlockBegin(caretXY()); setBlockEnd(caretXY()); mUndoList->addChange( - SynChangeReason::Delete, + ChangeReason::Delete, BufferCoord{1, oldCaretY}, BufferCoord{left.length()+1, oldCaretY}, QStringList(left), SelectionMode::Normal ); mUndoList->addChange( - SynChangeReason::Insert, + ChangeReason::Insert, BufferCoord{1, oldCaretY}, BufferCoord{newLeft.length()+1, oldCaretY}, QStringList(""), @@ -4297,16 +4297,16 @@ void SynEdit::doUndo() return; //Remove Group Break; - while (mUndoList->lastChangeReason() == SynChangeReason::GroupBreak) { - PSynEditUndoItem item = mUndoList->popItem(); + while (mUndoList->lastChangeReason() == ChangeReason::GroupBreak) { + PUndoItem item = mUndoList->popItem(); mRedoList->addRedo(item); } - PSynEditUndoItem item = mUndoList->peekItem(); + PUndoItem item = mUndoList->peekItem(); if (item) { size_t oldChangeNumber = item->changeNumber(); { - SynChangeReason lastChange = mUndoList->lastChangeReason(); + ChangeReason lastChange = mUndoList->lastChangeReason(); bool keepGoing; do { doUndoItem(); @@ -4335,7 +4335,7 @@ void SynEdit::doUndoItem() mUndoing = true; bool ChangeScrollPastEol = ! mOptions.testFlag(eoScrollPastEol); - PSynEditUndoItem item = mUndoList->popItem(); + PUndoItem item = mUndoList->popItem(); if (item) { setActiveSelectionMode(item->changeSelMode()); incPaintLock(); @@ -4347,7 +4347,7 @@ void SynEdit::doUndoItem() }); mOptions.setFlag(eoScrollPastEol); switch(item->changeReason()) { - case SynChangeReason::Caret: + case ChangeReason::Caret: mRedoList->addRedo( item->changeReason(), caretXY(), @@ -4356,7 +4356,7 @@ void SynEdit::doUndoItem() item->changeNumber()); internalSetCaretXY(item->changeStartPos()); break; - case SynChangeReason::LeftTop: + case ChangeReason::LeftTop: BufferCoord p; p.ch = leftChar(); p.line = topLine(); @@ -4369,7 +4369,7 @@ void SynEdit::doUndoItem() setLeftChar(item->changeStartPos().ch); setTopLine(item->changeStartPos().line); break; - case SynChangeReason::Selection: + case ChangeReason::Selection: mRedoList->addRedo( item->changeReason(), mBlockBegin, @@ -4379,7 +4379,7 @@ void SynEdit::doUndoItem() item->changeNumber()); setCaretAndSelection(caretXY(), item->changeStartPos(), item->changeEndPos()); break; - case SynChangeReason::Insert: { + case ChangeReason::Insert: { QStringList tmpText = getContent(item->changeStartPos(),item->changeEndPos(),item->changeSelMode()); doDeleteText(item->changeStartPos(),item->changeEndPos(),item->changeSelMode()); mRedoList->addRedo( @@ -4392,7 +4392,7 @@ void SynEdit::doUndoItem() internalSetCaretXY(item->changeStartPos()); break; } - case SynChangeReason::MoveSelectionUp: + case ChangeReason::MoveSelectionUp: setBlockBegin(BufferCoord{item->changeStartPos().ch, item->changeStartPos().line-1}); setBlockEnd(BufferCoord{item->changeEndPos().ch, item->changeEndPos().line-1}); doMoveSelDown(); @@ -4404,7 +4404,7 @@ void SynEdit::doUndoItem() item->changeSelMode(), item->changeNumber()); break; - case SynChangeReason::MoveSelectionDown: + case ChangeReason::MoveSelectionDown: setBlockBegin(BufferCoord{item->changeStartPos().ch, item->changeStartPos().line+1}); setBlockEnd(BufferCoord{item->changeEndPos().ch, item->changeEndPos().line+1}); doMoveSelUp(); @@ -4416,7 +4416,7 @@ void SynEdit::doUndoItem() item->changeSelMode(), item->changeNumber()); break; - case SynChangeReason::Delete: { + case ChangeReason::Delete: { // If there's no selection, we have to set // the Caret's position manualy. // qDebug()<<"undo delete"; @@ -4436,7 +4436,7 @@ void SynEdit::doUndoItem() ensureCursorPosVisible(); break; } - case SynChangeReason::LineBreak:{ + case ChangeReason::LineBreak:{ QString s; if (!item->changeText().isEmpty()) { s=item->changeText()[0]; @@ -4472,17 +4472,17 @@ void SynEdit::doRedo() if (mReadOnly) return; - PSynEditUndoItem item = mRedoList->peekItem(); + PUndoItem item = mRedoList->peekItem(); if (!item) return; size_t oldChangeNumber = item->changeNumber(); //skip group chain breakers - while (mRedoList->lastChangeReason()==SynChangeReason::GroupBreak) { - PSynEditUndoItem item = mRedoList->popItem(); + while (mRedoList->lastChangeReason()==ChangeReason::GroupBreak) { + PUndoItem item = mRedoList->popItem(); mUndoList->restoreChange(item); } - SynChangeReason lastChange = mRedoList->lastChangeReason(); + ChangeReason lastChange = mRedoList->lastChangeReason(); bool keepGoing; do { doRedoItem(); @@ -4502,8 +4502,8 @@ void SynEdit::doRedo() } while (keepGoing); //restore Group Break - while (mRedoList->lastChangeReason()==SynChangeReason::GroupBreak) { - PSynEditUndoItem item = mRedoList->popItem(); + while (mRedoList->lastChangeReason()==ChangeReason::GroupBreak) { + PUndoItem item = mRedoList->popItem(); mUndoList->restoreChange(item); } updateModifiedStatus(); @@ -4514,7 +4514,7 @@ void SynEdit::doRedoItem() { mUndoing = true; bool ChangeScrollPastEol = ! mOptions.testFlag(eoScrollPastEol); - PSynEditUndoItem item = mRedoList->popItem(); + PUndoItem item = mRedoList->popItem(); if (item) { setActiveSelectionMode(item->changeSelMode()); incPaintLock(); @@ -4528,7 +4528,7 @@ void SynEdit::doRedoItem() decPaintLock(); }); switch(item->changeReason()) { - case SynChangeReason::Caret: + case ChangeReason::Caret: mUndoList->restoreChange( item->changeReason(), caretXY(), @@ -4538,7 +4538,7 @@ void SynEdit::doRedoItem() item->changeNumber()); internalSetCaretXY(item->changeStartPos()); break; - case SynChangeReason::LeftTop: + case ChangeReason::LeftTop: BufferCoord p; p.ch = leftChar(); p.line = topLine(); @@ -4551,7 +4551,7 @@ void SynEdit::doRedoItem() setLeftChar(item->changeStartPos().ch); setTopLine(item->changeStartPos().line); break; - case SynChangeReason::Selection: + case ChangeReason::Selection: mUndoList->restoreChange( item->changeReason(), mBlockBegin, @@ -4564,7 +4564,7 @@ void SynEdit::doRedoItem() item->changeStartPos(), item->changeEndPos()); break; - case SynChangeReason::MoveSelectionUp: + case ChangeReason::MoveSelectionUp: setBlockBegin(BufferCoord{item->changeStartPos().ch, item->changeStartPos().line}); setBlockEnd(BufferCoord{item->changeEndPos().ch, item->changeEndPos().line}); doMoveSelUp(); @@ -4576,7 +4576,7 @@ void SynEdit::doRedoItem() item->changeSelMode(), item->changeNumber()); break; - case SynChangeReason::MoveSelectionDown: + case ChangeReason::MoveSelectionDown: setBlockBegin(BufferCoord{item->changeStartPos().ch, item->changeStartPos().line}); setBlockEnd(BufferCoord{item->changeEndPos().ch, item->changeEndPos().line}); doMoveSelDown(); @@ -4588,7 +4588,7 @@ void SynEdit::doRedoItem() item->changeSelMode(), item->changeNumber()); break; - case SynChangeReason::Insert: + case ChangeReason::Insert: setCaretAndSelection( item->changeStartPos(), item->changeStartPos(), @@ -4604,7 +4604,7 @@ void SynEdit::doRedoItem() item->changeSelMode(), item->changeNumber()); break; - case SynChangeReason::Delete: { + case ChangeReason::Delete: { doDeleteText(item->changeStartPos(),item->changeEndPos(),item->changeSelMode()); mUndoList->restoreChange(item->changeReason(), item->changeStartPos(), item->changeEndPos(),item->changeText(), @@ -4612,7 +4612,7 @@ void SynEdit::doRedoItem() internalSetCaretXY(item->changeStartPos()); break; }; - case SynChangeReason::LineBreak: { + case ChangeReason::LineBreak: { BufferCoord CaretPt = item->changeStartPos(); mUndoList->restoreChange(item->changeReason(), item->changeStartPos(), item->changeEndPos(),item->changeText(), @@ -4874,7 +4874,7 @@ void SynEdit::setHighlighter(const PHighlighter &highlighter) invalidate(); } -const PSynDocument& SynEdit::document() const +const PDocument& SynEdit::document() const { return mDocument; } @@ -5432,7 +5432,7 @@ void SynEdit::doDeleteText(BufferCoord startPos, BufferCoord endPos, SelectionMo if (UpdateMarks) doLinesDeleted(startPos.line, endPos.line - startPos.line + MarkOffset); if (!mUndoing) { - mUndoList->addChange(SynChangeReason::Delete, + mUndoList->addChange(ChangeReason::Delete, startPos, endPos, deleted, @@ -5562,7 +5562,7 @@ int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& onLinesPutted(startLine-1,result+1); if (!mUndoing) { mUndoList->addChange( - SynChangeReason::Insert, + ChangeReason::Insert, pos,newPos, QStringList(),SelectionMode::Normal); } @@ -5595,7 +5595,7 @@ int SynEdit::doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& result++; lineBreakPos.line = line - 1; lineBreakPos.ch = mDocument->getString(line - 2).length() + 1; - mUndoList->addChange(SynChangeReason::LineBreak, + mUndoList->addChange(ChangeReason::LineBreak, lineBreakPos, lineBreakPos, QStringList(), SelectionMode::Normal); @@ -5615,7 +5615,7 @@ int SynEdit::doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& // Add undo change here from PasteFromClipboard if (!mUndoing) { mUndoList->addChange( - SynChangeReason::Insert, + ChangeReason::Insert, BufferCoord{insertPos, line}, BufferCoord{insertPos+str.length(), line}, QStringList(), @@ -5659,7 +5659,7 @@ int SynEdit::doInsertTextByLineMode(const BufferCoord& pos, const QStringList& t } if (!mUndoing) { mUndoList->addChange( - SynChangeReason::Insert, + ChangeReason::Insert, BufferCoord{1,pos.line},newPos, QStringList(),SelectionMode::Line); } @@ -6692,7 +6692,7 @@ void SynEdit::onUndoAdded() // we have to clear the redo information, since adding undo info removes // the necessary context to undo earlier edit actions if (! mUndoList->insideRedo() && - mUndoList->peekItem() && (mUndoList->peekItem()->changeReason()!=SynChangeReason::GroupBreak)) + mUndoList->peekItem() && (mUndoList->peekItem()->changeReason()!=ChangeReason::GroupBreak)) mRedoList->clear(); onChanged(); diff --git a/libs/qsynedit/qsynedit/SynEdit.h b/libs/qsynedit/qsynedit/SynEdit.h index e411063e..e3bc9f91 100644 --- a/libs/qsynedit/qsynedit/SynEdit.h +++ b/libs/qsynedit/qsynedit/SynEdit.h @@ -261,7 +261,7 @@ public: void addLeftTopToUndo(); void addSelectionToUndo(); void replaceAll(const QString& text) { - mUndoList->addChange(SynChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode()); + mUndoList->addChange(ChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode()); selectAll(); setSelText(text); } @@ -354,7 +354,7 @@ public: QString lineText() const; void setLineText(const QString s); - const PSynDocument& document() const; + const PDocument& document() const; bool empty(); SelectionMode selectionMode() const; @@ -654,7 +654,7 @@ private: bool mInserting; bool mPainting; - PSynDocument mDocument; + PDocument mDocument; int mLinesInWindow; int mLeftChar; int mPaintLock; // lock counter for internal calculations @@ -677,8 +677,8 @@ private: bool mCaretUseTextColor; QColor mActiveLineColor; - PSynEditUndoList mUndoList; - PSynEditRedoList mRedoList; + PUndoList mUndoList; + PRedoList mRedoList; QPoint mMouseDownPos; bool mHideSelection; int mMouseWheelAccumulator; diff --git a/libs/qsynedit/qsynedit/TextBuffer.cpp b/libs/qsynedit/qsynedit/TextBuffer.cpp index 01cb127a..a496faf3 100644 --- a/libs/qsynedit/qsynedit/TextBuffer.cpp +++ b/libs/qsynedit/qsynedit/TextBuffer.cpp @@ -30,7 +30,7 @@ namespace QSynedit { -SynDocument::SynDocument(const QFont& font, const QFont& nonAsciiFont, QObject *parent): +Document::Document(const QFont& font, const QFont& nonAsciiFont, QObject *parent): QObject(parent), mFontMetrics(font), mNonAsciiFontMetrics(nonAsciiFont), @@ -51,7 +51,7 @@ static void ListIndexOutOfBounds(int index) { -int SynDocument::parenthesisLevels(int Index) +int Document::parenthesisLevels(int Index) { QMutexLocker locker(&mMutex); if (Index>=0 && Index < mLines.size()) { @@ -60,7 +60,7 @@ int SynDocument::parenthesisLevels(int Index) return 0; } -int SynDocument::bracketLevels(int Index) +int Document::bracketLevels(int Index) { QMutexLocker locker(&mMutex); if (Index>=0 && Index < mLines.size()) { @@ -69,7 +69,7 @@ int SynDocument::bracketLevels(int Index) return 0; } -int SynDocument::braceLevels(int Index) +int Document::braceLevels(int Index) { QMutexLocker locker(&mMutex); if (Index>=0 && Index < mLines.size()) { @@ -78,18 +78,7 @@ int SynDocument::braceLevels(int Index) return 0; } -//QString SynEditStringList::expandedStrings(int Index) -//{ -// if (Index>=0 && Index < mList.size()) { -// if (mList[Index]->fFlags & SynEditStringFlag::sfHasNoTabs) -// return mList[Index]->fString; -// else -// return ExpandString(Index); -// } else -// return QString(); -//} - -int SynDocument::lineColumns(int Index) +int Document::lineColumns(int Index) { QMutexLocker locker(&mMutex); if (Index>=0 && Index < mLines.size()) { @@ -101,7 +90,7 @@ int SynDocument::lineColumns(int Index) return 0; } -int SynDocument::leftBraces(int Index) +int Document::leftBraces(int Index) { QMutexLocker locker(&mMutex); if (Index>=0 && Index < mLines.size()) { @@ -110,7 +99,7 @@ int SynDocument::leftBraces(int Index) return 0; } -int SynDocument::rightBraces(int Index) +int Document::rightBraces(int Index) { QMutexLocker locker(&mMutex); if (Index>=0 && Index < mLines.size()) { @@ -119,7 +108,7 @@ int SynDocument::rightBraces(int Index) return 0; } -int SynDocument::lengthOfLongestLine() { +int Document::lengthOfLongestLine() { QMutexLocker locker(&mMutex); if (mIndexOfLongestLine < 0) { int MaxLen = -1; @@ -140,7 +129,7 @@ int SynDocument::lengthOfLongestLine() { return 0; } -QString SynDocument::lineBreak() const +QString Document::lineBreak() const { switch(mFileEndingType) { case FileEndingType::Linux: @@ -153,7 +142,7 @@ QString SynDocument::lineBreak() const return "\n"; } -HighlighterState SynDocument::ranges(int Index) +HighlighterState Document::ranges(int Index) { QMutexLocker locker(&mMutex); if (Index>=0 && Index < mLines.size()) { @@ -164,39 +153,39 @@ HighlighterState SynDocument::ranges(int Index) return HighlighterState(); } -void SynDocument::insertItem(int Index, const QString &s) +void Document::insertItem(int Index, const QString &s) { beginUpdate(); - PSynDocumentLine line = std::make_shared(); + PDocumentLine line = std::make_shared(); line->fString = s; mIndexOfLongestLine = -1; mLines.insert(Index,line); endUpdate(); } -void SynDocument::addItem(const QString &s) +void Document::addItem(const QString &s) { beginUpdate(); - PSynDocumentLine line = std::make_shared(); + PDocumentLine line = std::make_shared(); line->fString = s; mIndexOfLongestLine = -1; mLines.append(line); endUpdate(); } -bool SynDocument::getAppendNewLineAtEOF() +bool Document::getAppendNewLineAtEOF() { QMutexLocker locker(&mMutex); return mAppendNewLineAtEOF; } -void SynDocument::setAppendNewLineAtEOF(bool appendNewLineAtEOF) +void Document::setAppendNewLineAtEOF(bool appendNewLineAtEOF) { QMutexLocker locker(&mMutex); mAppendNewLineAtEOF = appendNewLineAtEOF; } -void SynDocument::setRange(int Index, const HighlighterState& ARange) +void Document::setRange(int Index, const HighlighterState& ARange) { QMutexLocker locker(&mMutex); if (Index<0 || Index>=mLines.count()) { @@ -207,7 +196,7 @@ void SynDocument::setRange(int Index, const HighlighterState& ARange) endUpdate(); } -QString SynDocument::getString(int Index) +QString Document::getString(int Index) { QMutexLocker locker(&mMutex); if (Index<0 || Index>=mLines.count()) { @@ -216,25 +205,25 @@ QString SynDocument::getString(int Index) return mLines[Index]->fString; } -int SynDocument::count() +int Document::count() { QMutexLocker locker(&mMutex); return mLines.count(); } -QString SynDocument::text() +QString Document::text() { QMutexLocker locker(&mMutex); return getTextStr(); } -void SynDocument::setText(const QString &text) +void Document::setText(const QString &text) { QMutexLocker locker(&mMutex); putTextStr(text); } -void SynDocument::setContents(const QStringList &text) +void Document::setContents(const QStringList &text) { QMutexLocker locker(&mMutex); beginUpdate(); @@ -253,18 +242,18 @@ void SynDocument::setContents(const QStringList &text) } } -QStringList SynDocument::contents() +QStringList Document::contents() { QMutexLocker locker(&mMutex); QStringList Result; - SynDocumentLines list = mLines; - foreach (const PSynDocumentLine& line, list) { + DocumentLines list = mLines; + foreach (const PDocumentLine& line, list) { Result.append(line->fString); } return Result; } -void SynDocument::beginUpdate() +void Document::beginUpdate() { if (mUpdateCount == 0) { setUpdateState(true); @@ -272,7 +261,7 @@ void SynDocument::beginUpdate() mUpdateCount++; } -void SynDocument::endUpdate() +void Document::endUpdate() { mUpdateCount--; if (mUpdateCount == 0) { @@ -281,7 +270,7 @@ void SynDocument::endUpdate() } -int SynDocument::add(const QString &s) +int Document::add(const QString &s) { QMutexLocker locker(&mMutex); beginUpdate(); @@ -292,7 +281,7 @@ int SynDocument::add(const QString &s) return Result; } -void SynDocument::addStrings(const QStringList &Strings) +void Document::addStrings(const QStringList &Strings) { QMutexLocker locker(&mMutex); if (Strings.count() > 0) { @@ -310,11 +299,11 @@ void SynDocument::addStrings(const QStringList &Strings) } } -int SynDocument::getTextLength() +int Document::getTextLength() { QMutexLocker locker(&mMutex); int Result = 0; - foreach (const PSynDocumentLine& line, mLines ) { + foreach (const PDocumentLine& line, mLines ) { Result += line->fString.length(); if (mFileEndingType == FileEndingType::Windows) { Result += 2; @@ -325,13 +314,13 @@ int SynDocument::getTextLength() return Result; } -void SynDocument::clear() +void Document::clear() { QMutexLocker locker(&mMutex); internalClear(); } -void SynDocument::deleteLines(int Index, int NumLines) +void Document::deleteLines(int Index, int NumLines) { QMutexLocker locker(&mMutex); if (NumLines<=0) @@ -358,7 +347,7 @@ void SynDocument::deleteLines(int Index, int NumLines) emit deleted(Index,NumLines); } -void SynDocument::exchange(int Index1, int Index2) +void Document::exchange(int Index1, int Index2) { QMutexLocker locker(&mMutex); if ((Index1 < 0) || (Index1 >= mLines.count())) { @@ -368,7 +357,7 @@ void SynDocument::exchange(int Index1, int Index2) ListIndexOutOfBounds(Index2); } beginUpdate(); - PSynDocumentLine temp = mLines[Index1]; + PDocumentLine temp = mLines[Index1]; mLines[Index1]=mLines[Index2]; mLines[Index2]=temp; //mList.swapItemsAt(Index1,Index2); @@ -380,7 +369,7 @@ void SynDocument::exchange(int Index1, int Index2) endUpdate(); } -void SynDocument::insert(int Index, const QString &s) +void Document::insert(int Index, const QString &s) { QMutexLocker locker(&mMutex); if ((Index < 0) || (Index > mLines.count())) { @@ -392,7 +381,7 @@ void SynDocument::insert(int Index, const QString &s) endUpdate(); } -void SynDocument::deleteAt(int Index) +void Document::deleteAt(int Index) { QMutexLocker locker(&mMutex); if ((Index < 0) || (Index >= mLines.count())) { @@ -408,11 +397,11 @@ void SynDocument::deleteAt(int Index) endUpdate(); } -QString SynDocument::getTextStr() const +QString Document::getTextStr() const { QString result; for (int i=0;ifString); result.append(lineBreak()); } @@ -422,7 +411,7 @@ QString SynDocument::getTextStr() const return result; } -void SynDocument::putString(int Index, const QString &s, bool notify) { +void Document::putString(int Index, const QString &s, bool notify) { QMutexLocker locker(&mMutex); if (Index == mLines.count()) { add(s); @@ -446,7 +435,7 @@ void SynDocument::putString(int Index, const QString &s, bool notify) { } } -void SynDocument::setUpdateState(bool Updating) +void Document::setUpdateState(bool Updating) { if (Updating) emit changing(); @@ -454,15 +443,15 @@ void SynDocument::setUpdateState(bool Updating) emit changed(); } -int SynDocument::calculateLineColumns(int Index) +int Document::calculateLineColumns(int Index) { - PSynDocumentLine line = mLines[Index]; + PDocumentLine line = mLines[Index]; line->fColumns = stringColumns(line->fString,0); return line->fColumns; } -void SynDocument::insertLines(int Index, int NumLines) +void Document::insertLines(int Index, int NumLines) { QMutexLocker locker(&mMutex); if (Index<0 || Index>mLines.count()) { @@ -475,17 +464,17 @@ void SynDocument::insertLines(int Index, int NumLines) endUpdate(); }); mIndexOfLongestLine = -1; - PSynDocumentLine line; + PDocumentLine line; mLines.insert(Index,NumLines,line); for (int i=Index;i(); + line = std::make_shared(); mLines[i]=line; } emit inserted(Index,NumLines); } -bool SynDocument::tryLoadFileByEncoding(QByteArray encodingName, QFile& file) { +bool Document::tryLoadFileByEncoding(QByteArray encodingName, QFile& file) { QTextCodec* codec = QTextCodec::codecForName(encodingName); if (!codec) return false; @@ -514,26 +503,26 @@ bool SynDocument::tryLoadFileByEncoding(QByteArray encodingName, QFile& file) { return true; } -const QFontMetrics &SynDocument::fontMetrics() const +const QFontMetrics &Document::fontMetrics() const { return mFontMetrics; } -void SynDocument::setFontMetrics(const QFont &newFont, const QFont& newNonAsciiFont) +void Document::setFontMetrics(const QFont &newFont, const QFont& newNonAsciiFont) { mFontMetrics = QFontMetrics(newFont); mCharWidth = mFontMetrics.horizontalAdvance("M"); mNonAsciiFontMetrics = QFontMetrics(newNonAsciiFont); } -void SynDocument::setTabWidth(int newTabWidth) +void Document::setTabWidth(int newTabWidth) { if (mTabWidth!=newTabWidth) { mTabWidth = newTabWidth; resetColumns(); } } -void SynDocument::loadFromFile(const QString& filename, const QByteArray& encoding, QByteArray& realEncoding) +void Document::loadFromFile(const QString& filename, const QByteArray& encoding, QByteArray& realEncoding) { QMutexLocker locker(&mMutex); QFile file(filename); @@ -660,7 +649,7 @@ void SynDocument::loadFromFile(const QString& filename, const QByteArray& encodi -void SynDocument::saveToFile(QFile &file, const QByteArray& encoding, +void Document::saveToFile(QFile &file, const QByteArray& encoding, const QByteArray& defaultEncoding, QByteArray& realEncoding) { QMutexLocker locker(&mMutex); @@ -686,7 +675,7 @@ void SynDocument::saveToFile(QFile &file, const QByteArray& encoding, } else { codec = QTextCodec::codecForName(realEncoding); } - for (PSynDocumentLine& line:mLines) { + for (PDocumentLine& line:mLines) { if (allAscii) { allAscii = isTextAllAscii(line->fString); } @@ -708,7 +697,7 @@ void SynDocument::saveToFile(QFile &file, const QByteArray& encoding, } } -int SynDocument::stringColumns(const QString &line, int colsBefore) const +int Document::stringColumns(const QString &line, int colsBefore) const { int columns = std::max(0,colsBefore); int charCols; @@ -724,7 +713,7 @@ int SynDocument::stringColumns(const QString &line, int colsBefore) const return columns-colsBefore; } -int SynDocument::charColumns(QChar ch) const +int Document::charColumns(QChar ch) const { if (ch.unicode()<=32) return 1; @@ -737,7 +726,7 @@ int SynDocument::charColumns(QChar ch) const return std::ceil(width / (double)mCharWidth); } -void SynDocument::putTextStr(const QString &text) +void Document::putTextStr(const QString &text) { beginUpdate(); auto action = finally([this]{ @@ -764,7 +753,7 @@ void SynDocument::putTextStr(const QString &text) } } -void SynDocument::internalClear() +void Document::internalClear() { if (!mLines.isEmpty()) { beginUpdate(); @@ -776,25 +765,25 @@ void SynDocument::internalClear() } } -FileEndingType SynDocument::getFileEndingType() +FileEndingType Document::getFileEndingType() { QMutexLocker locker(&mMutex); return mFileEndingType; } -void SynDocument::setFileEndingType(const FileEndingType &fileEndingType) +void Document::setFileEndingType(const FileEndingType &fileEndingType) { QMutexLocker locker(&mMutex); mFileEndingType = fileEndingType; } -bool SynDocument::empty() +bool Document::empty() { QMutexLocker locker(&mMutex); return mLines.count()==0; } -void SynDocument::resetColumns() +void Document::resetColumns() { QMutexLocker locker(&mMutex); mIndexOfLongestLine = -1; @@ -805,16 +794,16 @@ void SynDocument::resetColumns() } } -void SynDocument::invalidAllLineColumns() +void Document::invalidAllLineColumns() { QMutexLocker locker(&mMutex); mIndexOfLongestLine = -1; - for (PSynDocumentLine& line:mLines) { + for (PDocumentLine& line:mLines) { line->fColumns = -1; } } -SynDocumentLine::SynDocumentLine(): +DocumentLine::DocumentLine(): fString(), fRange(), fColumns(-1) @@ -822,7 +811,7 @@ SynDocumentLine::SynDocumentLine(): } -SynEditUndoList::SynEditUndoList():QObject() +UndoList::UndoList():QObject() { mMaxUndoActions = 1024; mMaxMemoryUsage = 50 * 1024 * 1024; @@ -839,7 +828,7 @@ SynEditUndoList::SynEditUndoList():QObject() mLastRestoredItemChangeNumber=0; } -void SynEditUndoList::addChange(SynChangeReason reason, const BufferCoord &startPos, +void UndoList::addChange(ChangeReason reason, const BufferCoord &startPos, const BufferCoord &endPos, const QStringList& changeText, SelectionMode selMode) { @@ -849,7 +838,7 @@ void SynEditUndoList::addChange(SynChangeReason reason, const BufferCoord &start } else { changeNumber = getNextChangeNumber(); } - PSynEditUndoItem newItem = std::make_shared( + PUndoItem newItem = std::make_shared( reason, selMode,startPos,endPos,changeText, changeNumber); @@ -858,22 +847,22 @@ void SynEditUndoList::addChange(SynChangeReason reason, const BufferCoord &start addMemoryUsage(newItem); ensureMaxEntries(); - if (reason!=SynChangeReason::GroupBreak && !inBlock()) { + if (reason!=ChangeReason::GroupBreak && !inBlock()) { mBlockCount++; // qDebug()<<"add"<(AReason, + PUndoItem newItem = std::make_shared(AReason, SelMode,AStart,AEnd,ChangeText, changeNumber); restoreChange(newItem); } -void SynEditUndoList::restoreChange(PSynEditUndoItem item) +void UndoList::restoreChange(PUndoItem item) { size_t changeNumber = item->changeNumber(); mItems.append(item); @@ -889,17 +878,17 @@ void SynEditUndoList::restoreChange(PSynEditUndoItem item) mLastRestoredItemChangeNumber=changeNumber; } -void SynEditUndoList::addGroupBreak() +void UndoList::addGroupBreak() { if (!canUndo()) return; - if (lastChangeReason() != SynChangeReason::GroupBreak) { - addChange(SynChangeReason::GroupBreak, {0,0}, {0,0}, QStringList(), SelectionMode::Normal); + if (lastChangeReason() != ChangeReason::GroupBreak) { + addChange(ChangeReason::GroupBreak, {0,0}, {0,0}, QStringList(), SelectionMode::Normal); } } -void SynEditUndoList::beginBlock() +void UndoList::beginBlock() { // qDebug()<<"begin block"; if (mBlockLock==0) @@ -908,7 +897,7 @@ void SynEditUndoList::beginBlock() } -void SynEditUndoList::clear() +void UndoList::clear() { mItems.clear(); mFullUndoImposible = false; @@ -920,7 +909,7 @@ void SynEditUndoList::clear() mMemoryUsage=0; } -void SynEditUndoList::endBlock() +void UndoList::endBlock() { // qDebug()<<"end block"; if (mBlockLock > 0) { @@ -937,77 +926,69 @@ void SynEditUndoList::endBlock() } } -bool SynEditUndoList::inBlock() +bool UndoList::inBlock() { return mBlockLock>0; } -unsigned int SynEditUndoList::getNextChangeNumber() +unsigned int UndoList::getNextChangeNumber() { return mNextChangeNumber++; } -void SynEditUndoList::addMemoryUsage(PSynEditUndoItem item) +void UndoList::addMemoryUsage(PUndoItem item) { if (!item) return; - int length=0; - foreach (const QString& s, item->changeText()) { - length+=s.length()+2; - } - mMemoryUsage += length * sizeof(QChar) ; + mMemoryUsage += item->memoryUsage(); } -void SynEditUndoList::reduceMemoryUsage(PSynEditUndoItem item) +void UndoList::reduceMemoryUsage(PUndoItem item) { if (!item) return; - int length=0; - foreach (const QString& s, item->changeText()) { - length+=s.length()+2; - } - mMemoryUsage -= length * sizeof(QChar) ; + mMemoryUsage -= item->memoryUsage(); } -int SynEditUndoList::maxMemoryUsage() const +int UndoList::maxMemoryUsage() const { return mMaxMemoryUsage; } -void SynEditUndoList::setMaxMemoryUsage(int newMaxMemoryUsage) +void UndoList::setMaxMemoryUsage(int newMaxMemoryUsage) { mMaxMemoryUsage = newMaxMemoryUsage; } -SynChangeReason SynEditUndoList::lastChangeReason() +ChangeReason UndoList::lastChangeReason() { if (mItems.count() == 0) - return SynChangeReason::Nothing; + return ChangeReason::Nothing; else return mItems.last()->changeReason(); } -bool SynEditUndoList::isEmpty() +bool UndoList::isEmpty() { return mItems.count()==0; } -PSynEditUndoItem SynEditUndoList::peekItem() +PUndoItem UndoList::peekItem() { if (mItems.count() == 0) - return PSynEditUndoItem(); + return PUndoItem(); else return mItems.last(); } -PSynEditUndoItem SynEditUndoList::popItem() +PUndoItem UndoList::popItem() { if (mItems.count() == 0) - return PSynEditUndoItem(); + return PUndoItem(); else { - PSynEditUndoItem item = mItems.last(); + PUndoItem item = mItems.last(); // qDebug()<<"popped"<changeNumber()<changeText()<<(int)item->changeReason()<changeNumber() && item->changeReason()!=SynChangeReason::GroupBreak) { + if (mLastPoppedItemChangeNumber!=item->changeNumber() && item->changeReason()!=ChangeReason::GroupBreak) { mBlockCount--; // qDebug()<<"pop"<0; } -int SynEditUndoList::itemCount() +int UndoList::itemCount() { return mItems.count(); } -int SynEditUndoList::maxUndoActions() const +int UndoList::maxUndoActions() const { return mMaxUndoActions; } -void SynEditUndoList::setMaxUndoActions(int maxUndoActions) +void UndoList::setMaxUndoActions(int maxUndoActions) { if (maxUndoActions!=mMaxUndoActions) { mMaxUndoActions = maxUndoActions; @@ -1045,7 +1026,7 @@ void SynEditUndoList::setMaxUndoActions(int maxUndoActions) } } -bool SynEditUndoList::initialState() +bool UndoList::initialState() { if (itemCount() == 0) { return mInitialChangeNumber==0; @@ -1054,7 +1035,7 @@ bool SynEditUndoList::initialState() } } -void SynEditUndoList::setInitialState() +void UndoList::setInitialState() { if (itemCount() == 0) mInitialChangeNumber = 0; @@ -1062,29 +1043,29 @@ void SynEditUndoList::setInitialState() mInitialChangeNumber = peekItem()->changeNumber(); } -bool SynEditUndoList::insideRedo() const +bool UndoList::insideRedo() const { return mInsideRedo; } -void SynEditUndoList::setInsideRedo(bool insideRedo) +void UndoList::setInsideRedo(bool insideRedo) { mInsideRedo = insideRedo; } -bool SynEditUndoList::fullUndoImposible() const +bool UndoList::fullUndoImposible() const { return mFullUndoImposible; } -void SynEditUndoList::ensureMaxEntries() +void UndoList::ensureMaxEntries() { if (mMaxUndoActions>0 && (mBlockCount > mMaxUndoActions || mMemoryUsage>mMaxMemoryUsage)){ mFullUndoImposible = true; while ((mBlockCount > mMaxUndoActions || mMemoryUsage>mMaxMemoryUsage) && !mItems.isEmpty()) { //remove all undo item in block - PSynEditUndoItem item = mItems.front(); + PUndoItem item = mItems.front(); size_t changeNumber = item->changeNumber(); while (mItems.count()>0) { item = mItems.front(); @@ -1093,38 +1074,43 @@ void SynEditUndoList::ensureMaxEntries() reduceMemoryUsage(item); mItems.removeFirst(); } - if (item->changeReason()!=SynChangeReason::GroupBreak) + if (item->changeReason()!=ChangeReason::GroupBreak) mBlockCount--; } } } -SelectionMode SynEditUndoItem::changeSelMode() const +SelectionMode UndoItem::changeSelMode() const { return mChangeSelMode; } -BufferCoord SynEditUndoItem::changeStartPos() const +BufferCoord UndoItem::changeStartPos() const { return mChangeStartPos; } -BufferCoord SynEditUndoItem::changeEndPos() const +BufferCoord UndoItem::changeEndPos() const { return mChangeEndPos; } -QStringList SynEditUndoItem::changeText() const +QStringList UndoItem::changeText() const { return mChangeText; } -size_t SynEditUndoItem::changeNumber() const +size_t UndoItem::changeNumber() const { return mChangeNumber; } -SynEditUndoItem::SynEditUndoItem(SynChangeReason reason, SelectionMode selMode, +unsigned int UndoItem::memoryUsage() const +{ + return mMemoryUsage; +} + +UndoItem::UndoItem(ChangeReason reason, SelectionMode selMode, BufferCoord startPos, BufferCoord endPos, const QStringList& text, int number) { @@ -1134,75 +1120,81 @@ SynEditUndoItem::SynEditUndoItem(SynChangeReason reason, SelectionMode selMode, mChangeEndPos = endPos; mChangeText = text; mChangeNumber = number; + int length=0; + foreach (const QString& s, text) { + length+=s.length(); + } + mMemoryUsage -= length * sizeof(QChar) + text.length() * sizeof(QString) + + sizeof(UndoItem); } -SynChangeReason SynEditUndoItem::changeReason() const +ChangeReason UndoItem::changeReason() const { return mChangeReason; } -SynEditRedoList::SynEditRedoList() +RedoList::RedoList() { } -void SynEditRedoList::addRedo(SynChangeReason AReason, const BufferCoord &AStart, const BufferCoord &AEnd, const QStringList &ChangeText, SelectionMode SelMode, size_t changeNumber) +void RedoList::addRedo(ChangeReason AReason, const BufferCoord &AStart, const BufferCoord &AEnd, const QStringList &ChangeText, SelectionMode SelMode, size_t changeNumber) { - PSynEditUndoItem newItem = std::make_shared( + PUndoItem newItem = std::make_shared( AReason, SelMode,AStart,AEnd,ChangeText, changeNumber); mItems.append(newItem); } -void SynEditRedoList::addRedo(PSynEditUndoItem item) +void RedoList::addRedo(PUndoItem item) { mItems.append(item); } -void SynEditRedoList::clear() +void RedoList::clear() { mItems.clear(); } -SynChangeReason SynEditRedoList::lastChangeReason() +ChangeReason RedoList::lastChangeReason() { if (mItems.count() == 0) - return SynChangeReason::Nothing; + return ChangeReason::Nothing; else return mItems.last()->changeReason(); } -bool SynEditRedoList::isEmpty() +bool RedoList::isEmpty() { return mItems.isEmpty(); } -PSynEditUndoItem SynEditRedoList::peekItem() +PUndoItem RedoList::peekItem() { if (mItems.count() == 0) - return PSynEditUndoItem(); + return PUndoItem(); else return mItems.last(); } -PSynEditUndoItem SynEditRedoList::popItem() +PUndoItem RedoList::popItem() { if (mItems.count() == 0) - return PSynEditUndoItem(); + return PUndoItem(); else { - PSynEditUndoItem item = mItems.last(); + PUndoItem item = mItems.last(); mItems.removeLast(); return item; } } -bool SynEditRedoList::canRedo() +bool RedoList::canRedo() { return mItems.count()>0; } -int SynEditRedoList::itemCount() +int RedoList::itemCount() { return mItems.count(); } diff --git a/libs/qsynedit/qsynedit/TextBuffer.h b/libs/qsynedit/qsynedit/TextBuffer.h index a23c2818..c33aa024 100644 --- a/libs/qsynedit/qsynedit/TextBuffer.h +++ b/libs/qsynedit/qsynedit/TextBuffer.h @@ -29,38 +29,31 @@ #include "qt_utils/utils.h" namespace QSynedit { -enum SynEditStringFlag { - sfHasTabs = 0x0001, - sfHasNoTabs = 0x0002, - sfExpandedLengthUnknown = 0x0004 -}; -typedef int SynEditStringFlags; - -struct SynDocumentLine { +struct DocumentLine { QString fString; HighlighterState fRange; int fColumns; // public: - explicit SynDocumentLine(); + explicit DocumentLine(); }; -typedef std::shared_ptr PSynDocumentLine; +typedef std::shared_ptr PDocumentLine; -typedef QVector SynDocumentLines; +typedef QVector DocumentLines; -typedef std::shared_ptr PSynDocumentLines; +typedef std::shared_ptr PDocumentLines; -class SynDocument; +class Document; -typedef std::shared_ptr PSynDocument; +typedef std::shared_ptr PDocument; -class SynDocument : public QObject +class Document : public QObject { Q_OBJECT public: - explicit SynDocument(const QFont& font, const QFont& nonAsciiFont, QObject* parent=nullptr); + explicit Document(const QFont& font, const QFont& nonAsciiFont, QObject* parent=nullptr); int parenthesisLevels(int Index); int bracketLevels(int Index); @@ -139,7 +132,7 @@ private: bool tryLoadFileByEncoding(QByteArray encodingName, QFile& file); private: - SynDocumentLines mLines; + DocumentLines mLines; //SynEdit* mEdit; @@ -158,7 +151,7 @@ private: int calculateLineColumns(int Index); }; -enum class SynChangeReason { +enum class ChangeReason { Insert, Delete, Caret, //just restore the Caret, allowing better Undo behavior @@ -171,54 +164,56 @@ enum class SynChangeReason { Nothing // undo list empty }; -class SynEditUndoItem { +class UndoItem { private: - SynChangeReason mChangeReason; + ChangeReason mChangeReason; SelectionMode mChangeSelMode; BufferCoord mChangeStartPos; BufferCoord mChangeEndPos; QStringList mChangeText; size_t mChangeNumber; + unsigned int mMemoryUsage; public: - SynEditUndoItem(SynChangeReason reason, + UndoItem(ChangeReason reason, SelectionMode selMode, BufferCoord startPos, BufferCoord endPos, const QStringList& text, int number); - SynChangeReason changeReason() const; + ChangeReason changeReason() const; SelectionMode changeSelMode() const; BufferCoord changeStartPos() const; BufferCoord changeEndPos() const; QStringList changeText() const; size_t changeNumber() const; + unsigned int memoryUsage() const; }; -using PSynEditUndoItem = std::shared_ptr; +using PUndoItem = std::shared_ptr; -class SynEditUndoList : public QObject { +class UndoList : public QObject { Q_OBJECT public: - explicit SynEditUndoList(); + explicit UndoList(); - void addChange(SynChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd, - const QStringList& ChangeText, SelectionMode SelMode); + void addChange(ChangeReason reason, const BufferCoord& start, const BufferCoord& end, + const QStringList& changeText, SelectionMode selMode); - void restoreChange(SynChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd, - const QStringList& ChangeText, SelectionMode SelMode, size_t changeNumber); + void restoreChange(ChangeReason reason, const BufferCoord& start, const BufferCoord& end, + const QStringList& changeText, SelectionMode selMode, size_t changeNumber); - void restoreChange(PSynEditUndoItem item); + void restoreChange(PUndoItem item); void addGroupBreak(); void beginBlock(); void endBlock(); void clear(); - SynChangeReason lastChangeReason(); + ChangeReason lastChangeReason(); bool isEmpty(); - PSynEditUndoItem peekItem(); - PSynEditUndoItem popItem(); + PUndoItem peekItem(); + PUndoItem popItem(); bool canUndo(); int itemCount(); @@ -242,8 +237,8 @@ protected: void ensureMaxEntries(); bool inBlock(); unsigned int getNextChangeNumber(); - void addMemoryUsage(PSynEditUndoItem item); - void reduceMemoryUsage(PSynEditUndoItem item); + void addMemoryUsage(PUndoItem item); + void reduceMemoryUsage(PUndoItem item); protected: size_t mBlockChangeNumber; int mBlockLock; @@ -252,7 +247,7 @@ protected: size_t mLastPoppedItemChangeNumber; size_t mLastRestoredItemChangeNumber; bool mFullUndoImposible; - QVector mItems; + QVector mItems; int mMaxUndoActions; int mMaxMemoryUsage; size_t mNextChangeNumber; @@ -260,31 +255,31 @@ protected: bool mInsideRedo; }; -class SynEditRedoList : public QObject { +class RedoList : public QObject { Q_OBJECT public: - explicit SynEditRedoList(); + explicit RedoList(); - void addRedo(SynChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd, + void addRedo(ChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd, const QStringList& ChangeText, SelectionMode SelMode, size_t changeNumber); - void addRedo(PSynEditUndoItem item); + void addRedo(PUndoItem item); void clear(); - SynChangeReason lastChangeReason(); + ChangeReason lastChangeReason(); bool isEmpty(); - PSynEditUndoItem peekItem(); - PSynEditUndoItem popItem(); + PUndoItem peekItem(); + PUndoItem popItem(); bool canRedo(); int itemCount(); protected: - QVector mItems; + QVector mItems; }; -using PSynEditUndoList = std::shared_ptr; -using PSynEditRedoList = std::shared_ptr; +using PUndoList = std::shared_ptr; +using PRedoList = std::shared_ptr; } diff --git a/libs/qsynedit/qsynedit/exporter/synexporter.cpp b/libs/qsynedit/qsynedit/exporter/synexporter.cpp index f2ffe454..f91f5c82 100644 --- a/libs/qsynedit/qsynedit/exporter/synexporter.cpp +++ b/libs/qsynedit/qsynedit/exporter/synexporter.cpp @@ -53,12 +53,12 @@ void SynExporter::CopyToClipboard() CopyToClipboardFormat(clipboardFormat()); } -void SynExporter::ExportAll(PSynDocument ALines) +void SynExporter::ExportAll(PDocument ALines) { ExportRange(ALines, BufferCoord{1, 1}, BufferCoord{INT_MAX, INT_MAX}); } -void SynExporter::ExportRange(PSynDocument ALines, BufferCoord Start, BufferCoord Stop) +void SynExporter::ExportRange(PDocument ALines, BufferCoord Start, BufferCoord Stop) { // abort if not all necessary conditions are met if (!ALines || !mHighlighter || (ALines->count() == 0)) diff --git a/libs/qsynedit/qsynedit/exporter/synexporter.h b/libs/qsynedit/qsynedit/exporter/synexporter.h index 62ed0d71..e7f15a84 100644 --- a/libs/qsynedit/qsynedit/exporter/synexporter.h +++ b/libs/qsynedit/qsynedit/exporter/synexporter.h @@ -43,7 +43,7 @@ public: * @brief Exports everything in the strings parameter to the output buffer. * @param ALines */ - void ExportAll(PSynDocument ALines); + void ExportAll(PDocument ALines); /** * @brief Exports the given range of the strings parameter to the output buffer. @@ -51,7 +51,7 @@ public: * @param Start * @param Stop */ - void ExportRange(PSynDocument ALines, + void ExportRange(PDocument ALines, BufferCoord Start, BufferCoord Stop); /** * @brief Saves the contents of the output buffer to a file.