From 833be397b01661aefaf95c9b172e0d0c737f3525 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 27 Oct 2022 15:18:57 +0800 Subject: [PATCH] - enhancement: add "editors share one code parser" in "options" / "editor" / "code completion", to reduce memory usage. Turned off by default on PCs with memory > 4G; Force turned on PCs with memory < 1G. - enhancement: add "goto block start"/"goto block end" in "Code" menu --- NEWS.md | 7 +- RedPandaIDE/editor.cpp | 51 +- RedPandaIDE/editor.h | 5 + RedPandaIDE/mainwindow.cpp | 16 + RedPandaIDE/mainwindow.h | 4 + RedPandaIDE/mainwindow.ui | 18 + RedPandaIDE/settings.cpp | 37 +- RedPandaIDE/settings.h | 8 +- .../editorcodecompletionwidget.cpp | 3 + .../editorcodecompletionwidget.ui | 7 + .../environmentperformancewidget.cpp | 11 +- .../environmentperformancewidget.ui | 11 +- RedPandaIDE/translations/RedPandaIDE_pt_BR.ts | 28 +- RedPandaIDE/translations/RedPandaIDE_zh_CN.ts | 1281 +++++++++-------- RedPandaIDE/translations/RedPandaIDE_zh_TW.ts | 32 +- libs/qsynedit/qsynedit/KeyStrokes.cpp | 5 + libs/qsynedit/qsynedit/KeyStrokes.h | 4 + libs/qsynedit/qsynedit/SynEdit.cpp | 110 +- libs/qsynedit/qsynedit/SynEdit.h | 10 +- 19 files changed, 969 insertions(+), 679 deletions(-) diff --git a/NEWS.md b/NEWS.md index 84d3f6d2..a0c85c49 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,10 @@ Red Panda C++ Version 2.1 - - editors that not in the editing panel shouldn't trigger switch breakpoint - - editors that not in the editing panel shouldn't show context menu + - fix: editors that not in the editing panel shouldn't trigger switch breakpoint + - fix:editors that not in the editing panel shouldn't show context menu + - enhancement: add "editors share one code parser" in "options" / "editor" / "code completion", to reduce memory usage. + Turned off by default on PCs with memory > 4G; Force turned on PCs with memory < 1G. + - enhancement: add "goto block start"/"goto block end" in "Code" menu Red Panda C++ Version 2.0 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 793567f6..f6787bac 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -69,6 +69,8 @@ const char* SaveException::what() const noexcept { return mReasonBuffer; } +std::weak_ptr Editor::mSharedParser; + Editor::Editor(QWidget *parent): Editor(parent,QObject::tr("untitled"),ENCODING_AUTO_DETECT,nullptr,true,nullptr) { @@ -1321,6 +1323,7 @@ void Editor::showEvent(QShowEvent */*event*/) void Editor::hideEvent(QHideEvent */*event*/) { if (pSettings->codeCompletion().clearWhenEditorHidden() + && !pSettings->codeCompletion().shareParser() && !inProject() && mParser && !pMainWindow->isMinimized()) { //recreate a parser, to totally clean memories the parse uses; @@ -1833,6 +1836,16 @@ void Editor::deleteToBOL() commandProcessor(QSynedit::EditCommand::ecDeleteBOL,QChar(),nullptr); } +void Editor::gotoBlockStart() +{ + commandProcessor(QSynedit::EditCommand::ecBlockStart,QChar(),nullptr); +} + +void Editor::gotoBlockEnd() +{ + commandProcessor(QSynedit::EditCommand::ecBlockEnd,QChar(),nullptr); +} + QStringList Editor::getOwnerExpressionAndMemberAtPositionForCompletion( const QSynedit::BufferCoord &pos, QString &memberOperator, @@ -2567,6 +2580,15 @@ bool Editor::handleCodeCompletion(QChar key) void Editor::initParser() { // mParser=nullptr; + if (pSettings->codeCompletion().shareParser()) { + if (pSettings->codeCompletion().enabled() + && (highlighter() && highlighter()->getClass() == QSynedit::HighlighterClass::CppHighlighter) + ) { + mParser = sharedParser(); + } + return; + } + mParser = std::make_shared(); if (mUseCppSyntax) { mParser->setLanguage(ParserLanguage::CPlusPlus); @@ -2721,11 +2743,13 @@ void Editor::reparse(bool resetParser) return; //mParser->setEnabled(pSettings->codeCompletion().enabled()); ParserLanguage language = mUseCppSyntax?ParserLanguage::CPlusPlus:ParserLanguage::C; - if (language!=mParser->language() && !inProject()) { - mParser->setLanguage(language); - resetCppParser(mParser); - } else if (resetParser && !inProject()) { - resetCppParser(mParser); + if (!inProject() && !pSettings->codeCompletion().shareParser()) { + if (language!=mParser->language()) { + mParser->setLanguage(language); + resetCppParser(mParser); + } else if (resetParser) { + resetCppParser(mParser); + } } parseFile(mParser,mFilename, inProject()); } @@ -3918,6 +3942,23 @@ void Editor::onScrollBarValueChanged() pMainWindow->functionTip()->hide(); } +PCppParser Editor::sharedParser() +{ + PCppParser parser=mSharedParser.lock(); + if (!parser) { + parser=std::make_shared(); + parser->setLanguage(ParserLanguage::CPlusPlus); + parser->setOnGetFileStream( + std::bind( + &EditorList::getContentFromOpenedEditor,pMainWindow->editorList(), + std::placeholders::_1, std::placeholders::_2)); + resetCppParser(parser); + parser->setEnabled(true); + mSharedParser=parser; + } + return parser; +} + bool Editor::canAutoSave() const { return mCanAutoSave; diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index f2498fce..b0d94f46 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -216,6 +216,8 @@ public: void duplicateLine(); void deleteToEOL(); void deleteToBOL(); + void gotoBlockStart(); + void gotoBlockEnd(); QStringList getOwnerExpressionAndMemberAtPositionForCompletion( const QSynedit::BufferCoord& pos, @@ -290,6 +292,7 @@ private: void onExportedFormatToken(QSynedit::PHighlighter syntaxHighlighter, int Line, int column, const QString& token, QSynedit::PHighlighterAttribute &attr); void onScrollBarValueChanged(); + static PCppParser sharedParser(); private: QByteArray mEncodingOption; // the encoding type set by the user QByteArray mFileEncoding; // the real encoding of the file (auto detected) @@ -340,6 +343,8 @@ private: QTimer mFunctionTipTimer; int mHoverModifiedLine; + static std::weak_ptr mSharedParser; + // QWidget interface protected: void wheelEvent(QWheelEvent *event) override; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 31bdf428..55828b7d 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -8639,3 +8639,19 @@ bool MainWindow::isClosingAll() const return mClosingAll; } + +void MainWindow::on_actionGoto_block_start_triggered() +{ + Editor* editor=mEditorList->getEditor(); + if (editor) + editor->gotoBlockStart(); +} + + +void MainWindow::on_actionGoto_block_end_triggered() +{ + Editor* editor=mEditorList->getEditor(); + if (editor) + editor->gotoBlockEnd(); +} + diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index d6b7fa26..f0a62c9a 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -728,6 +728,10 @@ private slots: void on_actionNew_Template_triggered(); + void on_actionGoto_block_start_triggered(); + + void on_actionGoto_block_end_triggered(); + private: Ui::MainWindow *ui; EditorList *mEditorList; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 88e2e1b9..e99e1f88 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -221,6 +221,8 @@ + + @@ -3237,6 +3239,22 @@ New Template from Project + + + Goto block start + + + Ctrl+Alt+Up + + + + + Goto block end + + + Ctrl+Alt+Down + + diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index f61e82e0..6f7cab25 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -3691,8 +3691,14 @@ void Settings::CodeCompletion::setShowCodeIns(bool newShowCodeIns) mShowCodeIns = newShowCodeIns; } -bool Settings::CodeCompletion::clearWhenEditorHidden() const +bool Settings::CodeCompletion::clearWhenEditorHidden() { + MEMORYSTATUSEX statex; +#ifdef Q_OS_WIN + if (statex.ullTotalPhys < (long long int)2*1024*1024*1024) { + mClearWhenEditorHidden = true; + } +#endif return mClearWhenEditorHidden; } @@ -3721,6 +3727,23 @@ void Settings::CodeCompletion::setHideSymbolsStartsWithTwoUnderLine(bool newHide mHideSymbolsStartsWithTwoUnderLine = newHideSymbolsStartsWithTwoUnderLine; } +bool Settings::CodeCompletion::shareParser() +{ + +#ifdef Q_OS_WIN + MEMORYSTATUSEX statex; + if (statex.ullTotalPhys < (long long int)1024*1024*1024) { + mShareParser = true; + } +#endif + return mShareParser; +} + +void Settings::CodeCompletion::setShareParser(bool newShareParser) +{ + mShareParser = newShareParser; +} + bool Settings::CodeCompletion::hideSymbolsStartsWithUnderLine() const { return mHideSymbolsStartsWithUnderLine; @@ -3859,6 +3882,7 @@ void Settings::CodeCompletion::doSave() saveValue("min_char_required",mMinCharRequired); saveValue("hide_symbols_start_with_two_underline", mHideSymbolsStartsWithTwoUnderLine); saveValue("hide_symbols_start_with_underline", mHideSymbolsStartsWithUnderLine); + saveValue("share_parser",mShareParser); } @@ -3896,11 +3920,18 @@ void Settings::CodeCompletion::doLoad() mClearWhenEditorHidden = boolValue("clear_when_editor_hidden",doClear); + bool shouldShare=true; + #ifdef Q_OS_WIN - if (statex.ullAvailPhys < (long long int)1024*1024*1024) { - mClearWhenEditorHidden = true; + statex.dwLength = sizeof (statex); + + GlobalMemoryStatusEx (&statex); + if (statex.ullAvailPhys > (long long int)4*1024*1024*1024) { + shouldShare = false; } #endif + + mShareParser = boolValue("share_parser",shouldShare); } Settings::CodeFormatter::CodeFormatter(Settings *settings): diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index cf578d63..96c39381 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -602,7 +602,7 @@ public: bool showCodeIns() const; void setShowCodeIns(bool newShowCodeIns); - bool clearWhenEditorHidden() const; + bool clearWhenEditorHidden(); void setClearWhenEditorHidden(bool newClearWhenEditorHidden); int minCharRequired() const; @@ -614,6 +614,9 @@ public: bool hideSymbolsStartsWithTwoUnderLine() const; void setHideSymbolsStartsWithTwoUnderLine(bool newHideSymbolsStartsWithTwoUnderLine); + bool shareParser(); + void setShareParser(bool newShareParser); + private: int mWidth; int mHeight; @@ -627,10 +630,11 @@ public: bool mIgnoreCase; bool mAppendFunc; bool mShowCodeIns; - bool mClearWhenEditorHidden; int mMinCharRequired; bool mHideSymbolsStartsWithTwoUnderLine; bool mHideSymbolsStartsWithUnderLine; + bool mClearWhenEditorHidden; + bool mShareParser; // _Base interface protected: diff --git a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp index 51ca2221..5d770003 100644 --- a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp +++ b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.cpp @@ -54,6 +54,7 @@ void EditorCodeCompletionWidget::doLoad() ui->chkHideSymbolsStartWithTwoUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithTwoUnderLine()); ui->chkHideSymbolsStartWithUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithUnderLine()); + ui->chkEditorShareCodeParser->setChecked(pSettings->codeCompletion().shareParser()); ui->spinMinCharRequired->setValue(pSettings->codeCompletion().minCharRequired()); } @@ -82,6 +83,8 @@ void EditorCodeCompletionWidget::doSave() pSettings->codeCompletion().setHideSymbolsStartsWithTwoUnderLine(ui->chkHideSymbolsStartWithTwoUnderline->isChecked()); pSettings->codeCompletion().setHideSymbolsStartsWithUnderLine(ui->chkHideSymbolsStartWithUnderline->isChecked()); + pSettings->codeCompletion().setShareParser(ui->chkEditorShareCodeParser->isChecked()); + pSettings->codeCompletion().save(); } diff --git a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.ui b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.ui index dcec458a..433dd337 100644 --- a/RedPandaIDE/settingsdialog/editorcodecompletionwidget.ui +++ b/RedPandaIDE/settingsdialog/editorcodecompletionwidget.ui @@ -74,6 +74,13 @@ + + + + Editors share one code parser + + + diff --git a/RedPandaIDE/settingsdialog/environmentperformancewidget.cpp b/RedPandaIDE/settingsdialog/environmentperformancewidget.cpp index 63245f0b..5cdfdcdc 100644 --- a/RedPandaIDE/settingsdialog/environmentperformancewidget.cpp +++ b/RedPandaIDE/settingsdialog/environmentperformancewidget.cpp @@ -39,17 +39,26 @@ void EnvironmentPerformanceWidget::doLoad() statex.dwLength = sizeof (statex); GlobalMemoryStatusEx (&statex); - if (statex.ullAvailPhys < (long long int)1024*1024*1024) { + if (statex.ullTotalPhys < (long long int)2*1024*1024*1024) { ui->chkClearWhenEditorHidden->setEnabled(false); ui->chkClearWhenEditorHidden->setChecked(true); pSettings->codeCompletion().setClearWhenEditorHidden(true); + pSettings->codeCompletion().save(); + } + if (statex.ullTotalPhys < (long long int)1024*1024*1024) { + ui->chkEditorsShareParser->setEnabled(false); + ui->chkEditorsShareParser->setChecked(true); + pSettings->codeCompletion().setShareParser(true); + pSettings->codeCompletion().save(); } #endif + ui->chkEditorsShareParser->setChecked(pSettings->codeCompletion().shareParser()); } void EnvironmentPerformanceWidget::doSave() { pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked()); + pSettings->codeCompletion().setShareParser(ui->chkEditorsShareParser->isChecked()); pSettings->codeCompletion().save(); } diff --git a/RedPandaIDE/settingsdialog/environmentperformancewidget.ui b/RedPandaIDE/settingsdialog/environmentperformancewidget.ui index 8d88a084..a838b646 100644 --- a/RedPandaIDE/settingsdialog/environmentperformancewidget.ui +++ b/RedPandaIDE/settingsdialog/environmentperformancewidget.ui @@ -6,7 +6,7 @@ 0 0 - 400 + 431 300 @@ -20,13 +20,20 @@ Reduce Memory Usage - + Auto clear parsed symbols when editor hidden + + + + Editors share one code parser + + + diff --git a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts index 692d1d9b..f94f14fe 100644 --- a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts +++ b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts @@ -1179,6 +1179,10 @@ Enable code competion + + Editors share one code parser + + EditorColorSchemeWidget @@ -1707,6 +1711,10 @@ Auto clear parsed symbols when editor hidden Limpar automaticamente símbolos verificados quando editor oculto + + Editors share one code parser + + EnvironmentProgramsWidget @@ -4688,6 +4696,22 @@ In current project + + Goto block start + + + + Ctrl+Alt+Up + + + + Goto block end + + + + Ctrl+Alt+Down + + NewClassDialog @@ -4838,7 +4862,7 @@ untitled - sem nome + sem nome Choose directory @@ -6623,7 +6647,7 @@ Column - Coluna + Coluna Content diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts index 73616e73..92e49c13 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts @@ -563,27 +563,27 @@ p, li { white-space: pre-wrap; } - 编译时间: %1 秒 - + [Error] [错误] - + [Warning] [警告] - + [Info] [信息] - + [Note] [说明] - + The compiler process for '%1' failed to start. 无法启动编译器进程'%1'。 @@ -592,27 +592,27 @@ p, li { white-space: pre-wrap; } 无法启动编译进程。 - + The compiler process crashed after starting successfully. 编译进程启动后崩溃。 - + The last waitFor...() function timed out. waitFor()函数等待超时。 - + An error occurred when attempting to write to the compiler process. 在向编译进程输入内容时出错。 - + An error occurred when attempting to read from the compiler process. 在从编译进程读取内容时出错。 - + An unknown error occurred. 发生了未知错误。 @@ -1305,7 +1305,7 @@ Are you really want to continue? Editor - + untitled 无标题 @@ -1318,13 +1318,13 @@ Are you really want to continue? 失败 - - - - - - - + + + + + + + Error 错误 @@ -1333,44 +1333,44 @@ Are you really want to continue? 无法写入文件"%1" - + Save As 另存为 - + File %1 already openned! 文件%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! 要剪切的内容超过了字符数限制! - + Print Document 打印文档 - - - + + + Ctrl+click for more info Ctrl+单击以获取更多信息 @@ -1379,27 +1379,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 只读 @@ -1561,83 +1561,88 @@ Are you really want to continue? + Editors share one code parser + 编辑器共享同一个代码分析器 + + + Clear all parsed symbols when editor is hidden 清除不活动编辑器中的符号表(大幅减少内存占用) - + Show completion suggestions while typing 输入时显示补全提示 - + Engine options 引擎选项 - + Scan local header files 扫描本地头文件 - + Scan system header files 扫描系统头文件 - + Show keywords in suggestions 提示C/C++关键字 - + Show code snippets in suggestions 提示用户自定义代码段 - + Append () when complete functions 补全函数时自动添加() - + Ignore case when search suggestions 查找提示时忽略大小写 - + Prefer local symbols 优先提示局部作用域中的符号 - + Hide symbols start with underscore Hide symbols start with underline 隐藏以下划线开头的符号 - + Hide symbols start with two underscores Hide symbols start with two underline 隐藏以两个下划线开头的符号 - + Prefer symbols mostly used 优先提示经常使用的符号 - + Clear usage data 清除使用数据 - + Completion suggestion window width: 补全提示窗口宽度: - + Completion suggestion window height: 补全提示窗口高度: @@ -2309,6 +2314,11 @@ Are you really want to continue? Auto clear parsed symbols when editor hidden 自动清理被隐藏的编辑器中的符号表 + + + Editors share one code parser + 编辑器共享同一个代码分析器 + EnvironmentProgramsWidget @@ -3904,13 +3914,13 @@ Are you really want to continue? 小熊猫C++ - - - - - - - + + + + + + + Issues 编译器 @@ -3929,8 +3939,8 @@ Are you really want to continue? 工具 - - + + Run 运行 @@ -3940,27 +3950,27 @@ Are you really want to continue? 编辑 - - - + + + Project 项目 - - + + Watch 监视 - - + + Structure 结构 - - + + Files 文件 @@ -3969,69 +3979,69 @@ Are you really want to continue? 资源 - - - - - + + + + + Debug 调试 - + Evaluate: 求值 - + Debug Console 调试主控台 - + Call Stack 调用栈 - + Breakpoints 断点 - + Locals 局部变量 - - + + Search 查找 - + History: 历史: - + Search Again 重新查找 - + Replace with: 替换为: - + Replace 替换 - + Close 关闭 @@ -4042,12 +4052,12 @@ Are you really want to continue? - + Code 代码 - + Window 窗口 @@ -4065,418 +4075,418 @@ Are you really want to continue? 新建 - + Ctrl+N Ctrl+N - + Open... 打开... - + Ctrl+O Ctrl+O - + Save 保存 - + Ctrl+S Ctrl+S - + Save As... 另存为... - + Save As 另存为 - + Save All 全部保存 - + Ctrl+Shift+S Ctrl+Shift+S - + Options 选项 - - - - - + + + + + Compile 编译 - - + + Tools Output 工具输出 - - + + Choose Input File 选择输入文件 - + ... ... - + Tool Panels 工具面板 - + Git Git - + Selection 选择 - + F9 F9 - + F10 F10 - + Undo 恢复 - + Ctrl+Z Ctrl+Z - + Redo 重做 - + Ctrl+Y Ctrl+Y - + Cut 剪切 - + Ctrl+X Ctrl+X - - - - + + + + Copy 复制 - + Ctrl+C Ctrl+C - - + + Paste 粘贴 - + Ctrl+V Ctrl+V - - - + + + Select All 选择全部 - + Ctrl+A Ctrl+A - + Indent 缩进 - + UnIndent 取消缩进 - + Toggle Comment 切换注释 - + Ctrl+/ Ctrl+/ - + Collapse All 全部收起 - + Uncollapse All 全部展开 - + Encode in ANSI 使用ANSI编码 - + Encode in UTF-8 使用UTF-8编码 - + Auto Detect 自动检测 - + Convert to ANSI 转换为ANSI编码 - + Convert to UTF-8 转换为UTF-8编码 - - + + Compile & Run 编译运行 - + F11 F11 - - + + Rebuild All 全部重编译 - + F12 F12 - + Stop Execution 停止执行 - + F6 F6 - + F5 F5 - + Step Over 单步跳过 - + F7 F7 - + Step Into 单步进入 - - - + + + Problem Set 试题集 - - - + + + New Problem Set 新建试题集 - - + + Add Problem 添加试题 - - + + Remove Problem 删除试题 - - - + + + Save Problem Set 保存试题集 - - - + + + Load Problem Set 载入试题集 - + Memory 内存 - + Address Expression: Address: 地址表达式: - + Cancel 取消 - - + + TODO TODO - - + + Bookmark 书签 - - - + + + Problem 试题 - - + + Add Probem Case 添加试题案例 - - + + Remove Problem Case Remove Problem Set 删除试题集 - - + + Open Anwser Source File 打开答案源代码文件 - - - + + + Run All Cases Run Current Case 运行所有案例 - + Problem Cases Validation Options 测试案例验证选项 - + %v/%m %v/%m - + Output 输出 - + Input 输入 - + Expected 期望输出 - + Help 帮助 - + Refactor 重构 - + View 视图 @@ -4485,607 +4495,627 @@ Are you really want to continue? 工具窗口 - + Main 主工具栏 - + Compiler Set 编译器配置集 - + Explorer 管理器 - + Messages 消息 - + Ignore Spaces 忽略空格 - - + + New Source File 新建源代码文件 - + Tab Tab - + Shift+Tab Shift+Tab - + F8 F8 - + Step Out 单步跳出 - + Ctrl+F8 Ctrl+F8 - + Run To Cursor 执行到光标处 - + Ctrl+F5 Ctrl+F5 - + Continue 继续执行 - + F4 F4 - + Add Watch... 添加监视 - + View CPU Window... 打开CPU信息窗口... - + Exit 退出 - + Find... 查找... - + Ctrl+F Ctrl+F - + Find in Files... 在文件中查找... - + Ctrl+Shift+F Ctrl+Shift+F - + Replace... 替换 - + Ctrl+R Ctrl+R - + Find Next 查找下一个 - + F3 F3 - + Find Previous 查找前一个 - + Shift+F3 Shift+F3 - + Remove Watch 删除监视值 - + Remove All Watches Remove All 删除全部监视值 - + Modify Watch... 修改监视值 - + Reformat Code 对代码重新排版 - + Ctrl+Shift+A Ctrl+Shift+A - + Go back 前一次编辑位置 - + Ctrl+Alt+Left Ctrl+Alt+Left - + Forward 后一次编辑位置 - + Ctrl+Alt+Right Ctrl+Alt+Right - + Ctrl+W Ctrl+W - + Close All 全部关闭 - + Ctrl+Shift+W Ctrl+Shift+W - + Maximize Editor 最大化编辑器 - + Ctrl+F11 Ctrl+F11 - + Next 下一窗口 - + Ctrl+Tab Ctrl+Tab - + Previous 前一窗口 - + Ctrl+Shift+Tab Ctrl+Shift+Tab - + Toggle breakpoint 切换断点 - + Ctrl+F4 Ctrl+F4 - - + + Clear all breakpoints 删除所有断点 - + Breakpoint property... 设置断点条件... - + Goto Declaration 跳转到声明处 - + Ctrl+Shift+G Ctrl+Shift+G - + Goto Definition 跳转到定义处 - + Ctrl+G Ctrl+G - + Find references 查找符号的引用 - + Open containing folder 打开所在的文件夹 - + Ctrl+B Ctrl+B - + Open a terminal here 打开命令行窗口 - + File Properties... 文件属性... - + Close Project 关闭项目 - + Project options 项目属性 - + New Project... 新建项目... - - + + New Project File 新建项目文件 - + F1 F1 - + Move Selection Up 向上移动选中的行 - + Ctrl+Shift+Up Ctrl+Shift+Up - + Move Selection Down 向下移动选中的行 - + Ctrl+Shift+Down Ctrl+Shift+Down - + Convert to UTF-8 BOM 转换为UTF-8 BOM编码 - + Encode in UTF-8 BOM 使用UTF-8 BOM编码 - + Compiler Options... 编译器选项... - + Toggle Explorer Panel 切换管理器面板 - + Ctrl+F9 Ctrl+F9 - + Toggle Messages Panel 切换消息面板 - + Ctrl+F10 Ctrl+F10 - + Raylib Manual Raylib教程 - + Select Word 选中当前单词 - + Go to Line... 跳转到行... - + New Template... 新建模板... - + New Template from Project 从项目创建模板 + + + Goto block start + 跳转到代码段开始 + + + + Ctrl+Alt+Up + Ctrl+Alt+Up + + + + Goto block end + 跳转到代码段结束 + + + + Ctrl+Alt+Down + Ctrl+Alt+Down + Save As Template... 保存为模板... - + New File 新建文件 - + Add to project... 添加到项目... - + Remove from project 从项目删除 - + View Makefile 查看Makefile - + Clean 清理构建文件 - + Open Folder in Explorer 在浏览器中打开 - + Open In Terminal 在终端中打开 - + About 关于 - - + + Rename Symbol 重命名符号 - + Shift+F6 Shift+F6 - + Print... 打印... - + Ctrl+P Ctrl+P - - + + Export As RTF 导出为RTF - - + + Export As HTML 导出为HTML - + Move To Other View 移动到其他视图 - + Ctrl+M Ctrl+M - - + + C++ Reference C++参考手册 - + C Reference C参考手册 - + Show Tool Panels 显示全部工具面板 - + Create Git Repository Create Repository 创建Git仓库 - + Commit 提交(Commit) - + Revert 撤销(Revert) - + Reset 回滚(Reset) - + Add Files 添加文件 - + Restore 还原(Restore) - + Website 官方网站 - + Branch/Switch 分支切换(Switch) - + Merge 合并(Merge) - - + + Show Log Log 显示日志(Log) - + Remotes... 远程仓库... - + Fetch 取回(Fetch) - + Pull 拉取(Pull) - + Push 推送(Push) - + Hide Non Support Files 隐藏不支持的文件 - + Toggle Block Comment 切换块注释 - + Alt+Shift+A Alt+Shift+A - + Match Bracket 匹配当前括号 - + Ctrl+] Ctrl+] @@ -5094,50 +5124,50 @@ Are you really want to continue? 工具窗口栏 - + Status Bar 状态栏 - + Ctrl+Backspace Ctrl+Backspace - + Interrupt 中断 - - + + Delete To Word Begin 删除到单词开头 - + Ctrl+Shift+B Ctrl+Shift+B - + Delete to Word End 删除到单词结尾 - + Ctrl+Shift+E Ctrl+Shift+E - + New Class... Add Class... 新建类... - - + + New Header... New Header 新建头文件... @@ -5147,47 +5177,47 @@ Are you really want to continue? 插入行 - + Delete Line 删除当前行 - + Ctrl+D Ctrl+D - + Duplicate Line 复制当前行 - + Ctrl+E Ctrl+E - + Delete Word 删除当前单词 - + Ctrl+Shift+D Ctrl+Shift+D - + Delete to EOL 删除到行尾 - + Ctrl+Del Ctrl+Del - + Delete to BOL 删除到行首 @@ -5196,27 +5226,27 @@ Are you really want to continue? C/C++参考 - + EGE Manual EGE图形库手册 - + Add Bookmark 添加书签 - + Remove Bookmark 删除书签 - + Modify Bookmark Description 修改书签说明 - + Locate in Files View 在文件视图中定位 @@ -5225,12 +5255,12 @@ Are you really want to continue? 打开文件夹 - + Running Parameters... 运行参数... - + File Encoding 文件编码 @@ -5311,19 +5341,19 @@ Are you really want to continue? - + Source file is not compiled. 源文件尚未编译。 - + Compile now? 现在编译? - + Source file is more recent than executable. 源文件比可执行程序新。 @@ -5333,103 +5363,103 @@ Are you really want to continue? 重新编译? - - - - + + + + Wrong Compiler Settings 错误的编译器设置 - - - - + + + + Compiler is set not to generate executable. 编译器被设置为不生成可执行文件。 - - + + We need the executabe to run problem case. 我们需要可执行文件来运行试题案例。 - + 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'不存在。 - - + + Please correct this before start debugging 请在调试前改正设置。 - + Recompile? 重新编译? - - + + Save last open info error 保存上次打开信息失败 @@ -5438,70 +5468,70 @@ Are you really want to continue? 无法删除旧上次打开信息文件'%1' - + Can't save last open info file '%1' 无法保存上次打开信息文件'%1' - - + + Load last open info error 载入上次打开信息失败 - - + + Can't load last open info file '%1' 无法载入上次打开信息文件'%1' - + Open Source File 打开源代码文件 - - + + Batch Set Cases 批量设置案例 - + Show detail debug logs 显示详细调试器日志 - + Copy all 全部复制 - + Go to Line 跳转到行 - + Line - + Template Exists 模板已存在 - + Template %1 already exists. Do you want to overwrite? 模板%1已存在。是否覆盖? - - - - - - + + + + + + Clear 清除 @@ -5517,7 +5547,7 @@ Are you really want to continue? - + Problem Set %1 试题集%1 @@ -5538,68 +5568,68 @@ Are you really want to continue? 或者选择使用其他的网络端口。 - - + + 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: 描述: @@ -5608,194 +5638,194 @@ 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 重命名 - + Can't open last open information file '%1' for write! 无法写入配置文件'%1'。 - + Run Current Case 运行当前案例 - + Remove Folder 删除文件夹 - + Switch to normal view 切换为普通视图 - + Switch to custom view 切换为自定义视图 - + Sort By Type 按类型排序 - + Sort alphabetically 按名称排序 - + Show inherited members 显示继承的成员 - + Goto declaration 跳转到声明处 - + Goto definition 跳转到定义处 - + In current file 仅当前文件 - + In current project 整个项目 - - + + New Folder 新建文件夹 - + Rename 重命名 - - - - + + + + Delete 删除 - + Open in Editor 在编辑器中打开 - + Open in External Program 使用外部程序打开 - + Open in Terminal 在终端中打开 - + Open in Windows Explorer 在Windows浏览器中打开 - + Character sets 字符集 - + Convert to %1 转换为%1编码 - + %1 files autosaved 已自动保存%1个文件 - + Set answer to... 设置答案源代码... - + select other file... 选择其他文件... - + Select Answer Source File 选择答案源代码文件 @@ -5805,7 +5835,7 @@ Are you really want to continue? C/C++源代码文件 (*.c *.cpp *.cc *.cxx) - + New Folder %1 新建文件夹%1 @@ -5818,67 +5848,67 @@ Are you really want to continue? 无标题%1 - + Do you really want to delete %1? 你真的要删除%1吗? - + Do you really want to delete %1 files? 你真的要删除%1个文件吗? - + 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? 你真的想要那么做吗? @@ -5887,119 +5917,119 @@ Are you really want to continue? 批量设置案例 - + Choose input files 选择输入数据文件 - + Input data files (*.in) 输入数据文件 (*.in) - + untitled%1 无标题%1 - + Modify Watch 修改监视表达式 - + Watch Expression 监视表达式 - + 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 - + Folder %1 is not empty. 文件夹%1不是空的。 - + Do you really want to delete it? 你真的要删除它吗? - + Change working folder 改变工作文件夹 - + File '%1' is not in the current working folder. File '%1' is not in the current working folder 文件'%1'不在当前工作文件夹中。 - + Do you want to change working folder to '%1'? 是否将工作文件夹改设为'%1'? - + Can't Commit 无法提交 - + Git needs user info to commit. Git需要用信息进行提交。 - + Choose Input Data File 选择输入数据文件 - - + + All files (*.*) 所有文件 (*.*) - + Choose Expected Output Data File Choose Expected Input Data File 选择期望输出文件 @@ -6009,61 +6039,61 @@ Are you really want to continue? 第%1行 - - - + + + Choose Working Folder 选择工作文件夹 - - + + Header Exists 头文件已存在 - - + + Header file "%1" already exists! 头文件"%1"已存在! - + Source Exists 源文件已存在! - + Source file "%1" already exists! 源文件"%1"已存在! - + Can't commit! 无法提交! - + The following files are in conflicting: 下列文件处于冲突状态,请解决后重新添加和提交: - + Commit Message 提交信息 - + Commit Message: 提交信息: - + Commit Failed 提交失败 - + Commit message shouldn't be empty! 提交信息不能为空! @@ -6072,137 +6102,136 @@ Are you really want to continue? 小熊猫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 添加到项目 - + C/C++ Source Files (*.c *.cpp *.cc *.cxx) C/C++源代码文件 (*.c *.cpp *.cc *.cxx) - + This operation will remove all cases for the current problem. 本操作会删除此试题的所有案例。 - + Red Panda C++ project file (*.dev) 小熊猫C++项目文件(*.dev) - + 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 @@ -6213,15 +6242,15 @@ Are you really want to continue? - - - - - - - - - + + + + + + + + + Error 错误 @@ -6242,85 +6271,85 @@ Are you really want to continue? 清除历史 - - + + Version Control 版本控制 - + 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个文件) @@ -6420,7 +6449,7 @@ Are you really want to continue? 取消 - + Path 路径 @@ -6526,12 +6555,11 @@ Are you really want to continue? 取消 - untitled - 无标题 + 无标题 - + Choose directory 选择文件夹 @@ -6659,7 +6687,7 @@ Are you really want to continue? 找不到项目文件'%1'! - + untitled 无标题 @@ -6672,105 +6700,105 @@ Are you really want to continue? 无法保存文件'%1'. - + Error Load File 载入文件错误 - - + + Error 错误 - + Can't create folder %1 无法创建文件夹%1 - + Warning 警告 - - + + Can't save file %1 无法保存文件%1 - + File Exists 文件已存在 - + File '%1' is already in the project 文件'%1'已在项目中 - + Project Updated 项目已升级 - + Your project was succesfully updated to a newer file format! 已成功将项目升级到新的格式 - + If something has gone wrong, we kept a backup-file: '%1'... 旧项目文件备份在'%1'。 - + Headers 头文件 - + Sources 源文件 - + Others 其他文件 - + Settings need update 设置需要更新 - + The compiler settings format of Red Panda C++ has changed. The compiler settings format of Dev-C++ has changed. 小熊猫C++的编译器设置格式已发生改变。 - + Please update your settings at Project >> Project Options >> Compiler and save your project. 请在项目 >> 项目属性 >> 编译器设置中修改您的设置并保存您的项目 - + Compiler not found 未找到编译器 - + The compiler set you have selected for this project, no longer exists. 您为该项目设置的编译器不存在。 - + It will be substituted by the global compiler set. 它将会被全局编译器设置代替。 - + Developed using the Red Panda C++ IDE Developed using the Red Panda Dev-C++ IDE 使用小熊猫C++编辑器开发 @@ -7239,32 +7267,32 @@ Are you really want to continue? ProjectModel - + File exists 文件已存在 - + File '%1' already exists. Delete it now? 文件'%1'已存在。是否删除? - + Remove failed 删除失败 - + Failed to remove file '%1' 无法删除文件'%1' - + Rename failed 改名失败 - + Failed to rename file '%1' to '%2' 无法将文件'%1'改名为'%2' @@ -7870,7 +7898,7 @@ Are you really want to continue? - + untitled 无标题 @@ -8202,7 +8230,7 @@ Are you really want to continue? - + Can't open file '%1' for write. 无法写入文件'%1'. @@ -8654,14 +8682,14 @@ Are you really want to continue? 性能 - + Compiler Set 编译器配置集 - + Compiler @@ -8673,7 +8701,7 @@ Are you really want to continue? 自动链接 - + @@ -8749,15 +8777,15 @@ Are you really want to continue? 杂项 - - + + Program Runner 程序运行 - + Problem Set 试题集 @@ -9035,22 +9063,21 @@ Are you really want to continue? TodoModel - + Filename 文件名 - + Line - Column - + - + Content 内容 diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts index 21c9456c..8b510691 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts @@ -1076,6 +1076,10 @@ Completion suggestion window height: + + Editors share one code parser + + EditorColorSchemeWidget @@ -1600,6 +1604,10 @@ Auto clear parsed symbols when editor hidden + + Editors share one code parser + + EnvironmentProgramsWidget @@ -4541,6 +4549,22 @@ In current project + + Goto block start + + + + Ctrl+Alt+Up + + + + Goto block end + + + + Ctrl+Alt+Down + + NewClassDialog @@ -4689,10 +4713,6 @@ Cancel - - untitled - - Choose directory @@ -6384,10 +6404,6 @@ Line - - Column - - Content diff --git a/libs/qsynedit/qsynedit/KeyStrokes.cpp b/libs/qsynedit/qsynedit/KeyStrokes.cpp index a24f5b41..eb867dda 100644 --- a/libs/qsynedit/qsynedit/KeyStrokes.cpp +++ b/libs/qsynedit/qsynedit/KeyStrokes.cpp @@ -198,6 +198,11 @@ void EditKeyStrokes::resetDefaults() add(EditCommand::ecWordRight, Qt::Key_Right, Qt::ControlModifier); add(EditCommand::ecSelWordRight, Qt::Key_Right, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::ecBlockStart, Qt::Key_Up, Qt::MetaModifier|Qt::ControlModifier); + add(EditCommand::ecSelBlockStart, Qt::Key_Up, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier); + add(EditCommand::ecBlockEnd, Qt::Key_Down, Qt::MetaModifier|Qt::ControlModifier); + add(EditCommand::ecSelBlockEnd, Qt::Key_Down, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier); + // add(SynEditorCommand::ecExpandSelection, Qt::Key_Right, Qt::ShiftModifier|Qt::AltModifier); // add(SynEditorCommand::ecShrinkSelection, Qt::Key_Left, Qt::ShiftModifier | Qt::AltModifier); diff --git a/libs/qsynedit/qsynedit/KeyStrokes.h b/libs/qsynedit/qsynedit/KeyStrokes.h index bbe1a876..e92cc001 100644 --- a/libs/qsynedit/qsynedit/KeyStrokes.h +++ b/libs/qsynedit/qsynedit/KeyStrokes.h @@ -62,6 +62,8 @@ enum class EditCommand { ecEditorStart = 15, // Move cursor to absolute beginning ecEditorEnd = 16, // Move cursor to absolute end ecGotoXY = 17, // Move cursor to specific coordinates, Data = PPoint + ecBlockStart = 18, // Move cursor to begin of block + ecBlockEnd = 19, // Move cursor to end of block //****************************************************************************** // Maybe the command processor should just take a boolean that signifies if @@ -89,6 +91,8 @@ enum class EditCommand { ecSelEditorStart = ecEditorStart + ecSelection, ecSelEditorEnd = ecEditorEnd + ecSelection, ecSelGotoXY = ecGotoXY + ecSelection, // Data = PPoint + ecSelBlockStart = ecBlockStart + ecSelection, // Move cursor to begin of scope + ecSelBlockEnd = ecBlockEnd + ecSelection, // Move cursor to end of scope ecCopy = 201, // Copy selection to clipboard diff --git a/libs/qsynedit/qsynedit/SynEdit.cpp b/libs/qsynedit/qsynedit/SynEdit.cpp index 99545860..96d5a727 100644 --- a/libs/qsynedit/qsynedit/SynEdit.cpp +++ b/libs/qsynedit/qsynedit/SynEdit.cpp @@ -5054,6 +5054,64 @@ void SynEdit::moveCaretToLineEnd(bool isSelection) moveCaretAndSelection(caretXY(), BufferCoord{vNewX, mCaretY}, isSelection); } +void SynEdit::doGotoBlockStart(bool isSelection) +{ + if (mCaretY<0 || mCaretY>document()->count()) + return; + HighlighterState state = document()->ranges(mCaretY-1); + //todo: handle block other than {} + if (document()->braceLevels(mCaretY-1)==0) { + doGotoEditorStart(isSelection); + } else if (document()->leftBraces(mCaretY-1)==0){ + int line=mCaretY-1; + while (line>=1) { + if (document()->leftBraces(line-1)>document()->rightBraces(line-1)) { + moveCaretVert(line+1-mCaretY, isSelection); + moveCaretToLineStart(isSelection); + setTopLine(line-1); + return; + } + line--; + } + } +} + +void SynEdit::doGotoBlockEnd(bool isSelection) +{ + if (mCaretY<0 || mCaretY>document()->count()) + return; + HighlighterState state = document()->ranges(mCaretY-1); + //todo: handle block other than {} + if (document()->braceLevels(mCaretY-1)==0) { + doGotoEditorEnd(isSelection); + } else if (document()->rightBraces(mCaretY-1)==0){ + int line=mCaretY+1; + while (line<=document()->count()) { + if (document()->rightBraces(line-1)>document()->leftBraces(line-1)) { + moveCaretVert(line-1-mCaretY, isSelection); + moveCaretToLineStart(isSelection); + setTopLine(line-mLinesInWindow+1); + return; + } + line++; + } + } +} + +void SynEdit::doGotoEditorStart(bool isSelection) +{ + moveCaretVert(1-mCaretY, isSelection); + moveCaretToLineStart(isSelection); +} + +void SynEdit::doGotoEditorEnd(bool isSelection) +{ + if (!mDocument->empty()) { + moveCaretVert(mDocument->count()-mCaretY, isSelection); + moveCaretToLineEnd(isSelection); + } +} + void SynEdit::setSelectedTextEmpty() { BufferCoord startPos=blockBegin(); @@ -5722,7 +5780,7 @@ void SynEdit::onCommandProcessed(EditCommand , QChar , void *) } -void SynEdit::executeCommand(EditCommand Command, QChar AChar, void *pData) +void SynEdit::executeCommand(EditCommand command, QChar ch, void *pData) { hideCaret(); incPaintLock(); @@ -5731,40 +5789,40 @@ void SynEdit::executeCommand(EditCommand Command, QChar AChar, void *pData) decPaintLock(); showCaret(); }); - switch(Command) { + switch(command) { //horizontal caret movement or selection case EditCommand::ecLeft: case EditCommand::ecSelLeft: - moveCaretHorz(-1, Command == EditCommand::ecSelLeft); + moveCaretHorz(-1, command == EditCommand::ecSelLeft); break; case EditCommand::ecRight: case EditCommand::ecSelRight: - moveCaretHorz(1, Command == EditCommand::ecSelRight); + moveCaretHorz(1, command == EditCommand::ecSelRight); break; case EditCommand::ecPageLeft: case EditCommand::ecSelPageLeft: - moveCaretHorz(-mCharsInWindow, Command == EditCommand::ecSelPageLeft); + moveCaretHorz(-mCharsInWindow, command == EditCommand::ecSelPageLeft); break; case EditCommand::ecPageRight: case EditCommand::ecSelPageRight: - moveCaretHorz(mCharsInWindow, Command == EditCommand::ecSelPageRight); + moveCaretHorz(mCharsInWindow, command == EditCommand::ecSelPageRight); break; case EditCommand::ecLineStart: case EditCommand::ecSelLineStart: - moveCaretToLineStart(Command == EditCommand::ecSelLineStart); + moveCaretToLineStart(command == EditCommand::ecSelLineStart); break; case EditCommand::ecLineEnd: case EditCommand::ecSelLineEnd: - moveCaretToLineEnd(Command == EditCommand::ecSelLineEnd); + moveCaretToLineEnd(command == EditCommand::ecSelLineEnd); break; // vertical caret movement or selection case EditCommand::ecUp: case EditCommand::ecSelUp: - moveCaretVert(-1, Command == EditCommand::ecSelUp); + moveCaretVert(-1, command == EditCommand::ecSelUp); break; case EditCommand::ecDown: case EditCommand::ecSelDown: - moveCaretVert(1, Command == EditCommand::ecSelDown); + moveCaretVert(1, command == EditCommand::ecSelDown); break; case EditCommand::ecPageUp: case EditCommand::ecSelPageUp: @@ -5779,51 +5837,55 @@ void SynEdit::executeCommand(EditCommand Command, QChar AChar, void *pData) } if (counter<0) break; - if (Command == EditCommand::ecPageUp || Command == EditCommand::ecSelPageUp) { + if (command == EditCommand::ecPageUp || command == EditCommand::ecSelPageUp) { counter = -counter; } - moveCaretVert(counter, Command == EditCommand::ecSelPageUp || Command == EditCommand::ecSelPageDown); + moveCaretVert(counter, command == EditCommand::ecSelPageUp || command == EditCommand::ecSelPageDown); break; } case EditCommand::ecPageTop: case EditCommand::ecSelPageTop: - moveCaretVert(mTopLine-mCaretY, Command == EditCommand::ecSelPageTop); + moveCaretVert(mTopLine-mCaretY, command == EditCommand::ecSelPageTop); break; case EditCommand::ecPageBottom: case EditCommand::ecSelPageBottom: - moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, Command == EditCommand::ecSelPageBottom); + moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, command == EditCommand::ecSelPageBottom); break; case EditCommand::ecEditorStart: case EditCommand::ecSelEditorStart: - moveCaretVert(1-mCaretY, Command == EditCommand::ecSelEditorStart); - moveCaretToLineStart(Command == EditCommand::ecSelEditorStart); + doGotoEditorStart(command == EditCommand::ecSelEditorStart); break; case EditCommand::ecEditorEnd: case EditCommand::ecSelEditorEnd: - if (!mDocument->empty()) { - moveCaretVert(mDocument->count()-mCaretY, Command == EditCommand::ecSelEditorEnd); - moveCaretToLineEnd(Command == EditCommand::ecSelEditorEnd); - } + doGotoEditorEnd(command == EditCommand::ecSelEditorEnd); + break; + case EditCommand::ecBlockStart: + case EditCommand::ecSelBlockStart: + doGotoBlockStart(command == EditCommand::ecSelBlockStart); + break; + case EditCommand::ecBlockEnd: + case EditCommand::ecSelBlockEnd: + doGotoBlockEnd(command == EditCommand::ecSelBlockEnd); break; // goto special line / column position case EditCommand::ecGotoXY: case EditCommand::ecSelGotoXY: if (pData) - moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), Command == EditCommand::ecSelGotoXY); + moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), command == EditCommand::ecSelGotoXY); break; // word selection case EditCommand::ecWordLeft: case EditCommand::ecSelWordLeft: { BufferCoord CaretNew = prevWordPos(); - moveCaretAndSelection(caretXY(), CaretNew, Command == EditCommand::ecSelWordLeft); + moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::ecSelWordLeft); break; } case EditCommand::ecWordRight: case EditCommand::ecSelWordRight: { BufferCoord CaretNew = nextWordPos(); - moveCaretAndSelection(caretXY(), CaretNew, Command == EditCommand::ecSelWordRight); + moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::ecSelWordRight); break; } case EditCommand::ecSelWord: @@ -5895,7 +5957,7 @@ void SynEdit::executeCommand(EditCommand Command, QChar AChar, void *pData) doShiftTabKey(); break; case EditCommand::ecChar: - doAddChar(AChar); + doAddChar(ch); break; case EditCommand::ecInsertMode: if (!mReadOnly) diff --git a/libs/qsynedit/qsynedit/SynEdit.h b/libs/qsynedit/qsynedit/SynEdit.h index a9d5cab3..ecbcde53 100644 --- a/libs/qsynedit/qsynedit/SynEdit.h +++ b/libs/qsynedit/qsynedit/SynEdit.h @@ -466,9 +466,9 @@ protected: virtual void onPreparePaintHighlightToken(int line, int aChar, const QString& token, PHighlighterAttribute attr, FontStyles& style, QColor& foreground, QColor& background); - virtual void onProcessCommand(EditCommand Command, QChar AChar, void * pData); - virtual void onCommandProcessed(EditCommand Command, QChar AChar, void * pData); - virtual void executeCommand(EditCommand Command, QChar AChar, void * pData); + virtual void onProcessCommand(EditCommand command, QChar car, void * pData); + virtual void onCommandProcessed(EditCommand command, QChar car, void * pData); + virtual void executeCommand(EditCommand command, QChar ch, void * pData); virtual void onEndFirstPaintLock(); virtual void onBeginFirstPaintLock(); @@ -540,6 +540,10 @@ private: bool isSelection); void moveCaretToLineStart(bool isSelection); void moveCaretToLineEnd(bool isSelection); + void doGotoBlockStart(bool isSelection); + void doGotoBlockEnd(bool isSelection); + void doGotoEditorStart(bool isSelection); + void doGotoEditorEnd(bool isSelection); void setSelectedTextEmpty(); void setSelTextPrimitive(const QStringList& text); void setSelTextPrimitiveEx(SelectionMode PasteMode,