- change: Don't confirm rebuild/recompile when run/debug.

This commit is contained in:
Roy Qu 2023-02-14 23:42:11 +08:00
parent 364aaf9704
commit 926802a8f5
19 changed files with 54 additions and 74 deletions

View File

@ -18,6 +18,8 @@ Red Panda C++ Version 2.12
- change: The default disassemble style of CPU Dialog is "AT&T" now. - change: The default disassemble style of CPU Dialog is "AT&T" now.
- fix: Can't compile files with chinese characters in filenames using winlibs mingw gcc - fix: Can't compile files with chinese characters in filenames using winlibs mingw gcc
- fix: If current editor is empty, parser will parse the file's content on the disk instead from the editor. - fix: If current editor is empty, parser will parse the file's content on the disk instead from the editor.
- fix: Can't show completion when cursor is after "char["
- change: Don't confirm rebuild/recompile when run/debug.
Red Panda C++ Version 2.11 Red Panda C++ Version 2.11

View File

@ -367,7 +367,6 @@ bool Editor::saveAs(const QString &name, bool fromProject){
QString selectedFileFilter; QString selectedFileFilter;
QString defaultExt; QString defaultExt;
defaultExt=QFileInfo(oldName).suffix(); defaultExt=QFileInfo(oldName).suffix();
qDebug()<<defaultExt;
if (defaultExt.isEmpty()) { if (defaultExt.isEmpty()) {
if (pSettings->editor().defaultFileCpp()) { if (pSettings->editor().defaultFileCpp()) {
selectedFileFilter = pSystemConsts->defaultCPPFileFilter(); selectedFileFilter = pSystemConsts->defaultCPPFileFilter();
@ -4654,7 +4653,7 @@ QString Editor::getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoo
QString s = document()->getLine(p.line - 1); QString s = document()->getLine(p.line - 1);
int wordBegin; int wordBegin;
int wordEnd = p.ch-1; int wordEnd = p.ch-2;
if (wordEnd >= s.length()) if (wordEnd >= s.length())
wordEnd = s.length()-1; wordEnd = s.length()-1;
while (true) { while (true) {

View File

@ -1974,12 +1974,7 @@ void MainWindow::runExecutable(
// Check if it exists // Check if it exists
if (!fileExists(exeName)) { if (!fileExists(exeName)) {
if (ui->actionCompile_Run->isEnabled()) { if (ui->actionCompile_Run->isEnabled()) {
if (QMessageBox::question(this,tr("Confirm"), doCompileRun(runType);
tr("Source file is not compiled.")
+"<br /><br />"+tr("Compile now?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
doCompileRun(runType);
}
return; return;
} else { } else {
QMessageBox::critical(this,"Error", QMessageBox::critical(this,"Error",
@ -1988,18 +1983,8 @@ void MainWindow::runExecutable(
} }
} else { } else {
if (!filename.isEmpty() && compareFileModifiedTime(filename,exeName)>=0) { if (!filename.isEmpty() && compareFileModifiedTime(filename,exeName)>=0) {
// if (ui->actionCompile_Run->isEnabled()) { doCompileRun(runType);
if (QMessageBox::warning(this,tr("Confirm"), return;
tr("Source file is more recent than executable.")
+"<br /><br />"+tr("Recompile now?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
doCompileRun(runType);
return;
}
// } else {
// QMessageBox::warning(this,"Error",
// tr("Source file is more recent than executable."));
// }
} }
} }
@ -2044,12 +2029,7 @@ void MainWindow::runExecutable(RunType runType)
QStringList binDirs = mProject->binDirs(); QStringList binDirs = mProject->binDirs();
QFileInfo execInfo(mProject->executable()); QFileInfo execInfo(mProject->executable());
QDateTime execModTime = execInfo.lastModified(); QDateTime execModTime = execInfo.lastModified();
if (execInfo.exists() && mProject->modifiedSince(execModTime) && if (execInfo.exists() && mProject->modifiedSince(execModTime)) {
QMessageBox::question(
this,
tr("Rebuild Project"),
tr("Project has been modified, do you want to rebuild it?")
) == QMessageBox::Yes) {
//mProject->saveAll(); //mProject->saveAll();
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>(); mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal; mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal;
@ -2138,30 +2118,18 @@ void MainWindow::debug()
// Did we compile? // Did we compile?
if (!fileExists(mProject->executable())) { if (!fileExists(mProject->executable())) {
if (QMessageBox::question( mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
this, mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
tr("Project not built"), mCompileSuccessionTask->execName = mProject->executable();
tr("Project hasn't been built. Build it now?"), mCompileSuccessionTask->isExecutable = true;
QMessageBox::Yes | QMessageBox::No, mCompileSuccessionTask->binDirs = binDirs;
QMessageBox::Yes) == QMessageBox::Yes) { compile();
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
mCompileSuccessionTask->execName = mProject->executable();
mCompileSuccessionTask->isExecutable = true;
mCompileSuccessionTask->binDirs = binDirs;
compile();
}
return; return;
} }
{ {
QFileInfo execInfo(mProject->executable()); QFileInfo execInfo(mProject->executable());
QDateTime execModTime = execInfo.lastModified(); QDateTime execModTime = execInfo.lastModified();
if (execInfo.exists() && mProject->modifiedSince(execModTime) && if (execInfo.exists() && mProject->modifiedSince(execModTime)) {
QMessageBox::question(
this,
tr("Rebuild Project"),
tr("Project has been modified, do you want to rebuild it?")
) == QMessageBox::Yes) {
//mProject->saveAll(); //mProject->saveAll();
mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>(); mCompileSuccessionTask=std::make_shared<CompileSuccessionTask>();
mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug; mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug;
@ -5592,35 +5560,41 @@ void MainWindow::onCompileFinished(QString filename, bool isCheckSyntax)
if (!isCheckSyntax) { if (!isCheckSyntax) {
//run succession task if there aren't any errors //run succession task if there aren't any errors
if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) { if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) {
if (!fileExists(mCompileSuccessionTask->execName)) {
QMessageBox::critical(this,tr("Compile Failed"),
tr("Failed to generate the executable.")+"<BR/><BR/>"
+tr("Please check detail info in \"Tools Output\" panel."));
return;
}
if (!mCompileSuccessionTask->isExecutable) { if (!mCompileSuccessionTask->isExecutable) {
Editor * editor;
switch (mCompileSuccessionTask->type) { switch (mCompileSuccessionTask->type) {
case MainWindow::CompileSuccessionTaskType::RunNormal: case MainWindow::CompileSuccessionTaskType::RunNormal:
if (fileExists(mCompileSuccessionTask->execName)) { editor = openFile(mCompileSuccessionTask->execName);
Editor * editor = openFile(mCompileSuccessionTask->execName); if (e && editor) {
if (e && editor) { int line = e->caretY();
int line = e->caretY(); int startLine = 1;
int startLine = 1; QString s = " # "+e->filename()+":";
QString s = " # "+e->filename()+":"; for(int i=0;i<editor->document()->count();i++) {
for(int i=0;i<editor->document()->count();i++) { QString t=editor->document()->getLine(i);
QString t=editor->document()->getLine(i); if (t.startsWith(s,PATH_SENSITIVITY)) {
if (t.startsWith(s,PATH_SENSITIVITY)) { t=t.mid(s.length());
t=t.mid(s.length()); int pos = t.indexOf(":");
int pos = t.indexOf(":"); if (pos>0) {
if (pos>0) { QString numstring=t.mid(0,pos);
QString numstring=t.mid(0,pos); bool isOk;
bool isOk; int l=numstring.toInt(&isOk);
int l=numstring.toInt(&isOk); if (isOk) {
if (isOk) { if (l<=line)
if (l<=line) startLine=i+1;
startLine=i+1; if (l>=line)
if (l>=line) break;
break;
}
} }
} }
} }
editor->setCaretPositionAndActivate(startLine,1);
} }
editor->setCaretPositionAndActivate(startLine,1);
} }
break; break;
case MainWindow::CompileSuccessionTaskType::RunProblemCases: case MainWindow::CompileSuccessionTaskType::RunProblemCases:

View File

@ -80,6 +80,7 @@ win32: {
QMAKE_SUBSTITUTES += platform/windows/installer-scripts/config-clang.nsh.in QMAKE_SUBSTITUTES += platform/windows/installer-scripts/config-clang.nsh.in
resources.path = $${PREFIX} resources.path = $${PREFIX}
resources.files += platform/windows/templates resources.files += platform/windows/templates
resources.files += platform/windows/installer-scripts/config.nsh resources.files += platform/windows/installer-scripts/config.nsh
resources.files += platform/windows/installer-scripts/config32.nsh resources.files += platform/windows/installer-scripts/config32.nsh
@ -90,5 +91,11 @@ win32: {
resources.files += RedPandaIDE/images/devcpp.ico resources.files += RedPandaIDE/images/devcpp.ico
INSTALLS += resources INSTALLS += resources
equals(X86_64, "ON") {
extra_templates.path = $${PREFIX}/templates
extra_templates.files += platform/windows/templates-win64/*
INSTALLS += extra_templates
}
} }
} }

View File

@ -20,7 +20,7 @@ echo "Building..."
pushd . pushd .
cd "${BUILD_DIR}" cd "${BUILD_DIR}"
make distclean make distclean
"$QMAKE" PREFIX="${PACKAGE_DIR}" -o Makefile "${SOURCE_DIR}\Red_Panda_Cpp.pro" -r -spec win32-g++ "$QMAKE" PREFIX="${PACKAGE_DIR}" X86_64=ON -o Makefile "${SOURCE_DIR}\Red_Panda_Cpp.pro" -r -spec win32-g++
make -j16 make -j16
make install make install
popd popd

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -5,10 +5,8 @@ main:
# the x64 calling convention requires you to allocate 32 bytes of shadow space before each call # the x64 calling convention requires you to allocate 32 bytes of shadow space before each call
# https://stackoverflow.com/questions/30190132/what-is-the-shadow-space-in-x64-assembly/ # https://stackoverflow.com/questions/30190132/what-is-the-shadow-space-in-x64-assembly/
sub $32, %rsp # allocate shadow space sub $32, %rsp # allocate shadow space
leaq fmt(%rip), %rax # first parameter leaq fmt(%rip), %rcx # first parameter
movq %rax, %rcx leaq msg(%rip), %rdx # second parameter
leaq msg(%rip), %rax # second parameter
movq %rax, %rdx
call printf call printf
add $32, %rsp # remove shadow space add $32, %rsp # remove shadow space

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -11,8 +11,8 @@ main:
; the x64 calling convention requires you to allocate 32 bytes of shadow space before each call ; the x64 calling convention requires you to allocate 32 bytes of shadow space before each call
; https://stackoverflow.com/questions/30190132/what-is-the-shadow-space-in-x64-assembly/ ; https://stackoverflow.com/questions/30190132/what-is-the-shadow-space-in-x64-assembly/
sub rsp, 32 ; allocate shadow space sub rsp, 32 ; allocate shadow space
mov rcx, fmt ; first parameter lea rcx, [rel fmt] ; first parameter
mov rdx, msg ; secodng parameter lea rdx, [rel msg] ; secodng parameter
call printf call printf
add rsp,32 ; remove shadow space add rsp,32 ; remove shadow space

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB