diff --git a/NEWS.md b/NEWS.md index 57a89647..bfc90d18 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ Version 0.11.0 For Dev-C++ 7 Beta - fix: typo errors in settings dialog - enhancement: console pauser clears STDIN buffer before show "press any key to continue..." - fix: path in macros should use system's path separator + - fix: custom tools doesn't work Version 0.10.4 For Dev-C++ 7 Beta - fix: can't correctly undo/redo indent diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index e4e9a7f0..5c51ed73 100644 Binary files a/RedPandaIDE/RedPandaIDE_zh_CN.qm and b/RedPandaIDE/RedPandaIDE_zh_CN.qm differ diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts index afe03650..6c614be1 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -1076,35 +1076,35 @@ Are you really want to continue? 要剪切的内容超过了字符数限制! - + Print Document 打印文档 - - - + + + Ctrl+click for more info Ctrl+单击以获取更多信息 - - + + Symbol '%1' not found! 未找到符号'%1'! - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -2826,36 +2826,46 @@ Are you really want to continue? + Full path to the compiled file + 编译得到的文件的完整路径 + + + Filename of the current source file 当前源文件名 - + Full path to the current source file 当前源文件路径 - + Path to the current source file's parent folder 当前源文件所在文件夹 - + Word at the cursor in the active editor 当前编辑器中光标处的单词 - + Name of the current project 当前项目名称 - + Full path to the current project file 项目文件完整路径 - + + Name of the current project file + 当前项目文件的文件名 + + + Path to the current project's folder 项目文件夹 @@ -2870,11 +2880,11 @@ Are you really want to continue? - - - - - + + + + + Issues 编译器 @@ -2950,7 +2960,7 @@ Are you really want to continue? - + Debug Console 调试主控台 @@ -3026,7 +3036,7 @@ Are you really want to continue? 工具栏2 - + New 新建 @@ -3084,8 +3094,8 @@ Are you really want to continue? - - + + Compile 编译 @@ -3131,8 +3141,8 @@ Are you really want to continue? - - + + Copy 复制 @@ -3143,7 +3153,7 @@ Are you really want to continue? - + Paste 粘贴 @@ -3154,7 +3164,7 @@ Are you really want to continue? - + Select All 选择全部 @@ -3274,14 +3284,14 @@ Are you really want to continue? - + Problem Set 试题集 - + New Problem Set 新建试题集 @@ -3300,14 +3310,14 @@ Are you really want to continue? - + Save Problem Set 保存试题集 - + Load Problem Set 载入试题集 @@ -3343,7 +3353,7 @@ Are you really want to continue? - + Problem 试题 @@ -3647,7 +3657,7 @@ Are you really want to continue? - + Clear all breakpoints 删除所有断点 @@ -3748,7 +3758,7 @@ Are you really want to continue? - + Rename Symbol 重命名符号 @@ -3769,13 +3779,13 @@ Are you really want to continue? - + Export As RTF 导出为RTF - + Export As HTML 导出为HTML @@ -3895,7 +3905,7 @@ Are you really want to continue? - + Open Folder 打开文件夹 @@ -3905,42 +3915,42 @@ Are you really want to continue? 运行参数... - + File Encoding 文件编码 - + Recent Files 文件历史 - - - - - - + + + + + + Debugging 正在调试 - - - - - - + + + + + + Running 正在运行 - - - - - - + + + + + + Compiling 正在编译 @@ -3949,189 +3959,189 @@ Are you really want to continue? 行:%1 列:%2 已选择:%3 总行数:%4 总长度:%5 - + Line:%1 Col:%2 Selected:%3 Lines:%4 Length:%5 Line: %1 Col: %2 Selected: %3 Lines: %4 Length: %5 行: %1 列: %2 已选择 :%3 总行数: %4 总长度: %5 - + Read Only 只读 - + Insert 插入 - + Overwrite 覆写 - + Close project 关闭项目 - + Are you sure you want to close %1? 你确定要关闭'%1'吗? - - + + Confirm 确认 - - - + + + Source file is not compiled. 源文件尚未编译。 - - + + Compile now? 现在编译? - - - + + + Source file is more recent than executable. 源文件比可执行程序新。 - + Recompile now? 重新编译? - + No compiler set 无编译器设置 - + No compiler set is configured. 没有配置编译器设置。 - + Can't start debugging. 无法启动调试器 - - + + Enable debugging 启用调试参数 - - + + You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now? 当前编译设置中未启用调试选项(-g3),或启用了信息剥除选项(-s)<br /><br/>是否纠正这一问题? - + Project not built 项目尚未构建 - + Project hasn't been built. Build it now? 项目尚未构建。是否构建? - + Host applcation missing 宿主程序不存在 - + DLL project needs a host application to run. 动态链接库(DLL)需要一个宿主程序来运行。 - + But it's missing. 但它不存在。 - + Host application not exists 宿主程序不存在 - + Host application file '%1' doesn't exist. 宿主程序'%1'不存在。 - + Recompile? 重新编译? - - + + Save last open info error 保存上次打开信息失败 - + Can't remove old last open information file '%1' 无法删除旧上次打开信息文件'%1' - + Can't save last open info file '%1' 无法保存上次打开信息文件'%1' - + Load last open info error 载入上次打开信息失败 - + Can't load last open info file '%1' 无法载入上次打开信息文件'%1' - + Show detail debug logs 显示详细调试器日志 - + Copy all 全部复制 - - + + Clear 清除 - + Export 导出 - + Insert Snippet 插入代码段 - - + + Problem Set %1 试题集%1 @@ -4152,73 +4162,73 @@ Are you really want to continue? 或者选择使用其他的网络端口。 - + Red Panda Dev-C++ 小熊猫Dev-C++ - - + + Rebuild Project 重新构建项目 - - + + Project has been modified, do you want to rebuild it? 项目已经被修改过,是否需要重新构建? - + Auto Save Error 自动保存出错 - + Auto save "%1" to "%2" failed:%3 自动保存"%1"到"%2"失败:%3 - + Properties... 试题属性... - + Set Problem Set Name 设置试题集名称 - + Problem Set Name: 试题集名称: - + Remove 删除 - + Remove All Bookmarks 删除全部书签 - + Modify Description 修改描述 - - - + + + Bookmark Description 书签描述 - - - + + + Description: 描述: @@ -4227,460 +4237,460 @@ Are you really want to continue? 在调试主控台中显示调试器输出 - + Remove this search 清除这次搜索 - + Clear all searches 删除所有搜索 - + Breakpoint condition... 断点条件... - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Remove All Breakpoints Remove all breakpoints 删除所有断点 - + Remove Breakpoint 删除当前断点 - + Rename File 重命名文件 - - + + Add Folder 添加文件夹 - + New folder 新文件夹 - + Folder name: 文件夹: - + Rename Folder 重命名 - + Remove Folder 删除文件夹 - + Sort By Type 按类型排序 - + Sort alphabetically 按名称排序 - + Show inherited members 显示继承的成员 - + Goto declaration 跳转到声明处 - + Goto definition 跳转到定义处 - + Open in Editor 在编辑器中打开 - + Open in External Program 使用外部程序打开 - + Open in Terminal 在终端中打开 - + Open in Windows Explorer 在Windows浏览器中打开 - + Character sets 字符集 - + %1 files autosaved 已自动保存%1个文件 - + Set answer to... 设置答案源代码... - + select other file... 选择其他文件... - + Select Answer Source File 选择答案源代码文件 - + C/C++Source Files (*.c *.cpp *.cc *.cxx) C/C++Source Files (*.c *.cpp *.cc *.cxx C/C++源代码文件 (*.c *.cpp *.cc *.cxx) - + Save project 保存项目 - + The project '%1' has modifications. 项目'%1'有改动。 - - + + Do you want to save it? 需要保存吗? - - + + File Changed 文件已发生变化 - + New Project File? 新建项目文件? - + Do you want to add the new file to the project? 您是否要将新建的文件加入项目? - - - - + + + + Save Error 保存失败 - + Change Project Compiler Set 改变项目编译器配置集 - + Change the project's compiler set will lose all custom compiler set options. 改变项目的编译器配置集会导致所有的自定义编译器选项被重置。 - + Do you really want to do that? 你真的想要做那些吗? - + Do you really want to clear all breakpoints in this file? 您真的要清除该文件的所有断点吗? - + New project 新建项目 - + Close %1 and start new project? 关闭'%1'以打开新项目? - + Folder not exist 文件夹不存在 - + Folder '%1' doesn't exist. Create it now? 文件夹'%1'不存在。是否创建? - + Can't create folder 无法创建文件夹 - + Failed to create folder '%1'. 创建文件夹'%1'失败。 - + Save new project as - + Red panda Dev-C++ project file (*.dev) 小熊猫Dev-C++项目文件 (*.dev) - + New project fail 新建项目失败 - + Can't assign project template 无法使用模板创建项目 - + Remove file 删除文件 - + Remove the file from disk? 同时从硬盘上删除文件? - + untitled 无标题 - + New Project File Name 新的项目文件名 - + File Name: 文件名: - + File Already Exists! 文件已存在! - + File '%1' already exists! 文件'%1'已经存在! - + Add to project 添加到项目 - + Rename Error 重命名出错 - + Symbol '%1' is defined in system header. 符号'%1'在系统头文件中定义,无法修改。 - + New Name 新名称 - - + + Replace Error 替换出错 - + Can't open file '%1' for replace! 无法打开文件'%1'进行替换! - + Contents has changed since last search! 内容和上次查找时不一致。 - + Rich Text Format Files (*.rtf) RTF格式文件 (*.rtf) - + HTML Files (*.html) HTML文件 (*.html) - + The current problem set is not empty. 当前的试题集不是空的。 - + Problem %1 试题%1 - - + + Problem Set Files (*.pbs) 试题集文件 (*.pbs) - + Load Error 载入失败 - - + + Problem Case %1 试题案例%1 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + Error 错误 - + Recent Projects 项目历史 - + File '%1' was changed. 磁盘文件'%1'已被修改。 - + Reload its content from disk? 是否重新读取它的内容? - + File '%1' was removed. 磁盘文件'%1'已被删除。 - + Keep it open? 是否保持它在小熊猫C++中打开的编辑窗口? - + Open 打开 - + Compile Failed 编译失败 - + Run Failed 运行失败 - - + + Confirm Convertion 确认转换 - - + + The editing file will be saved using %1 encoding. <br />This operation can't be reverted. <br />Are you sure to continue? 当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗? - + New Watch Expression 新监视表达式 - + Enter Watch Expression (it is recommended to use 'this->' for class members): 输入监视表达式 - + Parsing file %1 of %2: "%3" (%1/%2)正在解析文件"%3" - - + + Done parsing %1 files in %2 seconds 完成%1个文件的解析,用时%2秒 - + (%1 files per second) (每秒%1个文件) @@ -5855,27 +5865,27 @@ Are you really want to continue? 无标题 - + Index %1 out of range 下标"%1"越界 - + bytes 字节 - + KB KB - + MB MB - + GB GB @@ -6164,12 +6174,12 @@ Are you really want to continue? 无标题 - + constructor 构造函数 - + destructor 析构函数 @@ -6553,7 +6563,8 @@ Are you really want to continue? - Cancle + Cancel + Cancle 取消 @@ -6608,7 +6619,7 @@ Are you really want to continue? 自动链接 - + @@ -6684,15 +6695,15 @@ Are you really want to continue? 杂项 - - + + Program Runner 程序运行 - + Problem Set 试题集 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 6c8ece9f..eb2e4469 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1800,30 +1801,48 @@ void MainWindow::updateTools() if (!mToolsManager->tools().isEmpty()) { ui->menuTools->addSeparator(); foreach (const PToolItem& item, mToolsManager->tools()) { - QAction* action = new QAction(item->title,ui->menuTools); + QAction* action = new QAction(tr(item->title.toUtf8()),ui->menuTools); connect(action, &QAction::triggered, [item] (){ QString program = parseMacros(item->program); QString workDir = parseMacros(item->workingDirectory); - if (program == "del") { - QString current = QDir::currentPath(); - QDir::setCurrent(workDir); - qDebug()<<(program+" "+parseMacros(item->parameters)); - system((program+" "+parseMacros(item->parameters)).toLocal8Bit()); - QDir::setCurrent(current); + QString params = parseMacros(item->parameters); + if (!program.endsWith(".bat",Qt::CaseInsensitive)) { + QTemporaryFile file(QDir::tempPath()+QDir::separator()+"XXXXXX.bat"); + file.setAutoRemove(false); + if (file.open()) { + file.write(QString("cd /d \"%1\"") + .arg(localizePath(workDir)) + .toLocal8Bit()+LINE_BREAKER); + file.write((program+" "+params).toLocal8Bit() + + LINE_BREAKER); + file.close(); + if (item->pauseAfterExit) { + executeFile( + includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe", + " 1 \""+localizePath(file.fileName())+"\" ", + workDir, file.fileName()); + } else { + executeFile( + file.fileName(), + "", + workDir, file.fileName()); + } + } } else { if (item->pauseAfterExit) { executeFile( includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe", - " 0 \""+localizePath(program)+"\" "+parseMacros(item->parameters), - workDir); + " 1 \""+program+"\" "+params, + workDir, ""); } else { executeFile( program, - parseMacros(item->parameters), - workDir); + params, + workDir, ""); } } + }); ui->menuTools->addAction(action); } diff --git a/RedPandaIDE/settingsdialog/toolsgeneralwidget.cpp b/RedPandaIDE/settingsdialog/toolsgeneralwidget.cpp index d1a5cda8..64035570 100644 --- a/RedPandaIDE/settingsdialog/toolsgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/toolsgeneralwidget.cpp @@ -17,7 +17,7 @@ ToolsGeneralWidget::ToolsGeneralWidget(const QString &name, const QString &group finishEditing(false); connect(ui->lstTools->selectionModel(), &QItemSelectionModel::currentRowChanged, this,&ToolsGeneralWidget::onToolsCurrentChanged); - connect(ui->txtDirectory,&QLineEdit::textChanged, + connect(ui->txtProgram,&QLineEdit::textChanged, this, &ToolsGeneralWidget::updateDemo); connect(ui->txtParameters,&QLineEdit::textChanged, this, &ToolsGeneralWidget::updateDemo); diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index df92700d..08cd08e4 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -52,6 +52,7 @@ #ifdef Q_OS_WIN # define PATH_SENSITIVITY Qt::CaseInsensitive # define PATH_SEPARATOR ";" +# define LINE_BREAKER "\r\n" # define NULL_FILE "NUL" # define EXECUTABLE_EXT "exe" # define STATIC_LIB_EXT "a" @@ -60,6 +61,7 @@ #elif defined(Q_OS_LINUX) # define PATH_SENSITIVITY Qt::CaseSensitive # define PATH_SEPARATOR ":" +# define LINE_BREAKER "\n" # define NULL_FILE "/dev/null" # define EXECUTABLE_EXT "" # define STATIC_LIB_EXT "a" diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 79df5d8e..7127fec6 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -786,30 +786,27 @@ QString parseMacros(const QString &s) result.replace("",""); } - // Project-dependent macros - if (pMainWindow->project()) { + if (e!=nullptr && !e->inProject()) { // Non-project editor macros + result.replace("", extractFileName(changeFileExt(e->filename(),EXECUTABLE_EXT))); + result.replace("", localizePath(changeFileExt(e->filename(),EXECUTABLE_EXT))); + result.replace("", extractFileName(e->filename())); + result.replace("", localizePath(e->filename())); + result.replace("", extractFileName(e->filename())); + result.replace("", localizePath(extractFileDir(e->filename()))); + } else if (pMainWindow->project()) { result.replace("", extractFileName(pMainWindow->project()->executable())); result.replace("", localizePath(pMainWindow->project()->executable())); result.replace("", pMainWindow->project()->name()); result.replace("", localizePath(pMainWindow->project()->filename())); result.replace("", extractFileName(pMainWindow->project()->filename())); result.replace("", localizePath(pMainWindow->project()->directory())); -// result.replace("', MainForm.Project.ListUnitStr(' ')); -// result.replace("",""); - } else if (e!=nullptr) { // Non-project editor macros - result.replace("", extractFileName(changeFileExt(e->filename(),EXECUTABLE_EXT))); - result.replace("", localizePath(changeFileExt(e->filename(),EXECUTABLE_EXT))); - result.replace("", extractFileName(e->filename())); - result.replace("", localizePath(e->filename())); - result.replace("", extractFileName(e->filename())); - result.replace("", localizePath(extractFileDir(e->filename()))); -// result.replace("", ""); // clear unchanged macros } else { result.replace("", ""); + result.replace("", ""); result.replace("", ""); result.replace("", ""); + result.replace("", ""); result.replace("", ""); -// result.replace("", ""); // clear unchanged macros } // Editor macros @@ -827,26 +824,23 @@ QString parseMacros(const QString &s) return result; } -void executeFile(const QString &fileName, const QString ¶ms, const QString &workingDir) +void executeFile(const QString &fileName, const QString ¶ms, const QString &workingDir, const QString &tempFile) { - qDebug()<connect(runner, &QThread::finished, - [runner](){ - qDebug()<<"finished"; + [runner,tempFile](){ + if (!tempFile.isEmpty()) { + QFile::remove(tempFile); + } runner->deleteLater(); }); runner->connect(runner, &Runner::runErrorOccurred, - [](const QString& s){ - qDebug()<<"error occured"; - qDebug()<setStartConsole(true); runner->start(); } diff --git a/RedPandaIDE/utils.h b/RedPandaIDE/utils.h index bff61f39..ee7f9669 100644 --- a/RedPandaIDE/utils.h +++ b/RedPandaIDE/utils.h @@ -122,7 +122,10 @@ QByteArray runAndGetOutput(const QString& cmd, const QString& workingDir, const const QByteArray& inputContent = QByteArray(), bool inheritEnvironment = false); -void executeFile(const QString& fileName, const QString& params, const QString& workingDir); +void executeFile(const QString& fileName, + const QString& params, + const QString& workingDir, + const QString& tempFile); bool isNonPrintableAsciiChar(char ch); diff --git a/RedPandaIDE/widgets/macroinfomodel.cpp b/RedPandaIDE/widgets/macroinfomodel.cpp index 6d4df062..daf725c1 100644 --- a/RedPandaIDE/widgets/macroinfomodel.cpp +++ b/RedPandaIDE/widgets/macroinfomodel.cpp @@ -2,7 +2,7 @@ MacroInfoModel::MacroInfoModel(QObject *parent) : QAbstractListModel(parent) { - addMacroInfo("", tr("The default directory")); + addMacroInfo("", tr("The default directory")); addMacroInfo("", tr("Path to the Red Panda C++'s executable file.")); addMacroInfo("", tr("Version of the Red Panda C++")); addMacroInfo("", tr("PATH to the Red Panda C++'s installation folder.")); diff --git a/tools/ConsolePauser/main.cpp b/tools/ConsolePauser/main.cpp index b554b53d..5ff6ac01 100644 --- a/tools/ConsolePauser/main.cpp +++ b/tools/ConsolePauser/main.cpp @@ -78,15 +78,6 @@ string GetCommand(int argc,char** argv,bool &reInp,bool &pauseAfterExit) { reInp = flags & RPF_REDIRECT_INPUT; pauseAfterExit = flags & RPF_PAUSE_CONSOLE; for(int i = 2;i < argc;i++) { -/* - // Quote the first argument in case the path name contains spaces -// if(i == 1) { -// result += string("\"") + string(argv[i]) + string("\""); -// } else { - // Quote the first argument in case the path name contains spaces -// result += string(argv[i]); -// } -*/ // Quote the argument in case the path name contains spaces result += string("\"") + string(argv[i]) + string("\"");