From 1e645d77703529a35d05bb51f10a7d908efa33d6 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 21 Sep 2023 08:17:07 +0800 Subject: [PATCH] Improvement of terminal support --- NEWS.md | 3 +- RedPandaIDE/compiler/compilermanager.cpp | 5 +- RedPandaIDE/settings.cpp | 182 ++++--- RedPandaIDE/settings.h | 13 +- .../environmentprogramswidget.cpp | 6 +- .../settingsdialog/executorgeneralwidget.cpp | 12 +- .../settingsdialog/executorgeneralwidget.ui | 10 +- RedPandaIDE/translations/RedPandaIDE_pt_BR.ts | 4 + RedPandaIDE/translations/RedPandaIDE_zh_CN.ts | 459 +++++++++--------- RedPandaIDE/translations/RedPandaIDE_zh_TW.ts | 4 + tools/consolepauser/main.windows.cpp | 15 +- 11 files changed, 373 insertions(+), 340 deletions(-) diff --git a/NEWS.md b/NEWS.md index 2ed305cd..c7f1ded0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,8 +5,7 @@ Red Panda C++ Version 2.25 - fix: "move selection up/down" of whole lines selection are no correctly handled. - enhancement: Improvement of terminal support ( from cyano.CN ) - enhancement: Virtual Terminal Sequences Support in windows 10/11 ( from cyano.CN ) - - + - enhancement: Option "Enable Virtual Terminal Sequences Support" in Settings -> Executor Red Panda C++ Version 2.24 diff --git a/RedPandaIDE/compiler/compilermanager.cpp b/RedPandaIDE/compiler/compilermanager.cpp index f450c7fd..2759d541 100644 --- a/RedPandaIDE/compiler/compilermanager.cpp +++ b/RedPandaIDE/compiler/compilermanager.cpp @@ -37,7 +37,8 @@ enum RunProgramFlag { RPF_PAUSE_CONSOLE = 0x0001, - RPF_REDIRECT_INPUT = 0x0002 + RPF_REDIRECT_INPUT = 0x0002, + RPF_ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004 }; CompilerManager::CompilerManager(QObject *parent) : QObject(parent), @@ -256,6 +257,8 @@ void CompilerManager::run( if (pSettings->executor().pauseConsole()) consoleFlag |= RPF_PAUSE_CONSOLE; #ifdef Q_OS_WIN + if (pSettings->executor().enableVirualTerminalSequence()) + consoleFlag |= RPF_ENABLE_VIRTUAL_TERMINAL_PROCESSING; if (consoleFlag!=0) { QString sharedMemoryId = QUuid::createUuid().toString(); QString consolePauserPath = includeTrailingPathDelimiter(pSettings->dirs().appDir()) + CONSOLE_PAUSER; diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 17cc6d24..2d1290d4 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -3623,36 +3623,9 @@ void Settings::Environment::doLoad() mUseCustomTerminal = true; #endif -#ifdef Q_OS_WINDOWS - QString terminalListFilename(":/config/terminal-windows.json"); -#else // UNIX - QString terminalListFilename(":/config/terminal-unix.json"); -#endif - QFile terminalListFile(terminalListFilename); - if (!terminalListFile.open(QFile::ReadOnly)) - throw FileError(QObject::tr("Can't open file '%1' for read.") - .arg(terminalListFilename)); - QByteArray terminalListContent = terminalListFile.readAll(); - QJsonDocument terminalListDocument(QJsonDocument::fromJson(terminalListContent)); - // check saved terminal path - QString savedTerminalPath = stringValue("terminal_path", ""); - QString savedArgsPattern = stringValue("terminal_arguments_pattern", ""); - bool terminalSet = checkAndSetTerminal(savedTerminalPath, savedArgsPattern); - - // determing terminal (if not set yet) and build predefined arguments pattern map from our list - for (const auto &terminalGroup: terminalListDocument.array()) { - const QJsonArray &terminals = terminalGroup.toObject()["terminals"].toArray(); - for (const auto &terminal_: terminals) { - const QJsonObject &terminal = terminal_.toObject(); - const QString &path = terminal["path"].toString(); - const QString &executable = QFileInfo(path).fileName(); - const QString &pattern = terminal["argsPattern"].toString(); - mPredefinedTerminalArgumentsPattern[executable] = pattern; - if (!terminalSet) - terminalSet = checkAndSetTerminal(path, pattern); - } - } + mTerminalPath = stringValue("terminal_path", ""); + mTerminalArgumentsPattern = stringValue("terminal_arguments_pattern", ""); mAStylePath = includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"astyle"; mHideNonSupportFilesInFileView=boolValue("hide_non_support_files_file_view",true); @@ -3798,23 +3771,32 @@ void Settings::Environment::setIconZoomFactor(double newIconZoomFactor) mIconZoomFactor = newIconZoomFactor; } -QMap Settings::Environment::predefinedTerminalArgumentsPattern() const +QString Settings::Environment::queryPredefinedTerminalArgumentsPattern(const QString &executable) const { - return mPredefinedTerminalArgumentsPattern; -} +#ifdef Q_OS_WINDOWS + QString terminalListFilename(":/config/terminal-windows.json"); +#else // UNIX + QString terminalListFilename(":/config/terminal-unix.json"); +#endif + QFile terminalListFile(terminalListFilename); + if (!terminalListFile.open(QFile::ReadOnly)) + throw FileError(QObject::tr("Can't open file '%1' for read.") + .arg(terminalListFilename)); + QByteArray terminalListContent = terminalListFile.readAll(); + QJsonDocument terminalListDocument(QJsonDocument::fromJson(terminalListContent)); -void Settings::Environment::setPredefinedTerminalArgumentsPattern(const QMap &newPredefinedTerminalArgumentsPattern) -{ - mPredefinedTerminalArgumentsPattern = newPredefinedTerminalArgumentsPattern; -} - -std::unique_ptr Settings::Environment::queryPredefinedTerminalArgumentsPattern(const QString &executable) const -{ - auto it = mPredefinedTerminalArgumentsPattern.find(executable); - if (it != mPredefinedTerminalArgumentsPattern.end()) - return std::make_unique(*it); - else - return nullptr; + // determing terminal (if not set yet) and build predefined arguments pattern map from our list + for (const auto &terminalGroup: terminalListDocument.array()) { + const QJsonArray &terminals = terminalGroup.toObject()["terminals"].toArray(); + for (const auto &terminal_: terminals) { + const QJsonObject &terminal = terminal_.toObject(); + const QString &path = terminal["path"].toString(); + const QString &termExecutable = QFileInfo(path).fileName(); + const QString &pattern = terminal["argsPattern"].toString(); + if (QString::compare( executable , termExecutable, PATH_SENSITIVITY)==0) return pattern; + } + } + return QString(); } bool Settings::Environment::useCustomTerminal() const @@ -3827,59 +3809,59 @@ void Settings::Environment::setUseCustomTerminal(bool newUseCustomTerminal) mUseCustomTerminal = newUseCustomTerminal; } -bool Settings::Environment::checkAndSetTerminal(QString terminalPath, QString argsPattern) -{ - QStringList patternItems = splitProcessCommand(argsPattern); +//bool Settings::Environment::checkAndSetTerminal(QString terminalPath, QString argsPattern) +//{ +// QStringList patternItems = splitProcessCommand(argsPattern); - if (patternItems.empty() || - !(patternItems.contains("$argv") || patternItems.contains("$command") || patternItems.contains("$tmpfile")) // program not referenced - ) - return false; +// if (patternItems.empty() || +// !(patternItems.contains("$argv") || patternItems.contains("$command") || patternItems.contains("$tmpfile")) // program not referenced +// ) +// return false; - // `term` is not referenced ("$argv"), - // or is not directly called ("open -app $term -args $tmpfile"), - // do not check terminal path - if (patternItems[0] != "$term") { - setTerminalPath(terminalPath); - setTerminalArgumentsPattern(argsPattern); - return true; - } +// // `term` is not referenced ("$argv"), +// // or is not directly called ("open -app $term -args $tmpfile"), +// // do not check terminal path +// if (patternItems[0] != "$term") { +// setTerminalPath(terminalPath); +// setTerminalArgumentsPattern(argsPattern); +// return true; +// } -#define DO_CHECK_AND_SET do { \ - if (termPathInfo.isFile() && termPathInfo.isReadable() && termPathInfo.isExecutable()) { \ - mTerminalPath = terminalPath; \ - mTerminalArgumentsPattern = argsPattern; \ - return true; \ - } \ - } while (0) +//#define DO_CHECK_AND_SET do { \ +// if (termPathInfo.isFile() && termPathInfo.isReadable() && termPathInfo.isExecutable()) { \ +// mTerminalPath = terminalPath; \ +// mTerminalArgumentsPattern = argsPattern; \ +// return true; \ +// } \ +// } while (0) - switch (getPathUnixExecSemantics(terminalPath)) { - case UnixExecSemantics::Absolute: { - QFileInfo termPathInfo(terminalPath); - DO_CHECK_AND_SET; - break; - } - case UnixExecSemantics::RelativeToCwd: { - QDir appDir(pSettings->dirs().appDir()); - QString absoluteTerminalPath = appDir.absoluteFilePath(terminalPath); - QFileInfo termPathInfo(absoluteTerminalPath); - DO_CHECK_AND_SET; - break; - } - case UnixExecSemantics::SearchInPath: { - QStringList pathList = getExecutableSearchPaths(); - for (const QString &dir: pathList) { - QString absoluteTerminalPath = QDir(dir).absoluteFilePath(terminalPath); - QFileInfo termPathInfo(absoluteTerminalPath); - DO_CHECK_AND_SET; - } - break; - } - } -#undef DO_CHECK_AND_SET +// switch (getPathUnixExecSemantics(terminalPath)) { +// case UnixExecSemantics::Absolute: { +// QFileInfo termPathInfo(terminalPath); +// DO_CHECK_AND_SET; +// break; +// } +// case UnixExecSemantics::RelativeToCwd: { +// QDir appDir(pSettings->dirs().appDir()); +// QString absoluteTerminalPath = appDir.absoluteFilePath(terminalPath); +// QFileInfo termPathInfo(absoluteTerminalPath); +// DO_CHECK_AND_SET; +// break; +// } +// case UnixExecSemantics::SearchInPath: { +// QStringList pathList = getExecutableSearchPaths(); +// for (const QString &dir: pathList) { +// QString absoluteTerminalPath = QDir(dir).absoluteFilePath(terminalPath); +// QFileInfo termPathInfo(absoluteTerminalPath); +// DO_CHECK_AND_SET; +// } +// break; +// } +// } +//#undef DO_CHECK_AND_SET - return false; -} +// return false; +//} void Settings::Environment::doSave() { @@ -4051,6 +4033,16 @@ void Settings::Executor::setProblemCaseValidateType(ProblemCaseValidateType newP mProblemCaseValidateType = newProblemCaseValidateType; } +bool Settings::Executor::enableVirualTerminalSequence() const +{ + return mEnableVirualTerminalSequence; +} + +void Settings::Executor::setEnableVirualTerminalSequence(bool newEnableVirualTerminalSequence) +{ + mEnableVirualTerminalSequence = newEnableVirualTerminalSequence; +} + bool Settings::Executor::convertHTMLToTextForInput() const { return mConvertHTMLToTextForInput; @@ -4114,6 +4106,9 @@ void Settings::Executor::setEnableProblemSet(bool newEnableProblemSet) void Settings::Executor::doSave() { saveValue("pause_console", mPauseConsole); +#ifdef Q_OS_WIN + saveValue("enable_virtual_terminal_sequence", mEnableVirualTerminalSequence); +#endif saveValue("minimize_on_run", mMinimizeOnRun); saveValue("use_params",mUseParams); saveValue("params",mParams); @@ -4149,6 +4144,9 @@ void Settings::Executor::setPauseConsole(bool pauseConsole) void Settings::Executor::doLoad() { mPauseConsole = boolValue("pause_console",true); +#ifdef Q_OS_WIN + mEnableVirualTerminalSequence = boolValue("enable_virtual_terminal_sequence", true); +#endif mMinimizeOnRun = boolValue("minimize_on_run",false); mUseParams = boolValue("use_params",false); mParams = stringValue("params", ""); diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 933bfdf2..97b62fbb 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -596,18 +596,13 @@ public: QJsonArray availableTerminals() const; void setAvailableTerminals(const QJsonArray &availableTerminals); - QMap predefinedTerminalArgumentsPattern() const; - void setPredefinedTerminalArgumentsPattern(const QMap &newPredefinedTerminalArgumentsPattern); - // it should be `std::optional`. - // `std::unique_ptr` is a work around for Debian 10, where Qt 5.11 doesnt recognize `CONFIG += c++17`, - // and macOS, where official Qt 5.15 is built against macOS 10.13 and `std::optional` is explicitly disabled. - std::unique_ptr queryPredefinedTerminalArgumentsPattern(const QString &executable) const; + QString queryPredefinedTerminalArgumentsPattern(const QString &executable) const; bool useCustomTerminal() const; void setUseCustomTerminal(bool newUseCustomTerminal); private: - bool checkAndSetTerminal(QString terminalPath, QString argsPattern); +// bool checkAndSetTerminal(QString terminalPath, QString argsPattern); bool updateTerminalList(); //Appearance @@ -625,7 +620,6 @@ public: QString mTerminalPath; QString mAStylePath; QString mTerminalArgumentsPattern; - QMap mPredefinedTerminalArgumentsPattern; bool mUseCustomTerminal; bool mHideNonSupportFilesInFileView; bool mOpenFilesInSingleInstance; @@ -955,6 +949,8 @@ public: ProblemCaseValidateType problemCaseValidateType() const; void setProblemCaseValidateType(ProblemCaseValidateType newProblemCaseValidateType); + bool enableVirualTerminalSequence() const; + void setEnableVirualTerminalSequence(bool newEnableVirualTerminalSequence); private: // general bool mPauseConsole; @@ -963,6 +959,7 @@ public: QString mParams; bool mRedirectInput; QString mInputFilename; + bool mEnableVirualTerminalSequence; //Problem Set bool mEnableProblemSet; diff --git a/RedPandaIDE/settingsdialog/environmentprogramswidget.cpp b/RedPandaIDE/settingsdialog/environmentprogramswidget.cpp index e0a8c630..0fbc528b 100644 --- a/RedPandaIDE/settingsdialog/environmentprogramswidget.cpp +++ b/RedPandaIDE/settingsdialog/environmentprogramswidget.cpp @@ -67,9 +67,9 @@ void EnvironmentProgramsWidget::updateCommandPreview(const QString &terminalPath void EnvironmentProgramsWidget::autoDetectAndUpdateArgumentsPattern(const QString &terminalPath) { const QString &executable = QFileInfo(terminalPath).fileName(); - const std::unique_ptr &pattern = pSettings->environment().queryPredefinedTerminalArgumentsPattern(executable); - if (pattern != nullptr) - ui->txtArgsPattern->setText(*pattern); + const QString &pattern = pSettings->environment().queryPredefinedTerminalArgumentsPattern(executable); + if (!pattern.isEmpty()) + ui->txtArgsPattern->setText(pattern); else QMessageBox::warning(nullptr, QObject::tr("Auto Detection Failed"), diff --git a/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp index 1aa3dd1d..5e05e7cb 100644 --- a/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp @@ -30,6 +30,11 @@ ExecutorGeneralWidget::ExecutorGeneralWidget(const QString& name, const QString& { ui->setupUi(this); ui->txtParsedArgsInJson->setFont(QFont(DEFAULT_MONO_FONT)); +#ifdef Q_OS_WIN + ui->chkVTSeq->setVisible(true); +#else + ui->chkVTSeq->setVisible(false); +#endif } ExecutorGeneralWidget::~ExecutorGeneralWidget() @@ -40,6 +45,9 @@ ExecutorGeneralWidget::~ExecutorGeneralWidget() void ExecutorGeneralWidget::doLoad() { ui->chkPauseConsole->setChecked(pSettings->executor().pauseConsole()); +#ifdef Q_OS_WIN + ui->chkVTSeq->setChecked(pSettings->executor().enableVirualTerminalSequence()); +#endif ui->chkMinimizeOnRun->setChecked(pSettings->executor().minimizeOnRun()); ui->grpExecuteParameters->setChecked(pSettings->executor().useParams()); ui->txtExecuteParamaters->setText(pSettings->executor().params()); @@ -50,6 +58,9 @@ void ExecutorGeneralWidget::doLoad() void ExecutorGeneralWidget::doSave() { pSettings->executor().setPauseConsole(ui->chkPauseConsole->isChecked()); +#ifdef Q_OS_WIN + pSettings->executor().setEnableVirualTerminalSequence(ui->chkVTSeq->isChecked()); +#endif pSettings->executor().setMinimizeOnRun(ui->chkMinimizeOnRun->isChecked()); pSettings->executor().setUseParams(ui->grpExecuteParameters->isChecked()); pSettings->executor().setParams(ui->txtExecuteParamaters->text()); @@ -83,4 +94,3 @@ void ExecutorGeneralWidget::on_txtExecuteParamaters_textChanged(const QString &c QJsonArray obj = QJsonArray::fromStringList(parsed); ui->txtParsedArgsInJson->setText(QJsonDocument{obj}.toJson()); } - diff --git a/RedPandaIDE/settingsdialog/executorgeneralwidget.ui b/RedPandaIDE/settingsdialog/executorgeneralwidget.ui index 329949c6..9afdaac6 100644 --- a/RedPandaIDE/settingsdialog/executorgeneralwidget.ui +++ b/RedPandaIDE/settingsdialog/executorgeneralwidget.ui @@ -24,6 +24,13 @@ + + + + Enable Virtual Terminal Sequence Support + + + @@ -67,8 +74,7 @@ - - + diff --git a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts index 11709c75..463085ab 100644 --- a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts +++ b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts @@ -2090,6 +2090,10 @@ Parsed argv array (represented in JSON): + + Enable Virtual Terminal Sequence Support + + ExecutorProblemSetWidget diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts index 15a3b65e..da0e8515 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts @@ -687,29 +687,29 @@ p, li { white-space: pre-wrap; } CompilerManager - - - - - + + + + + No compiler set 无编译器设置 - - - - - + + + + + No compiler set is configured. 没有配置编译器设置。 - - - - - + + + + + Can't start debugging. 无法启动调试器 @@ -726,12 +726,12 @@ p, li { white-space: pre-wrap; } 程序中的文字内容可能无法被正确处理和显示。 - + Can't find Console Pauser 找不到Console Pauser程序 - + Console Pauser "%1" doesn't exists! 找不到Console Pauser程序"%1"! @@ -1505,10 +1505,10 @@ Are you really want to continue? - - - - + + + + Error 错误 @@ -1557,44 +1557,44 @@ Are you really want to continue? 文件%1已经被打开! - + The text to be copied exceeds count limit! 要复制的内容超过了行数限制! - + The text to be copied exceeds character limit! 要复制的内容超过了字符数限制! - + The text to be cut exceeds count limit! 要剪切的内容超过了行数限制! - + The text to be cut exceeds character limit! 要剪切的内容超过了字符数限制! - + hex: %1 16进制: %1 - + dec: %1 十进制: %1 - + Print Document 打印文档 - - - + + + Ctrl+click for more info Ctrl+单击以获取更多信息 @@ -1603,27 +1603,27 @@ Are you really want to continue? 未找到符号'%1'! - + astyle not found 找不到astyle程序 - + Can't find astyle in "%1". 找不到astyle程序"%1". - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -2670,74 +2670,75 @@ Are you really want to continue? Editors share one code parser 编辑器共享同一个代码分析器 - -EnvironmentProgramsWidget - - - Form - 表单 - - - - Use custom terminal - 使用自定义终端 - - - - - - ... - ... - - - - Cmd. preview - 命令行预览 - - - - Auto Detect Terminal Arguments Pattern - 自动检测终端参数模式 - - - - Terminal - 终端 - - - - Test Command - 测试命令 - - - - $term -e $argv - - - - - Args. pattern - 参数模式 - - - - term -e sh -c "echo hello; sleep 3" - - - - - Choose Terminal Program - 选择终端程序 - - - - All files (%1) - 所有文件 (%1) - - - All files (*.*) - 所有文件 (*.*) - + + + EnvironmentProgramsWidget + + + Form + 表单 + + + + Use custom terminal + 使用自定义终端 + + + + + + ... + ... + + + + Cmd. preview + 命令行预览 + + + + Auto Detect Terminal Arguments Pattern + 自动检测终端参数模式 + + + + Terminal + 终端 + + + + Test Command + 测试命令 + + + + $term -e $argv + + + + + Args. pattern + 参数模式 + + + + term -e sh -c "echo hello; sleep 3" + + + + + Choose Terminal Program + 选择终端程序 + + + + All files (%1) + 所有文件 (%1) + + + All files (*.*) + 所有文件 (*.*) + EnvironmentShortcutModel @@ -2783,7 +2784,7 @@ Are you really want to continue? ExecutableRunner - + The runner process '%1' failed to start. The runner process failed to start. 无法启动程序运行进程'%1'。 @@ -2793,17 +2794,17 @@ Are you really want to continue? 程序运行进程启动后崩溃。 - + The last waitFor...() function timed out. waitFor()函数等待超时。 - + An error occurred when attempting to write to the runner process. 在向程序运行进程写入内容时出错。 - + An error occurred when attempting to read from the runner process. 在从程序运行进程读取内容时出错。 @@ -2826,42 +2827,47 @@ Are you really want to continue? + Enable Virtual Terminal Sequence Support + + + + Minimize IDE when running programs 在运行程序时自动最小化IDE - + Parameters to pass to your program 运行程序的命令行参数 - + Parsed argv array (represented in JSON): argv 数组解析结果(以 JSON 表示): - + Redirect input to the following file: 将程序的标准输入重定向到下面的文件 - + Debugger doesn't support this feature in Linux. Linux下调试器不支持此功能。 - + Note: 说明: - + Debugger only support this feature in gdb server mode in windows. Windows下调试器需启用gdb server模式支持此功能。 - - + + Browse 浏览 @@ -2870,12 +2876,12 @@ Are you really want to continue? 注意:由于gdb的bug,调试时不支持该功能 - + Choose input file 选择输入文件 - + All files (%1) 所有文件 (%1) @@ -8759,7 +8765,7 @@ Are you really want to continue? QApplication - + Error 错误 @@ -8846,7 +8852,7 @@ Are you really want to continue? 无法写入配置文件夹"%1" - + Can't load autolink settings 无法载入自动链接设置 @@ -8908,7 +8914,7 @@ Are you really want to continue? - + Code Generation 代码生成 @@ -8936,7 +8942,7 @@ Are you really want to continue? 使用下列指针大小编译(-mx) - + Processor (-m) 处理器类型(-m) @@ -8954,7 +8960,7 @@ Are you really want to continue? 生成调试信息(-g3) - + Would you like Red Panda C++ to search for compilers in PATH? 您同意小熊猫C++在PATH路径中寻找gcc编译器吗? @@ -8992,7 +8998,7 @@ Are you really want to continue? 检查栈溢出(stack smashing)错误 (-fstack-protector) - + Enable Sanitizer (-fsanitize=) 启用地址消毒(-fsanitize=) @@ -9017,82 +9023,82 @@ Are you really want to continue? 检查是否严格遵守ISO C/C++标准 - + Language standard (--std) C语言标准(--std) - + Memory model (--model) 内存模型(--model) - + Use external stack 使用外部栈空间 - + Use movc instead of movx to read from external ram 使用movc代替movx访问外部RAM - + Replaces lcall/ljmp with acall/ajmp 用acall/ajmp代替lcall/ljmp - + Don't memcpy initialized xram from code Don't memcpy initialized xram from code - + Don't generate startup code 无main函数时不生成起始代码(用于edsim51模拟器) - + MCU Specification 微处理器参数 - + Internal ram size 内部RAM大小 - + External ram start location 外部RAM起始地址 - + External ram size 外部RAM大小 - + Stack pointer initial value 栈指针寄存器初始地址 - + External stack start location 外部栈空间起始地址 - + Direct data start location 内部数据区起始地址 - + Code segment location 代码段起始地址 - + Code segment size 代码段大小 @@ -9116,7 +9122,7 @@ Are you really want to continue? 遇到第一个错误后立即中止编译(-Wfatal-errors) - + Linker 链接器 @@ -9125,17 +9131,17 @@ Are you really want to continue? 链接Objective-C程序 (-lobjc) - + Do not use standard system libraries (-nostdlib) 不使用标准库和系统启动文件(-nostdlib) - + Do not create a console window (-mwindows) 不产生控制台窗口(-mwindows) - + Strip executable (-s) 剥除附加信息(-s) @@ -9156,7 +9162,7 @@ Are you really want to continue? 仅预处理(-E) - + Use pipes instead of temporary files during compilation (-pipe) 编译时使用管道而不是临时文件(-pipe) @@ -9165,7 +9171,7 @@ Are you really want to continue? 只生成汇编代码(-S) - + Confirm 确认 @@ -9186,13 +9192,13 @@ Are you really want to continue? 如果仍然保留这些设置,可能会导致编译错误。<br /><br />请选择“是”,除非您清楚的知道选择“否”的后果, - - + + Compiler set not configuared. 未配置编译器设置。 - + Would you like Red Panda C++ to search for compilers in the following locations: <BR />'%1'<BR />'%2'? 您需要小熊猫C++在下列位置搜索编译器吗:<br />%1<br />%2 @@ -9559,8 +9565,9 @@ Are you really want to continue? - + + Can't open file '%1' for read. @@ -9568,7 +9575,7 @@ Are you really want to continue? - + Can't open file '%1' for write. 无法写入文件'%1'. @@ -9605,12 +9612,12 @@ Are you really want to continue? 在写入文件“%1”时出错。 - + Auto Detection Failed 自动检测失败 - + Failed to detect terminal arguments pattern for “%1”. 无法检测适用于 “%1” 的终端参数模式。 @@ -10732,9 +10739,9 @@ Are you really want to continue? - - - + + + Environment 环境 @@ -10753,12 +10760,12 @@ Are you really want to continue? 文件夹 - + Terminal 终端程序 - + Performance 性能 @@ -10767,230 +10774,230 @@ Are you really want to continue? - - + + Compiler Set 编译器配置集 - - + + Compiler 编译器 - + Auto Link 自动链接 - - - - - - + + + + + + General 通用 - - - - - - - - - - - + + + + + + + + + + + Editor 编辑器 - + Font 字体 - + Copy & Export 复制/导出 - + Color 配色 - + Code Completion 代码补全 - + Symbol Completion 符号补全 - + Snippet 代码模板 - + Auto Syntax Checking 自动语法检查 - + Tooltips 信息提示 - + Auto save 自动保存 - + Misc 杂项 - - + + Program Runner 程序运行 - + Problem Set 试题集 - + Folders / Restore Default Settings 文件夹 / 恢复出厂设置 - + Custom C/C++ Keywords 自定义C/C++关键字 - - + + Languages 语言 - + ASM Generation 生成汇编代码 - + Debugger 调试器 - - + + Code Formatter 代码排版 - + Program 程序 - - + + Tools 工具 - + Git Git - + Project Options 项目选项 - - - - - - - - - - + + + + + + + + + + Project 项目 - + Files 文件 - + Custom Compile options 自定义编译选项 - + Directories 文件夹 - + Precompiled Header 预编译头文件 - + Makefile Makefile - + Output 输出 - + DLL host DLL宿主 - + Version info 版本信息 - + Save Changes 保存修改 - + There are changes in the settings, do you want to save them before swtich to other page? 本页中有尚未保存的设置修改,是否保存后再切换到其他页? diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts index 34007e4a..d0c5c668 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts @@ -1923,6 +1923,10 @@ Parsed argv array (represented in JSON): + + Enable Virtual Terminal Sequence Support + + ExecutorProblemSetWidget diff --git a/tools/consolepauser/main.windows.cpp b/tools/consolepauser/main.windows.cpp index d2f5d5e3..2992f224 100644 --- a/tools/consolepauser/main.windows.cpp +++ b/tools/consolepauser/main.windows.cpp @@ -38,7 +38,8 @@ using std::string; enum RunProgramFlag { RPF_PAUSE_CONSOLE = 0x0001, - RPF_REDIRECT_INPUT = 0x0002 + RPF_REDIRECT_INPUT = 0x0002, + RPF_ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004 }; HANDLE hJob; @@ -98,11 +99,12 @@ void PauseExit(int exitcode, bool reInp) { exit(exitcode); } -string GetCommand(int argc,char** argv,bool &reInp,bool &pauseAfterExit) { +string GetCommand(int argc,char** argv,bool &reInp,bool &pauseAfterExit, bool &enableVisualTerminalSeq) { string result; int flags = atoi(argv[1]); reInp = flags & RPF_REDIRECT_INPUT; pauseAfterExit = flags & RPF_PAUSE_CONSOLE; + enableVisualTerminalSeq = flags & RPF_ENABLE_VIRTUAL_TERMINAL_PROCESSING; for(int i = 3;i < argc;i++) { // Quote the argument in case the path name contains spaces result += string("\"") + string(argv[i]) + string("\""); @@ -219,8 +221,9 @@ int main(int argc, char** argv) { bool reInp; bool pauseAfterExit; + bool enableVisualTerminalSeq; // Then build the to-run application command - string command = GetCommand(argc,argv,reInp, pauseAfterExit); + string command = GetCommand(argc,argv,reInp, pauseAfterExit, enableVisualTerminalSeq); HANDLE hOutput = NULL; if (reInp) { SECURITY_ATTRIBUTES sa; @@ -237,7 +240,9 @@ int main(int argc, char** argv) { } else { FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); } - EnableVtSequence(); + if (enableVisualTerminalSeq) { + EnableVtSequence(); + } HANDLE hSharedMemory=INVALID_HANDLE_VALUE; int BUF_SIZE=1024; @@ -255,7 +260,7 @@ int main(int argc, char** argv) { 0, BUF_SIZE); } else { - printf("can't open shared memory!"); + printf("can't open shared memory!\n"); } // Save starting timestamp