diff --git a/NEWS.md b/NEWS.md index 8f1a31ce..f8a7364d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,8 @@ Red Panda C++ Version 1.0.1 - fix: corresponding '>' not correctly removed when deleting '<' in #include line - enhancement: shortcut for goto definition/declaration - change: ctrl+click symbol will goto definition, instead of got declaration + - fix: when size of undo items is greater than the limit, old items should be poped in group + - enhancement: max undo size in option dialog's editor->misc tab Red Panda C++ Version 1.0.0 - fix: calculation for code snippets's tab stop positions is not correct diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts index 00881bbe..a5d456b2 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -1257,7 +1257,7 @@ Are you really want to continue? Editor - + untitled 无标题 @@ -1270,12 +1270,12 @@ Are you really want to continue? 失败 - - - + + - + + Error 错误 @@ -1284,39 +1284,39 @@ Are you really want to continue? 无法写入文件"%1" - + Save As 另存为 - + 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+单击以获取更多信息 @@ -1325,27 +1325,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 只读 @@ -1866,32 +1866,37 @@ Are you really want to continue? 在打开文件时自动探测文件编码 - + + Max Undo Steps + 最大可撤销编辑操作数量 + + + Default file encoding 缺省文件编码 - + Default file type 缺省文件类型 - + C++ files C++语言文件 - + C files C语言文件 - + ANSI ANSI - + UTF-8 UTF-8 @@ -3787,12 +3792,12 @@ Are you really want to continue? - + - + Issues 编译器 @@ -3824,25 +3829,25 @@ Are you really want to continue? - + Project 项目 - + Watch 监视 - + Structure 结构 - + Files 文件 @@ -3855,7 +3860,7 @@ Are you really want to continue? - + Debug 调试 @@ -3888,7 +3893,7 @@ Are you really want to continue? - + Search 查找 @@ -4007,7 +4012,7 @@ Are you really want to continue? - + Tools Output 工具输出 @@ -4207,7 +4212,7 @@ Are you really want to continue? - + Problem Set 试题集 @@ -4215,7 +4220,7 @@ Are you really want to continue? - + New Problem Set 新建试题集 @@ -4234,14 +4239,14 @@ Are you really want to continue? - + Save Problem Set 保存试题集 - + Load Problem Set 载入试题集 @@ -4263,20 +4268,20 @@ Are you really want to continue? - + TODO TODO - + Bookmark 书签 - + Problem 试题 @@ -4595,53 +4600,63 @@ Are you really want to continue? 跳转到声明处 - + + 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 新建项目文件 @@ -4651,194 +4666,194 @@ Are you really want to continue? 新建文件 - + 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+] @@ -4847,50 +4862,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 新建头文件... @@ -4900,47 +4915,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 删除到行首 @@ -4949,27 +4964,27 @@ Are you really want to continue? C/C++参考 - + EGE Manual EGE图形库手册 - + Add Bookmark 添加书签 - + Remove Bookmark 删除书签 - + Modify Bookmark Description 修改书签说明 - + Locate in Files View 在文件视图中定位 @@ -4978,7 +4993,7 @@ Are you really want to continue? 打开文件夹 - + Running Parameters... 运行参数... @@ -5214,7 +5229,7 @@ Are you really want to continue? - + Problem Set %1 试题集%1 @@ -5288,15 +5303,15 @@ Are you really want to continue? - - + + Bookmark Description 书签描述 - - + + Description: 描述: @@ -5416,7 +5431,7 @@ Are you really want to continue? - + Delete 删除 @@ -5513,7 +5528,7 @@ Are you really want to continue? - + Do you want to save it? 需要保存吗? @@ -5537,7 +5552,7 @@ Are you really want to continue? - + Save Error 保存失败 @@ -5562,132 +5577,132 @@ Are you really want to continue? 您真的要清除该文件的所有断点吗? - + 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 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! 提交信息不能为空! @@ -5696,125 +5711,125 @@ 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 添加到项目 - + 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 @@ -6992,200 +7007,200 @@ Are you really want to continue? 无法载入自动链接设置 - - - - + + + + The following %1 directories don't exist: 下列%1文件夹不存在: - - + + binary 二进制 - + No %1 directories have been specified. 未指定%1文件夹 - + C include C包含 - - + + C++ include C++包含 - - - - + + + + Cannot find the %1 "%2" 无法找到%1程序"%2" - + C Compiler C编译器 - + C++ Compiler C++编译器 - + Maker 构建程序(Make) - + Debugger 调试器 - + C options C语言选项 - + Support all ANSI standard C programs (-ansi) 支持所有ANSI标准C程序(-ansi) - + Do not recognize asm,inline or typeof as a keyword (-fno-asm) 不支持将asm、inline和typeof作为关键字(-fno-asm) - + Imitate traditional C preprocessors (-traditional-cpp) 模仿传统C预处理器行为(-traditional-cpp) - + Code Generation 代码生成 - + Optimize for the following machine (-march) 生成特定机器的专用指令(-march) - + Optimize less, while maintaining full compatibility (-tune) 完整兼容特定机器,较少优化(-tune) - + Enable use of specific instructions (-mx) 启用特定指令集(-mx) - + Optimization level (-Ox) 优化级别(-Ox) - + Compile with the following pointer size (-mx) 使用下列指针大小编译(-mx) - + Language standard (-std) 语言标准(-std) - + Profile 性能分析 - + Generate debugging information (-g3) 生成调试信息(-g3) - + Would you like Red Panda C++ to search for compilers in PATH? 您同意小熊猫C++在PATH路径中寻找gcc编译器吗? - + Generate profiling info for analysis (-pg) 生成性能分析信息(-pg) - + Warnings 代码警告 - + Inhibit all warning messages (-w) 忽略所有警告信息(-w) - + Show most warnings (-Wall) 启用常见问题警告(-Wall) - + Show some more warnings (-Wextra) 启用更多问题警告(-Wextra) - + Check ISO C/C++/C++0x conformance (-pedantic) 检查ISO C/C++/C++0x语法一致性(-pedantic) - + Only check the code for syntax errors (-fsyntax-only) 只进行语法检查(不编译)(-fsyntax-only) - + Make all warnings into errors (-Werror) 将警告作为错误处理(-Werror) - + Abort compilation on first error (-Wfatal-errors) 遇到第一个错误后立即中止编译(-Wfatal-errors) - + Linker 链接器 - + Link an Objective C program (-lobjc) 链接Objective-C程序 (-lobjc) - + Do not use standard system libraries (-nostdlib) 不使用标准库和系统启动文件(-nostdlib) - + Do not create a console window (-mwindows) 不产生控制台窗口(-mwindows) - + Strip executable (-s) 剥除附加信息(-s) @@ -7194,54 +7209,54 @@ Are you really want to continue? 链接Ojbective C程序(-lobjc) - + Output 输出 - + Put comments in generated assembly code (-fverbose-asm) 在生成的汇编代码中加入注释(-fverbose-asm) - + Use pipes instead of temporary files during compilation (-pipe) 编译时使用管道而不是临时文件(-pipe) - + Do not assemble, compile and generate the assemble code (-S) 只生成汇编代码(-S) - - + + Confirm 确认 - + The following problems were found during validation of compiler set "%1": 在验证编译器设置"%1"时遇到了下列问题: - + Would you like Red Panda C++ to remove them for you and add the default paths to the valid paths? 是否让小熊猫C++删除这些配置,并尝试重新建立配置? - + Leaving those directories will lead to problems during compilation.<br /><br />Unless you know exactly what you're doing, it is recommended that you click Yes. 如果仍然保留这些设置,可能会导致编译错误。<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 @@ -7279,7 +7294,7 @@ Are you really want to continue? - + untitled 无标题 @@ -8081,7 +8096,7 @@ Are you really want to continue? 自动链接 - + @@ -8157,15 +8172,15 @@ Are you really want to continue? 杂项 - - + + Program Runner 程序运行 - + Problem Set 试题集 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 78838df9..ecf4f8c8 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -4397,6 +4397,8 @@ void Editor::applySettings() setRightEdge(0); } + this->setUndoLimit(pSettings->editor().undoLimit()); + setMouseWheelScrollSpeed(pSettings->editor().mouseWheelScrollSpeed()); setMouseSelectionScrollSpeed(pSettings->editor().mouseSelectionScrollSpeed()); invalidate(); diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 811717b7..044f21a5 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -6320,6 +6320,13 @@ int SynEdit::charWidth() const return mCharWidth; } +void SynEdit::setUndoLimit(int size) +{ + mUndoList->setMaxUndoActions(size); + + mRedoList->setMaxUndoActions(size); +} + int SynEdit::charsInWindow() const { return mCharsInWindow; diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index afe464e0..e7cfb2ff 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -323,6 +323,8 @@ public: int charWidth() const; + void setUndoLimit(int size); + int gutterWidth() const; void setGutterWidth(int value); diff --git a/RedPandaIDE/qsynedit/TextBuffer.cpp b/RedPandaIDE/qsynedit/TextBuffer.cpp index 2d3713dd..da406c87 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.cpp +++ b/RedPandaIDE/qsynedit/TextBuffer.cpp @@ -930,7 +930,7 @@ void SynEditUndoList::PushItem(PSynEditUndoItem Item) if (!Item) return; mItems.append(Item); - EnsureMaxEntries(); + ensureMaxEntries(); if (Item->changeReason()!= SynChangeReason::crGroupBreak) emit addedUndo(); } @@ -958,7 +958,10 @@ int SynEditUndoList::maxUndoActions() const void SynEditUndoList::setMaxUndoActions(int maxUndoActions) { - mMaxUndoActions = maxUndoActions; + if (maxUndoActions!=mMaxUndoActions) { + mMaxUndoActions = maxUndoActions; + ensureMaxEntries(); + } } bool SynEditUndoList::initialState() @@ -1032,12 +1035,16 @@ bool SynEditUndoList::fullUndoImposible() const return mFullUndoImposible; } -void SynEditUndoList::EnsureMaxEntries() +void SynEditUndoList::ensureMaxEntries() { + qDebug()< mMaxUndoActions){ mFullUndoImposible = true; while (mItems.count() > mMaxUndoActions) { - mItems.removeFirst(); + //remove all undo item in block + int changeNumber = mItems.front()->changeNumber(); + while (mItems.count()>0 && mItems.front()->changeNumber() == changeNumber) + mItems.removeFirst(); } } } diff --git a/RedPandaIDE/qsynedit/TextBuffer.h b/RedPandaIDE/qsynedit/TextBuffer.h index 30a77569..039ff177 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.h +++ b/RedPandaIDE/qsynedit/TextBuffer.h @@ -234,7 +234,7 @@ public: signals: void addedUndo(); protected: - void EnsureMaxEntries(); + void ensureMaxEntries(); protected: int mBlockChangeNumber; int mBlockCount; diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 511d4fe8..2710f17d 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -624,6 +624,16 @@ void Settings::Editor::setAutoDetectFileEncoding(bool newAutoDetectFileEncoding) mAutoDetectFileEncoding = newAutoDetectFileEncoding; } +int Settings::Editor::undoLimit() const +{ + return mUndoLimit; +} + +void Settings::Editor::setUndoLimit(int newUndoLimit) +{ + mUndoLimit = newUndoLimit; +} + bool Settings::Editor::highlightCurrentWord() const { return mHighlightCurrentWord; @@ -1202,6 +1212,7 @@ void Settings::Editor::doSave() saveValue("auto_load_last_files",mAutoLoadLastFiles); saveValue("default_file_cpp",mDefaultFileCpp); saveValue("auto_detect_file_encoding",mAutoDetectFileEncoding); + saveValue("undo_limit",mUndoLimit); //tooltips saveValue("enable_tooltips",mEnableTooltips); @@ -1339,6 +1350,8 @@ void Settings::Editor::doLoad() else mDefaultEncoding = value("default_encoding", ENCODING_SYSTEM_DEFAULT).toByteArray(); mAutoDetectFileEncoding = boolValue("auto_detect_file_encoding",true); + mUndoLimit = intValue("undo_limit",1000); + //tooltips mEnableTooltips = boolValue("enable_tooltips",true); diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 8153a720..df7b8e76 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -375,6 +375,9 @@ public: bool autoDetectFileEncoding() const; void setAutoDetectFileEncoding(bool newAutoDetectFileEncoding); + int undoLimit() const; + void setUndoLimit(int newUndoLimit); + private: //General // indents @@ -481,6 +484,8 @@ public: bool mReadOnlySytemHeader; bool mAutoLoadLastFiles; bool mDefaultFileCpp; + int mUndoLimit; + //hints tooltip bool mEnableTooltips; diff --git a/RedPandaIDE/settingsdialog/editormiscwidget.cpp b/RedPandaIDE/settingsdialog/editormiscwidget.cpp index b9d3924d..58fc28d1 100644 --- a/RedPandaIDE/settingsdialog/editormiscwidget.cpp +++ b/RedPandaIDE/settingsdialog/editormiscwidget.cpp @@ -18,6 +18,7 @@ #include "ui_editormiscwidget.h" #include "../settings.h" #include "../platform.h" +#include "../mainwindow.h" EditorMiscWidget::EditorMiscWidget(const QString& name, const QString& group, QWidget *parent) : @@ -62,6 +63,7 @@ void EditorMiscWidget::doLoad() } ui->cbEncodingDetail->setCurrentText(defaultEncoding); } + ui->spinMaxUndo->setValue(pSettings->editor().undoLimit()); } void EditorMiscWidget::doSave() @@ -76,7 +78,9 @@ void EditorMiscWidget::doSave() } else { pSettings->editor().setDefaultEncoding(ui->cbEncoding->currentData().toByteArray()); } + pSettings->editor().setUndoLimit(ui->spinMaxUndo->value()); pSettings->editor().save(); + pMainWindow->updateEditorSettings(); } void EditorMiscWidget::init() diff --git a/RedPandaIDE/settingsdialog/editormiscwidget.ui b/RedPandaIDE/settingsdialog/editormiscwidget.ui index b36420f2..76b6a062 100644 --- a/RedPandaIDE/settingsdialog/editormiscwidget.ui +++ b/RedPandaIDE/settingsdialog/editormiscwidget.ui @@ -35,6 +35,57 @@ + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Max Undo Steps + + + + + + + 100 + + + 1000000000 + + + 50 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + +