Merge branch 'master' of github.com:royqh1979/RedPanda-CPP

This commit is contained in:
Roy Qu 2022-12-15 15:42:22 +08:00
commit 47e40d2f8e
14 changed files with 701 additions and 455 deletions

11
NEWS.md
View File

@ -11,7 +11,16 @@ Red Panda C++ Version 2.6
- enhancement: Prevent error of "del" to stop make when rebuild project.
- enhancement: Import FPS (free problem set) files.
- enhancement: Show current problem's description in the problem list's mouse tip.
- enhancement: Show memory usage for problem cases.
- enhancement: Show memory usage for problem cases (windows only).
- enhancement: Show memory usage after console program exited.
- fix: If clang and g++ are in the same folder, only the compiler sets for gcc are auto generated.
- fix: Buttons in options -> compiler -> compiler set -> programs are not usable.
- enhancement: Don't check existence of gcc/g++/make/gdb at startup.
- enhancement: Auto disable "compile" button if gcc doesn't exist.
- enhancement: Auto disable "debug" button if gdb doesn't exist.
- enhancement: Auto disable "compile" button for project if make doesn't exist.
- fix: Crash when scroll file which has more than 65535 lines.
- fix: Can't scroll to lines greater than 65535.
Red Panda C++ Version 2.5

View File

@ -54,7 +54,8 @@ enum class CompilerSetType {
enum class CompilerType {
GCC,
GCC_UTF8,
Clang
Clang,
Unknown
};
using CompileOptionChoiceList = QList<QPair<QString,QString>>;

View File

@ -30,7 +30,10 @@ StdinCompiler::StdinCompiler(const QString &filename,const QByteArray& encoding,
bool StdinCompiler::prepareForCompile()
{
if (mOnlyCheckSyntax)
log(tr("Checking file syntax..."));
else
log(tr("Compiling..."));
log("------------------");
log(tr("- Filename: %1").arg(mFilename));
log(tr("- Compiler Set Name: %1").arg(compilerSet()->name()));
@ -68,7 +71,10 @@ bool StdinCompiler::prepareForCompile()
mArguments += getLibraryArguments(fileType);
if (!fileExists(mCompiler)) {
if (!mOnlyCheckSyntax)
throw CompileError(tr("The Compiler '%1' doesn't exists!").arg(mCompiler));
else
return false;
}
log(tr("Processing %1 source file:").arg(strFileType));

View File

@ -650,14 +650,28 @@ void MainWindow::updateCompileActions()
bool forProject=false;
bool canCompile = false;
bool canRun = false;
bool canDebug = false;
Editor * e = mEditorList->getEditor();
if (e) {
if (!e->inProject()) {
FileType fileType = getFileType(e->filename());
if (fileType == FileType::CSource
|| fileType == FileType::CppSource || e->isNew()) {
canCompile = true;
canRun = true;
Settings::PCompilerSet set = pSettings->compilerSets().defaultSet();
if (set) {
canDebug = set->canDebug();
switch(fileType) {
case FileType::CSource:
canCompile = set->canCompileC();
break;
case FileType::CppSource:
canCompile = set->canCompileCPP();
break;
default:
break;
}
}
}
} else {
forProject = (mProject!=nullptr);
@ -666,9 +680,13 @@ void MainWindow::updateCompileActions()
forProject = (mProject!=nullptr);
}
if (forProject) {
canCompile = true;
canRun = (mProject->options().type !=ProjectType::DynamicLib)
&& (mProject->options().type !=ProjectType::StaticLib);
Settings::PCompilerSet set = pSettings->compilerSets().getSet(mProject->options().compilerSet);
if (set) {
canDebug = set->canDebug();
canCompile = set->canMake();
}
}
if (mCompilerManager->compiling() || mCompilerManager->running() || mDebugger->executing()
|| (!canCompile)) {
@ -681,11 +699,11 @@ void MainWindow::updateCompileActions()
ui->btnRunAllProblemCases->setEnabled(false);
} else {
ui->actionCompile->setEnabled(true);
ui->actionCompile_Run->setEnabled(canRun);
ui->actionCompile_Run->setEnabled(canRun && canCompile);
ui->actionRun->setEnabled(canRun);
ui->actionRebuild->setEnabled(true);
ui->actionGenerate_Assembly->setEnabled(!forProject);
ui->actionDebug->setEnabled(canRun);
ui->actionDebug->setEnabled(canDebug);
ui->btnRunAllProblemCases->setEnabled(canRun);
}
if (!mDebugger->executing()) {
@ -5170,6 +5188,7 @@ void MainWindow::onCompilerSetChanged(int index)
if (index<0)
return;
Editor *e = mEditorList->getEditor();
updateCompileActions();
if ( mProject && (!e || e->inProject())
) {
if (index==mProject->options().compilerSet)

View File

@ -1544,9 +1544,11 @@ void Settings::Editor::setTabToSpaces(bool tabToSpaces)
Settings::CompilerSet::CompilerSet():
mFullLoaded(false),
mAutoAddCharsetParams(true),
mCompilerType(CompilerType::Unknown),
mCompilerSetType(CompilerSetType::RELEASE),
mAutoAddCharsetParams(false),
mExecCharset(ENCODING_SYSTEM_DEFAULT),
mStaticLink(true),
mStaticLink(false),
mPreprocessingSuffix(DEFAULT_PREPROCESSING_SUFFIX),
mCompilationProperSuffix(DEFAULT_COMPILATION_SUFFIX),
mAssemblingSuffix(DEFAULT_ASSEMBLING_SUFFIX),
@ -1557,7 +1559,7 @@ Settings::CompilerSet::CompilerSet():
}
Settings::CompilerSet::CompilerSet(const QString& compilerFolder, const QString& cc_prog):
Settings::CompilerSet::CompilerSet(const QString& compilerFolder, const QString& c_prog):
mAutoAddCharsetParams(true),
mExecCharset(ENCODING_SYSTEM_DEFAULT),
mStaticLink(true),
@ -1568,7 +1570,7 @@ Settings::CompilerSet::CompilerSet(const QString& compilerFolder, const QString&
mCompilationStage(Settings::CompilerSet::CompilationStage::GenerateExecutable)
{
if (QDir(compilerFolder).exists()) {
setProperties(compilerFolder, cc_prog);
setProperties(compilerFolder, c_prog);
//manually set the directories
setDirectories(compilerFolder, mCompilerType);
@ -1770,34 +1772,34 @@ bool Settings::CompilerSet::dirsValid(QString &msg)
return true;
}
bool Settings::CompilerSet::validateExes(QString &msg)
{
msg ="";
if (!fileExists(mCCompiler)) {
msg += QObject::tr("Cannot find the %1 \"%2\"")
.arg(QObject::tr("C Compiler"))
.arg(mCCompiler);
}
if (!fileExists(mCppCompiler)) {
msg += QObject::tr("Cannot find the %1 \"%2\"")
.arg(QObject::tr("C++ Compiler"))
.arg(mCppCompiler);
}
if (!mMake.isEmpty() && !fileExists(mMake)) {
msg += QObject::tr("Cannot find the %1 \"%2\"")
.arg(QObject::tr("Maker"))
.arg(mMake);
}
if (!fileExists(mDebugger)) {
msg += QObject::tr("Cannot find the %1 \"%2\"")
.arg(QObject::tr("Debugger"))
.arg(mDebugger);
}
if (!msg.isEmpty())
return false;
else
return true;
}
//bool Settings::CompilerSet::validateExes(QString &msg)
//{
// msg ="";
// if (!fileExists(mCCompiler)) {
// msg += QObject::tr("Cannot find the %1 \"%2\"")
// .arg(QObject::tr("C Compiler"))
// .arg(mCCompiler);
// }
// if (!fileExists(mCppCompiler)) {
// msg += QObject::tr("Cannot find the %1 \"%2\"")
// .arg(QObject::tr("C++ Compiler"))
// .arg(mCppCompiler);
// }
// if (!mMake.isEmpty() && !fileExists(mMake)) {
// msg += QObject::tr("Cannot find the %1 \"%2\"")
// .arg(QObject::tr("Maker"))
// .arg(mMake);
// }
// if (!fileExists(mDebugger)) {
// msg += QObject::tr("Cannot find the %1 \"%2\"")
// .arg(QObject::tr("Debugger"))
// .arg(mDebugger);
// }
// if (!msg.isEmpty())
// return false;
// else
// return true;
//}
const QString &Settings::CompilerSet::CCompiler() const
{
@ -1806,7 +1808,17 @@ const QString &Settings::CompilerSet::CCompiler() const
void Settings::CompilerSet::setCCompiler(const QString &name)
{
if (mCCompiler!=name) {
mCCompiler = name;
if (mCompilerType == CompilerType::Unknown) {
QString temp=extractFileName(mCCompiler);
if (temp == CLANG_PROGRAM) {
setCompilerType(CompilerType::Clang);
} else if (temp == GCC_PROGRAM) {
setCompilerType(CompilerType::GCC);
}
}
}
}
const QString &Settings::CompilerSet::cppCompiler() const
@ -2051,21 +2063,15 @@ static void addExistingDirectory(QStringList& dirs, const QString& directory) {
dirs.append(dirPath);
}
void Settings::CompilerSet::setProperties(const QString &binDir, const QString& cc_prog)
void Settings::CompilerSet::setProperties(const QString &binDir, const QString& c_prog)
{
if (cc_prog.isEmpty())
if (c_prog.isEmpty())
return;
// QString cc_prog;
// if (fileExists(binDir, CLANG_PROGRAM))
// cc_prog = CLANG_PROGRAM;
// else if (fileExists(binDir,GCC_PROGRAM))
// cc_prog = GCC_PROGRAM;
// else
// return;
// Obtain version number and compiler distro etc
QStringList arguments;
arguments.append("-v");
QByteArray output = getCompilerOutput(binDir,cc_prog,arguments);
QByteArray output = getCompilerOutput(binDir,c_prog,arguments);
//Target
QByteArray targetStr = "Target: ";
@ -2169,7 +2175,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir, const QString&
// Obtain compiler target
arguments.clear();
arguments.append("-dumpmachine");
mDumpMachine = getCompilerOutput(binDir, cc_prog, arguments);
mDumpMachine = getCompilerOutput(binDir, c_prog, arguments);
// Add the default directories
addExistingDirectory(mBinDirs, includeTrailingPathDelimiter(folder) + "bin");
@ -2257,11 +2263,11 @@ void Settings::CompilerSet::setExecutables()
void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType compilerType)
{
QString folder = QFileInfo(binDir).absolutePath();
QString cc_prog;
QString c_prog;
if (compilerType==CompilerType::Clang)
cc_prog = CLANG_PROGRAM;
c_prog = CLANG_PROGRAM;
else
cc_prog = GCC_PROGRAM;
c_prog = GCC_PROGRAM;
// Find default directories
// C include dirs
QStringList arguments;
@ -2270,7 +2276,7 @@ void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType co
arguments.append("-v");
arguments.append("-E");
arguments.append(NULL_FILE);
QByteArray output = getCompilerOutput(binDir,cc_prog,arguments);
QByteArray output = getCompilerOutput(binDir,c_prog,arguments);
int delimPos1 = output.indexOf("#include <...> search starts here:");
int delimPos2 = output.indexOf("End of search list.");
@ -2292,7 +2298,7 @@ void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType co
arguments.append("-E");
arguments.append("-v");
arguments.append(NULL_FILE);
output = getCompilerOutput(binDir,cc_prog,arguments);
output = getCompilerOutput(binDir,c_prog,arguments);
//gcc -xc++ -E -v NUL
delimPos1 = output.indexOf("#include <...> search starts here:");
@ -2312,7 +2318,7 @@ void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType co
arguments.clear();
arguments.append("-print-search-dirs");
arguments.append(NULL_FILE);
output = getCompilerOutput(binDir,cc_prog,arguments);
output = getCompilerOutput(binDir,c_prog,arguments);
// bin dirs
QByteArray targetStr = QByteArray("programs: =");
delimPos1 = output.indexOf(targetStr);
@ -2409,6 +2415,26 @@ int Settings::CompilerSet::mainVersion()
}
bool Settings::CompilerSet::canCompileC()
{
return fileExists(mCCompiler);
}
bool Settings::CompilerSet::canCompileCPP()
{
return fileExists(mCppCompiler);
}
bool Settings::CompilerSet::canMake()
{
return fileExists(mMake);
}
bool Settings::CompilerSet::canDebug()
{
return fileExists(mDebugger);
}
void Settings::CompilerSet::setUserInput()
{
mUseCustomCompileParams = false;
@ -2608,10 +2634,10 @@ Settings::PCompilerSet Settings::CompilerSets::addSet()
return p;
}
Settings::PCompilerSet Settings::CompilerSets::addSet(const QString &folder, const QString& cc_prog)
Settings::PCompilerSet Settings::CompilerSets::addSet(const QString &folder, const QString& c_prog)
{
PCompilerSet p=std::make_shared<CompilerSet>(folder,cc_prog);
if (cc_prog==GCC_PROGRAM && p->compilerType()==CompilerType::Clang)
PCompilerSet p=std::make_shared<CompilerSet>(folder,c_prog);
if (c_prog==GCC_PROGRAM && p->compilerType()==CompilerType::Clang)
return PCompilerSet();
mList.push_back(p);
return p;
@ -2651,13 +2677,13 @@ static void setDebugOptions(Settings::PCompilerSet pSet) {
pSet->setStaticLink(false);
}
bool Settings::CompilerSets::addSets(const QString &folder, const QString& cc_prog) {
bool Settings::CompilerSets::addSets(const QString &folder, const QString& c_prog) {
foreach (const PCompilerSet& set, mList) {
if (set->binDirs().contains(folder))
if (set->binDirs().contains(folder) && extractFileName(set->CCompiler())==c_prog)
return false;
}
// Default, release profile
PCompilerSet baseSet = addSet(folder,cc_prog);
PCompilerSet baseSet = addSet(folder,c_prog);
if (!baseSet)
return false;
QString baseName = baseSet->name();
@ -2806,7 +2832,7 @@ void Settings::CompilerSets::loadSets()
PCompilerSet pCurrentSet = defaultSet();
if (pCurrentSet) {
QString msg;
if (!pCurrentSet->dirsValid(msg) || !pCurrentSet->validateExes(msg)) {
if (!pCurrentSet->dirsValid(msg)) {
if (QMessageBox::warning(nullptr,QObject::tr("Confirm"),
QObject::tr("The following problems were found during validation of compiler set \"%1\":")
.arg(pCurrentSet->name())

View File

@ -1230,14 +1230,14 @@ public:
};
explicit CompilerSet();
explicit CompilerSet(const QString& compilerFolder, const QString& cc_prog);
explicit CompilerSet(const QString& compilerFolder, const QString& c_prog);
explicit CompilerSet(const CompilerSet& set);
CompilerSet& operator= (const CompilerSet& ) = delete;
CompilerSet& operator= (const CompilerSet&& ) = delete;
// Initialization
void setProperties(const QString& binDir, const QString& cc_prog);
void setProperties(const QString& binDir, const QString& c_prog);
void resetCompileOptionts();
bool setCompileOption(const QString& key, int valIndex);
@ -1249,8 +1249,12 @@ public:
int mainVersion();
bool canCompileC();
bool canCompileCPP();
bool canMake();
bool canDebug();
bool dirsValid(QString& msg);
bool validateExes(QString& msg);
// bool validateExes(QString& msg);
//properties
const QString& CCompiler() const;
void setCCompiler(const QString& name);
@ -1425,9 +1429,9 @@ public:
QString getKeyFromCompilerCompatibleIndex(int idx) const;
private:
PCompilerSet addSet(const QString& folder, const QString& cc_prog);
PCompilerSet addSet(const QString& folder, const QString& c_prog);
PCompilerSet addSet(const PCompilerSet &pSet);
bool addSets(const QString& folder, const QString& cc_prog);
bool addSets(const QString& folder, const QString& c_prog);
void savePath(const QString& name, const QString& path);
void savePathList(const QString& name, const QStringList& pathList);

View File

@ -51,6 +51,7 @@ CompilerSetOptionWidget::CompilerSetOptionWidget(const QString& name, const QStr
#ifdef Q_OS_WIN
ui->txtExecutableSuffix->setReadOnly(true);
#endif
ui->settingTabs->setCurrentWidget(ui->tabGeneral);
}
CompilerSetOptionWidget::~CompilerSetOptionWidget()
@ -235,6 +236,16 @@ void CompilerSetOptionWidget::saveCurrentCompilerSet()
pSet->setExecutableSuffix(ui->txtExecutableSuffix->text());
}
QString CompilerSetOptionWidget::getBinDir()
{
Settings::PCompilerSet pSet = pSettings->compilerSets().defaultSet();
if (!pSet->binDirs().isEmpty())
return pSet->binDirs().front();
if (!mBinDirWidget->dirList().isEmpty())
return mBinDirWidget->dirList().front();
return QDir().absolutePath();
}
void CompilerSetOptionWidget::on_btnFindCompilers_pressed()
{
#ifdef Q_OS_WIN
@ -338,3 +349,87 @@ void CompilerSetOptionWidget::on_cbEncodingDetails_currentTextChanged(const QStr
}
void CompilerSetOptionWidget::on_btnChooseCCompiler_clicked()
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Locate C Compiler"),
getBinDir(),
tr("Executable files (*.exe)"));
if (fileExists(fileName))
ui->txtCCompiler->setText(fileName);
}
void CompilerSetOptionWidget::on_btnChooseCppCompiler_clicked()
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Locate C++ Compiler"),
getBinDir(),
tr("Executable files (*.exe)"));
if (fileExists(fileName))
ui->txtCppCompiler->setText(fileName);
}
void CompilerSetOptionWidget::on_btnChooseMake_clicked()
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Locate Make"),
getBinDir(),
tr("Executable files (*.exe)"));
if (fileExists(fileName))
ui->txtMake->setText(fileName);
}
void CompilerSetOptionWidget::on_btnChooseGDB_clicked()
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Locate GDB"),
getBinDir(),
tr("Executable files (*.exe)"));
if (fileExists(fileName))
ui->txtDebugger->setText(fileName);
}
void CompilerSetOptionWidget::on_btnChooseGDBServer_clicked()
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Locate GDB Server"),
getBinDir(),
tr("Executable files (*.exe)"));
if (fileExists(fileName))
ui->txtGDBServer->setText(fileName);
}
void CompilerSetOptionWidget::on_btnChooseResourceCompiler_clicked()
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Locate windres"),
getBinDir(),
tr("Executable files (*.exe)"));
if (fileExists(fileName))
ui->txtResourceCompiler->setText(fileName);
}
void CompilerSetOptionWidget::on_btnChooseProfiler_clicked()
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Locate gprof"),
getBinDir(),
tr("Executable files (*.exe)"));
if (fileExists(fileName))
ui->txtProfiler->setText(fileName);
}

View File

@ -52,6 +52,7 @@ protected:
private:
void reloadCurrentCompilerSet();
void saveCurrentCompilerSet();
QString getBinDir();
private slots:
void on_cbCompilerSet_currentIndexChanged(int index);
@ -63,6 +64,13 @@ private slots:
void on_cbEncoding_currentTextChanged(const QString &arg1);
void on_cbEncodingDetails_currentTextChanged(const QString &arg1);
void on_btnChooseCCompiler_clicked();
void on_btnChooseCppCompiler_clicked();
void on_btnChooseMake_clicked();
void on_btnChooseGDB_clicked();
void on_btnChooseGDBServer_clicked();
void on_btnChooseResourceCompiler_clicked();
void on_btnChooseProfiler_clicked();
};
#endif // COMPILERSETOPTIONWIDGET_H

View File

@ -723,6 +723,38 @@
<source>Executable suffix</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate C Compiler</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Executable files (*.exe)</source>
<translation type="unfinished">Arquivos executáveis (*.exe)</translation>
</message>
<message>
<source>Locate C++ Compiler</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate Make</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate GDB</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate GDB Server</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate windres</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate gprof</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CppRefacter</name>
@ -5977,23 +6009,23 @@
</message>
<message>
<source>Cannot find the %1 &quot;%2&quot;</source>
<translation>Impossível encontrar %1 &quot;%2&quot;</translation>
<translation type="vanished">Impossível encontrar %1 &quot;%2&quot;</translation>
</message>
<message>
<source>C Compiler</source>
<translation>Compilar C</translation>
<translation type="vanished">Compilar C</translation>
</message>
<message>
<source>C++ Compiler</source>
<translation>Compilador C++</translation>
<translation type="vanished">Compilador C++</translation>
</message>
<message>
<source>Maker</source>
<translation>Maker</translation>
<translation type="vanished">Maker</translation>
</message>
<message>
<source>Debugger</source>
<translation>Depurador</translation>
<translation type="vanished">Depurador</translation>
</message>
<message>
<source>C options</source>

File diff suppressed because it is too large Load Diff

View File

@ -632,6 +632,38 @@
<source>Executable suffix</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate C Compiler</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Executable files (*.exe)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate C++ Compiler</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate Make</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate GDB</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate GDB Server</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate windres</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Locate gprof</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CppRefacter</name>
@ -5752,26 +5784,6 @@
<source>C++ include</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cannot find the %1 &quot;%2&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>C Compiler</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>C++ Compiler</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Maker</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Debugger</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>C options</source>
<translation type="unfinished"></translation>

View File

@ -27,9 +27,6 @@ extern const QChar TabGlyph;
extern const QChar LineBreakGlyph;
extern const QChar SoftBreakGlyph;
#define MAX_SCROLL 65535
// names for token attributes
#define SYNS_AttrAssembler "Assembler"
#define SYNS_AttrCharacter "Character"

View File

@ -3238,17 +3238,10 @@ void SynEdit::updateScrollbars()
}
if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssHorizontal) {
nMaxScroll = maxScrollWidth();
if (nMaxScroll <= MAX_SCROLL) {
nMin = 1;
nMax = nMaxScroll;
nPage = mCharsInWindow;
nPos = mLeftChar;
} else {
nMin = 0;
nMax = MAX_SCROLL;
nPage = mulDiv(MAX_SCROLL, mCharsInWindow, nMaxScroll);
nPos = mulDiv(MAX_SCROLL, mLeftChar, nMaxScroll);
}
horizontalScrollBar()->setMinimum(nMin);
horizontalScrollBar()->setMaximum(nMax);
horizontalScrollBar()->setPageStep(nPage);
@ -3259,17 +3252,10 @@ void SynEdit::updateScrollbars()
if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssVertical) {
nMaxScroll = maxScrollHeight();
if (nMaxScroll <= MAX_SCROLL) {
nMin = 1;
nMax = std::max(1, nMaxScroll);
nPage = mLinesInWindow;
nPos = mTopLine;
} else {
nMin = 0;
nMax = MAX_SCROLL;
nPage = mulDiv(MAX_SCROLL, mLinesInWindow, nMaxScroll);
nPos = mulDiv(MAX_SCROLL, mTopLine, nMaxScroll);
}
verticalScrollBar()->setMinimum(nMin);
verticalScrollBar()->setMaximum(nMax);
verticalScrollBar()->setPageStep(nPage);

View File

@ -20,6 +20,7 @@
using std::string;
#include <stdio.h>
#include <windows.h>
#include <psapi.h>
#include <conio.h>
#ifndef WINBOOL
@ -114,7 +115,7 @@ string GetCommand(int argc,char** argv,bool &reInp,bool &pauseAfterExit) {
return result;
}
DWORD ExecuteCommand(string& command,bool reInp) {
DWORD ExecuteCommand(string& command,bool reInp, LONGLONG &peakMemory) {
STARTUPINFOA si;
PROCESS_INFORMATION pi;
@ -139,7 +140,13 @@ DWORD ExecuteCommand(string& command,bool reInp) {
WaitForSingleObject(pi.hProcess, INFINITE); // Wait for it to finish
peakMemory = 0;
PROCESS_MEMORY_COUNTERS counter;
counter.cb = sizeof(counter);
if (GetProcessMemoryInfo(pi.hProcess,&counter,
sizeof(counter))){
peakMemory = counter.PeakWorkingSetSize/1024;
}
DWORD result = 0;
GetExitCodeProcess(pi.hProcess, &result);
return result;
@ -225,8 +232,9 @@ int main(int argc, char** argv) {
// Save starting timestamp
LONGLONG starttime = GetClockTick();
LONGLONG peakMemory=0;
// Then execute said command
DWORD returnvalue = ExecuteCommand(command,reInp);
DWORD returnvalue = ExecuteCommand(command,reInp,peakMemory);
// Get ending timestamp
LONGLONG endtime = GetClockTick();
@ -242,7 +250,7 @@ int main(int argc, char** argv) {
// Done? Print return value of executed program
printf("\n--------------------------------");
printf("\nProcess exited after %.4g seconds with return value %lu\n",seconds,returnvalue);
printf("\nProcess exited after %.4g seconds with return value %lu, %d KB mem used.\n",seconds,returnvalue,peakMemory);
if (pauseAfterExit)
PauseExit(returnvalue,reInp);
return 0;