- enhancement: set compilation stage in the options / compiler set pages
- enhancement: set custom compilation output suffix in the options / compiler set pages
This commit is contained in:
parent
5f0371cb5b
commit
7883397409
6
NEWS.md
6
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
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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<CompileSuccessionTask>();
|
||||
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.")+"<BR/><BR/>"
|
||||
+tr("We need the executabe to run problem case."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1821,6 +1849,7 @@ void MainWindow::debug()
|
|||
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
|
||||
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<CompileSuccessionTask>();
|
||||
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<CompileSuccessionTask>();
|
||||
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.")+"<BR /><BR />"
|
||||
+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.")+"<BR/><BR/>"
|
||||
+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.")+"<BR /><BR />"
|
||||
+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
|
||||
|
|
|
@ -90,6 +90,7 @@ class MainWindow : public QMainWindow
|
|||
CompileSuccessionTaskType type;
|
||||
QString execName;
|
||||
QStringList binDirs;
|
||||
bool isExecutable;
|
||||
};
|
||||
|
||||
using PCompileSuccessionTask = std::shared_ptr<CompileSuccessionTask>;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<QString, QString> &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();
|
||||
|
|
|
@ -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<QString, QString> &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<QString,QString> mCompileOptions;
|
||||
};
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="settingTabs">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>false</bool>
|
||||
|
@ -240,19 +240,6 @@
|
|||
<string>Programs</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
|
@ -451,6 +438,102 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabOutput">
|
||||
<attribute name="title">
|
||||
<string>Output</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="txtExecutableSuffix"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="txtCompilationSuffix"/>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Compilation Stages</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbPreprocessingOnly">
|
||||
<property name="text">
|
||||
<string>Stop after the preprocessing stage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbCompilationProperOnly">
|
||||
<property name="text">
|
||||
<string>Stop after the compilation proper stage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbGenerateExecutable">
|
||||
<property name="text">
|
||||
<string>Link and generate the executable </string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="txtPreprocessingSuffix"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Executable suffix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Preprocessing output suffix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Compiling output suffix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -91,7 +91,7 @@ void SettingsWidget::disconnectAbstractItemView(QAbstractItemView *pView)
|
|||
|
||||
}
|
||||
|
||||
void SettingsWidget::updateIcons(const QSize &)
|
||||
void SettingsWidget::updateIcons(const QSize & /*size*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -585,7 +585,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>TextLabel</source>
|
||||
<translation>Label</translation>
|
||||
<translation type="vanished">Label</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose make</source>
|
||||
|
@ -687,6 +687,46 @@
|
|||
<source>New name</source>
|
||||
<translation>Novo nome</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Output</source>
|
||||
<translation type="unfinished">Saída</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Compilation Stages</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stop after the preprocessing stage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stop after the compilation proper stage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stop after the assembling stage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Link and generate the executable </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Preprocessing output suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Assembling output suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Compiling output suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>CppRefacter</name>
|
||||
|
@ -4604,6 +4644,22 @@
|
|||
<source>Template %1 already exists. Do you want to overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Wrong Compiler Settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Compiler is set not to generate executable.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>We need the executabe to run problem case.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please correct this before start debugging</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NewClassDialog</name>
|
||||
|
@ -5842,7 +5898,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Link an Objective C program (-lobjc)</source>
|
||||
<translation>Link para um programa Objective C (-lobjc)</translation>
|
||||
<translation type="vanished">Link para um programa Objective C (-lobjc)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do not use standard system libraries (-nostdlib)</source>
|
||||
|
@ -5862,11 +5918,11 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Output</source>
|
||||
<translation>Saída</translation>
|
||||
<translation type="vanished">Saída</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Put comments in generated assembly code (-fverbose-asm)</source>
|
||||
<translation>Colocar comentários no código gerado em assembly (-fverbose-asm)</translation>
|
||||
<translation type="vanished">Colocar comentários no código gerado em assembly (-fverbose-asm)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do not assemble, compile and generate the assembly code (-S)</source>
|
||||
|
@ -5974,7 +6030,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Do not compile, stop after the preprocessing stage (-E)</source>
|
||||
<translation>Não compilar, parar após o estágio de preprocessamento (-E)</translation>
|
||||
<translation type="vanished">Não compilar, parar após o estágio de preprocessamento (-E)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Leaving those directories will lead to problems during compilation.</source>
|
||||
|
@ -5984,10 +6040,6 @@
|
|||
<source>Gloabal Variable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do not assemble, compile and generate the assemble code (-S)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Compiler set not configuared.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -512,10 +512,6 @@
|
|||
<source>Programs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TextLabel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose make</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -616,6 +612,46 @@
|
|||
<source>New name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Output</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Compilation Stages</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stop after the preprocessing stage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stop after the compilation proper stage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stop after the assembling stage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Link and generate the executable </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Preprocessing output suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Assembling output suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Compiling output suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable suffix</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>CppRefacter</name>
|
||||
|
@ -4497,6 +4533,22 @@
|
|||
<source>Template %1 already exists. Do you want to overwrite?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Wrong Compiler Settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Compiler is set not to generate executable.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>We need the executabe to run problem case.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please correct this before start debugging</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NewClassDialog</name>
|
||||
|
@ -5713,10 +5765,6 @@
|
|||
<source>Linker</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Link an Objective C program (-lobjc)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do not use standard system libraries (-nostdlib)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -5733,18 +5781,6 @@
|
|||
<source>Generate debugging information (-g3)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Output</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Put comments in generated assembly code (-fverbose-asm)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do not assemble, compile and generate the assemble code (-S)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Use pipes instead of temporary files during compilation (-pipe)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -5841,10 +5877,6 @@
|
|||
<source>This CPU</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do not compile, stop after the preprocessing stage (-E)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Leaving those directories will lead to problems during compilation.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
|
|
@ -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("<EXENAME>", extractFileName(changeFileExt(e->filename(),EXECUTABLE_EXT)));
|
||||
result.replace("<EXEFILE>", localizePath(changeFileExt(e->filename(),EXECUTABLE_EXT)));
|
||||
result.replace("<PROJECTNAME>", extractFileName(e->filename()));
|
||||
result.replace("<PROJECTFILE>", localizePath(e->filename()));
|
||||
result.replace("<PROJECTFILENAME>", extractFileName(e->filename()));
|
||||
result.replace("<PROJECTPATH>", localizePath(extractFileDir(e->filename())));
|
||||
QString exeSuffix;
|
||||
Settings::PCompilerSet compilerSet = pSettings->compilerSets().defaultSet();
|
||||
if (compilerSet) {
|
||||
exeSuffix = compilerSet->executableSuffix();
|
||||
} else {
|
||||
exeSuffix = DEFAULT_EXECUTABLE_SUFFIX;
|
||||
}
|
||||
result.replace("<EXENAME>", extractFileName(changeFileExt(e->filename(), exeSuffix)));
|
||||
result.replace("<EXEFILE>", localizePath(changeFileExt(e->filename(), exeSuffix)));
|
||||
result.replace("<PROJECTNAME>", extractFileName(e->filename()));
|
||||
result.replace("<PROJECTFILE>", localizePath(e->filename()));
|
||||
result.replace("<PROJECTFILENAME>", extractFileName(e->filename()));
|
||||
result.replace("<PROJECTPATH>", localizePath(extractFileDir(e->filename())));
|
||||
} else if (pMainWindow->project()) {
|
||||
result.replace("<EXENAME>", extractFileName(pMainWindow->project()->executable()));
|
||||
result.replace("<EXEFILE>", localizePath(pMainWindow->project()->executable()));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -37,6 +37,8 @@ public:
|
|||
|
||||
void resetUI(Settings::PCompilerSet pSet, const QMap<QString,QString>& options);
|
||||
|
||||
void setBoolArgument(const QString &argKey, bool checked);
|
||||
|
||||
private:
|
||||
QString mCompilerType;
|
||||
};
|
||||
|
|
|
@ -63,23 +63,23 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent),
|
|||
#error "Not supported!"
|
||||
#endif
|
||||
mFontDummy.setStyleStrategy(QFont::PreferAntialias);
|
||||
mDocument = std::make_shared<SynDocument>(mFontDummy, mFontDummy, this);
|
||||
mDocument = std::make_shared<Document>(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<SynEditUndoList>();
|
||||
mUndoList->connect(mUndoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::onUndoAdded);
|
||||
mRedoList = std::make_shared<SynEditRedoList>();
|
||||
mUndoList = std::make_shared<UndoList>();
|
||||
mUndoList->connect(mUndoList.get(), &UndoList::addedUndo, this, &SynEdit::onUndoAdded);
|
||||
mRedoList = std::make_shared<RedoList>();
|
||||
// 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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<SynDocumentLine>();
|
||||
PDocumentLine line = std::make_shared<DocumentLine>();
|
||||
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<SynDocumentLine>();
|
||||
PDocumentLine line = std::make_shared<DocumentLine>();
|
||||
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;i<mLines.count()-1;i++) {
|
||||
const PSynDocumentLine& line = mLines[i];
|
||||
const PDocumentLine& line = mLines[i];
|
||||
result.append(line->fString);
|
||||
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<Index+NumLines;i++) {
|
||||
line = std::make_shared<SynDocumentLine>();
|
||||
line = std::make_shared<DocumentLine>();
|
||||
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<SynEditUndoItem>(
|
||||
PUndoItem newItem = std::make_shared<UndoItem>(
|
||||
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"<<mBlockCount;
|
||||
emit addedUndo();
|
||||
}
|
||||
}
|
||||
|
||||
void SynEditUndoList::restoreChange(SynChangeReason AReason, const BufferCoord &AStart, const BufferCoord &AEnd, const QStringList &ChangeText, SelectionMode SelMode, size_t changeNumber)
|
||||
void UndoList::restoreChange(ChangeReason AReason, const BufferCoord &AStart, const BufferCoord &AEnd, const QStringList &ChangeText, SelectionMode SelMode, size_t changeNumber)
|
||||
{
|
||||
PSynEditUndoItem newItem = std::make_shared<SynEditUndoItem>(AReason,
|
||||
PUndoItem newItem = std::make_shared<UndoItem>(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"<<item->changeNumber()<<item->changeText()<<(int)item->changeReason()<<mLastPoppedItemChangeNumber;
|
||||
if (mLastPoppedItemChangeNumber!=item->changeNumber() && item->changeReason()!=SynChangeReason::GroupBreak) {
|
||||
if (mLastPoppedItemChangeNumber!=item->changeNumber() && item->changeReason()!=ChangeReason::GroupBreak) {
|
||||
mBlockCount--;
|
||||
// qDebug()<<"pop"<<mBlockCount;
|
||||
if (mBlockCount<0) {
|
||||
|
@ -1022,22 +1003,22 @@ PSynEditUndoItem SynEditUndoList::popItem()
|
|||
}
|
||||
}
|
||||
|
||||
bool SynEditUndoList::canUndo()
|
||||
bool UndoList::canUndo()
|
||||
{
|
||||
return mItems.count()>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<SynEditUndoItem>(
|
||||
PUndoItem newItem = std::make_shared<UndoItem>(
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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<SynDocumentLine> PSynDocumentLine;
|
||||
typedef std::shared_ptr<DocumentLine> PDocumentLine;
|
||||
|
||||
typedef QVector<PSynDocumentLine> SynDocumentLines;
|
||||
typedef QVector<PDocumentLine> DocumentLines;
|
||||
|
||||
typedef std::shared_ptr<SynDocumentLines> PSynDocumentLines;
|
||||
typedef std::shared_ptr<DocumentLines> PDocumentLines;
|
||||
|
||||
class SynDocument;
|
||||
class Document;
|
||||
|
||||
typedef std::shared_ptr<SynDocument> PSynDocument;
|
||||
typedef std::shared_ptr<Document> 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<SynEditUndoItem>;
|
||||
using PUndoItem = std::shared_ptr<UndoItem>;
|
||||
|
||||
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<PSynEditUndoItem> mItems;
|
||||
QVector<PUndoItem> 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<PSynEditUndoItem> mItems;
|
||||
QVector<PUndoItem> mItems;
|
||||
};
|
||||
|
||||
|
||||
using PSynEditUndoList = std::shared_ptr<SynEditUndoList>;
|
||||
using PSynEditRedoList = std::shared_ptr<SynEditRedoList>;
|
||||
using PUndoList = std::shared_ptr<UndoList>;
|
||||
using PRedoList = std::shared_ptr<RedoList>;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue