diff --git a/NEWS.md b/NEWS.md index 7ed65eda..57cf32f6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,9 @@ Version 0.7.0 - fix: don't highlight '#' with spaces preceeding it as error - fix: correctly handle integer with 'L' suffix in #if directives ( so can be correctly parsed ) - enhancement: bookmark view + - enhancement: autosave/load bookmarks + - enhancement: autosave/load breakpoints + - enhancement: autosave/load watches Version 0.6.8 - enhancement: add link to cppreference in the help menu diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index 0119b85b..2c684e08 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 11ab5320..b6f68db0 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -95,17 +95,17 @@ BacktraceModel - + Function 函数 - + Filename 文件名 - + Line @@ -113,37 +113,37 @@ BookmarkModel - + Save file '%1' failed. 保存文件'%1'失败。 - + Can't open file '%1' for write. 无法写入文件'%1'. - + Error in json file '%1':%2 : %3 JSON文件'%1':%2中存在错误:%3 - + Can't open file '%1' for read. 无法读取文件'%1'. - + Description 描述 - + Line - + Filename 文件名 @@ -151,20 +151,40 @@ BreakpointModel - + Filename 文件名 - + Line - + Condition 条件 + + + Save file '%1' failed. + 保存文件'%1'失败。 + + + + Can't open file '%1' for write. + 无法写入文件'%1'. + + + + Error in json file '%1':%2 : %3 + JSON文件'%1':%2中存在错误:%3 + + + + Can't open file '%1' for read. + 无法读取文件'%1'. + CPUDialog @@ -874,32 +894,47 @@ Are you really want to continue? Show full gdb annotations 在调试主控台中显示gdb输出注解 + + + Autosave + 自动保存 + + + + Autosave breakpoints + 自动保存断点 + + + + Autosave watches + 自动保存监视 + Disassembly Coding Style 反汇编代码样式 - + CPU Window CPU信息窗口 - + Disassembly Coding Style: 反汇编代码样式 - + Intel Intel - + AT&&T AT&&T - + Show disassembly code in blend mode 以混合模式显示反汇编代码 @@ -907,68 +942,68 @@ Are you really want to continue? Debugger - + No compiler set 无编译器设置 - + No compiler set is configured. 没有配置编译器设置。 - + Can't start debugging. 无法启动调试器 - + Debugger path error 调试路径错误 - + Debugger's path "%1" contains non-ascii characters. 调试路径"%1"中包含非ASCII字符(如,中文字符) - + This prevents it from executing. 这会导致调试器无法启动。 - + Debugger not exists 找不到调试器 - + Can''t find debugger in : "%1" 找不到调试器程序"%1" - - + + Execute to evaluate 执行以求值 - + Not found in current context 不在当前语境中 - + Compile 编译 - + Source file is more recent than executable. 源文件比程序文件新。 - + Recompile? 重新编译? @@ -989,76 +1024,76 @@ Are you really want to continue? 失败 - - - - - - - + + + + + + + Error 错误 - + File %1 is not writable! 无法写入文件"%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+单击以获取更多信息 - - + + Symbol '%1' not found! 未找到符号'%1'! - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -2767,7 +2802,7 @@ Are you really want to continue? - + Issues 编译器 @@ -2787,8 +2822,8 @@ Are you really want to continue? 工具 - - + + Run 运行 @@ -2799,7 +2834,7 @@ Are you really want to continue? - + Project 项目 @@ -2823,9 +2858,9 @@ Are you really want to continue? - - - + + + Debug 调试 @@ -2881,7 +2916,7 @@ Are you really want to continue? 替换 - + Close 关闭 @@ -2892,12 +2927,12 @@ Are you really want to continue? - + Code 代码 - + Window 窗口 @@ -2910,249 +2945,249 @@ Are you really want to continue? 工具栏2 - + New 新建 - + 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 编译 - + 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 单步进入 @@ -3183,448 +3218,448 @@ Are you really want to continue? 书签 - + Help 帮助 - + Refactor 重构 - + Main 主工具栏 - + Compiler Set 编译器配置集 - - + + 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 清除全部监视 - + 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 跳转到声明处 - + Goto Definition 跳转到定义处 - + Find references 查找符号的引用 - + Open containing folder 打开所在的文件夹 - + Ctrl+B Ctrl+B - + Open a terminal here 打开命令行窗口 - + File Properties... 文件属性... - + Close Project 关闭项目 - + Project options 项目属性 - + New Project... 新建项目... - + 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/C++ Reference C/C++参考 - + EGE Manual EGE图形库手册 - + Add Bookmark 添加书签 - + Remove Bookmark 删除书签 - + Modify Bookmark Description 修改书签说明 - + File Encoding 文件编码 - + Recent Files 文件历史 - - - - - - + + + + + + Debugging 正在调试 - - - - - - + + + + + + Running 正在运行 - - - - - - + + + + + + Compiling 正在编译 @@ -3633,510 +3668,510 @@ 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' - + Copy all 全部复制 - - + + Clear 清除 - + Export 导出 - + Insert Snippet 插入代码段 - + Remove 删除 - + Modify Description 修改描述 - - - + + + Bookmark Description 书签描述 - - - + + + Description: 描述: - + Show debug logs in the debug console 在调试主控台中显示调试器输出 - + Remove this search 清除这次搜索 - + Clear all searches 删除所有搜索 - + Breakpoint condition... 断点条件... - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Remove all breakpoints 清除所有断点 - + Rename File 重命名文件 - - + + Add Folder 添加文件夹 - + New folder 新文件夹 - + Folder name: 文件夹: - + Rename Folder 重命名 - + Remove Folder 删除文件夹 - + Sort By Type 按类型排序 - + Sort alphabetically 按名称排序 - + Show inherited members 显示继承的成员 - + Goto declaration 跳转到声明处 - + Goto definition 跳转到定义处 - + Character sets 字符集 - + %1 files autosaved 已自动保存%1个文件 - + Save project 保存项目 - + The project '%1' has modifications. 项目'%1'有改动。 - + Do you want to save it? 需要保存吗? - + 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 无法使用模板创建项目 - + 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) - - - - - - - - - + + + + + + + + + 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个文件) @@ -5542,17 +5577,17 @@ Are you really want to continue? RegisterModel - + Register 寄存器 - + Value(Hex) 值(HEX) - + Value(Dec) 值(DEC) @@ -6380,12 +6415,37 @@ Are you really want to continue? WatchModel - + + Save file '%1' failed. + 保存文件'%1'失败。 + + + + Can't open file '%1' for write. + 无法写入文件'%1'. + + + + Error in json file '%1':%2 : %3 + JSON文件'%1':%2中存在错误:%3 + + + + Execute to evaluate + 执行以求值 + + + + Can't open file '%1' for read. + 无法读取文件'%1'. + + + Expression 表达式 - + Value diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index ee803d5a..744aa542 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -12,6 +12,9 @@ #include #include #include +#include +#include +#include Debugger::Debugger(QObject *parent) : QObject(parent) { @@ -149,6 +152,7 @@ void Debugger::addBreakpoint(int line, const QString &filename) bp->line = line; bp->filename = filename; bp->condition = ""; + bp->enabled = true; mBreakpointModel->addBreakpoint(bp); if (mExecuting) { sendBreakpointCommand(bp); @@ -1810,6 +1814,65 @@ PBreakpoint BreakpointModel::breakpoint(int index) const return mList[index]; } +void BreakpointModel::save(const QString &filename) +{ + QFile file(filename); + if (file.open(QFile::WriteOnly | QFile::Truncate)) { + QJsonArray array; + foreach (const PBreakpoint& breakpoint, mList) { + QJsonObject obj; + obj["filename"]=breakpoint->filename; + obj["line"]=breakpoint->line; + obj["condition"]=breakpoint->condition; + obj["enabled"]=breakpoint->enabled; + array.append(obj); + } + QJsonDocument doc; + doc.setArray(array); + if (file.write(doc.toJson())<0) { + throw FileError(tr("Save file '%1' failed.") + .arg(filename)); + } + } else { + throw FileError(tr("Can't open file '%1' for write.") + .arg(filename)); + } +} + +void BreakpointModel::load(const QString &filename) +{ + clear(); + QFile file(filename); + if (!file.exists()) + return; + if (file.open(QFile::ReadOnly)) { + QByteArray content = file.readAll(); + QJsonParseError error; + QJsonDocument doc(QJsonDocument::fromJson(content,&error)); + if (error.error != QJsonParseError::NoError) { + throw FileError(tr("Error in json file '%1':%2 : %3") + .arg(filename) + .arg(error.offset) + .arg(error.errorString())); + } + QJsonArray array = doc.array(); + for (int i=0;i(); + breakpoint->filename = obj["filename"].toString(); + breakpoint->line = obj["line"].toInt(); + breakpoint->condition = obj["condition"].toString(); + breakpoint->enabled = obj["enabled"].toBool(); + + addBreakpoint(breakpoint); + } + } else { + throw FileError(tr("Can't open file '%1' for read.") + .arg(filename)); + } +} + void BreakpointModel::onFileDeleteLines(const QString &filename, int startLine, int count) { for (int i = mList.count()-1;i>=0;i--){ @@ -2135,6 +2198,63 @@ void WatchModel::notifyUpdated(PWatchVar var) emit dataChanged(createIndex(row,0,var.get()),createIndex(row,0,var.get())); } +void WatchModel::save(const QString &filename) +{ + QFile file(filename); + if (file.open(QFile::WriteOnly | QFile::Truncate)) { + QJsonArray array; + foreach (const PWatchVar& watchVar, mWatchVars) { + QJsonObject obj; + obj["name"]=watchVar->name; + array.append(obj); + } + QJsonDocument doc; + doc.setArray(array); + if (file.write(doc.toJson())<0) { + throw FileError(tr("Save file '%1' failed.") + .arg(filename)); + } + } else { + throw FileError(tr("Can't open file '%1' for write.") + .arg(filename)); + } +} + +void WatchModel::load(const QString &filename) +{ + clear(); + QFile file(filename); + if (!file.exists()) + return; + if (file.open(QFile::ReadOnly)) { + QByteArray content = file.readAll(); + QJsonParseError error; + QJsonDocument doc(QJsonDocument::fromJson(content,&error)); + if (error.error != QJsonParseError::NoError) { + throw FileError(tr("Error in json file '%1':%2 : %3") + .arg(filename) + .arg(error.offset) + .arg(error.errorString())); + } + QJsonArray array = doc.array(); + for (int i=0;i(); + var->parent= nullptr; + var->name = obj["name"].toString(); + var->value = tr("Execute to evaluate"); + var->gdbIndex = -1; + + addWatchVar(var); + } + } else { + throw FileError(tr("Can't open file '%1' for read.") + .arg(filename)); + } +} + + QVariant WatchModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index 687a414f..5e88a14a 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -63,6 +63,7 @@ struct Breakpoint { int line; QString filename; QString condition; + bool enabled; }; using PBreakpoint = std::shared_ptr; @@ -112,6 +113,8 @@ public: PBreakpoint setBreakPointCondition(int index, const QString& condition); const QList& breakpoints() const; PBreakpoint breakpoint(int index) const; + void save(const QString& filename); + void load(const QString& filename); public slots: void onFileDeleteLines(const QString& filename, int startLine, int count); void onFileInsertLines(const QString& filename, int startLine, int count); @@ -160,6 +163,8 @@ public: void beginUpdate(); void endUpdate(); void notifyUpdated(PWatchVar var); + void save(const QString& filename); + void load(const QString& filename); private: QList mWatchVars; int mUpdateCount; diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 3cb29d6e..c9b50505 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -151,6 +151,9 @@ Editor::Editor(QWidget *parent, const QString& filename, setContextMenuPolicy(Qt::CustomContextMenu); connect(this, &QWidget::customContextMenuRequested, pMainWindow, &MainWindow::onEditorContextMenu); + + resetBookmarks(); + resetBreakpoints(); } Editor::~Editor() { @@ -3555,6 +3558,13 @@ bool Editor::hasBookmark(int line) return mBookmarkLines.contains(line); } +void Editor::clearBookmarks() +{ + mBookmarkLines.clear(); + pMainWindow->bookmarkModel()->removeBookmarks(mFilename); + invalidateGutter(); +} + void Editor::removeBreakpointFocus() { if (mActiveBreakpointLine!=-1) { diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index 160fcafd..18266e03 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -150,6 +150,7 @@ public: void addBookmark(int line,const QString& description); void removeBookmark(int line); bool hasBookmark(int line); + void clearBookmarks(); void removeBreakpointFocus(); void modifyBreakpointProperty(int line); void setActiveBreakpointFocus(int Line, bool setFocus=true); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 9525a2be..d26b7837 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -90,6 +90,11 @@ MainWindow::MainWindow(QWidget *parent) ui->tblStackTrace->setModel(mDebugger->backtraceModel()); ui->watchView->setModel(mDebugger->watchModel()); + mDebugger->breakpointModel()->load(includeTrailingPathDelimiter(pSettings->dirs().config()) + +DEV_BREAKPOINTS_FILE); + mDebugger->watchModel()->load(includeTrailingPathDelimiter(pSettings->dirs().config()) + +DEV_WATCH_FILE); + // ui->actionIndent->setShortcut(Qt::Key_Tab); // ui->actionUnIndent->setShortcut(Qt::Key_Tab | Qt::ShiftModifier); @@ -1655,7 +1660,15 @@ void MainWindow::buildContextMenus() [this]() { QModelIndex index = ui->tableBookmark->currentIndex(); if (index.isValid()) { - mBookmarkModel->removeBookmarkAt(index.row()); + PBookmark bookmark = mBookmarkModel->bookmark(index.row()); + if (bookmark) { + Editor * editor = mEditorList->getOpenedEditorByFilename(bookmark->filename); + if (editor) { + editor->removeBookmark(bookmark->line); + } else { + mBookmarkModel->removeBookmarkAt(index.row()); + } + } } }); mBookmark_RemoveAll=createActionFor( @@ -1664,6 +1677,10 @@ void MainWindow::buildContextMenus() connect(mBookmark_RemoveAll, &QAction::triggered, [this]() { mBookmarkModel->clear(); + for (int i=0;ipageCount();i++) { + Editor * editor = (*mEditorList)[i]; + editor->clearBookmarks(); + } }); mBookmark_Modify=createActionFor( tr("Modify Description"), @@ -1677,10 +1694,10 @@ void MainWindow::buildContextMenus() QString desc = QInputDialog::getText(ui->tableBookmark,tr("Bookmark Description"), tr("Description:"),QLineEdit::Normal, bookmark->description); - desc = desc.trimmed(); - mBookmarkModel->updateDescription(bookmark->filename,bookmark->line,desc); + desc = desc.trimmed(); + mBookmarkModel->updateDescription(bookmark->filename,bookmark->line,desc); + } } - mBookmarkModel->clear(); }); //context menu signal for the watch view @@ -2695,6 +2712,19 @@ void MainWindow::closeEvent(QCloseEvent *event) { settings.save(); mBookmarkModel->save(includeTrailingPathDelimiter(pSettings->dirs().config()) +DEV_BOOKMARK_FILE); + if (pSettings->debugger().autosaveBreakpoints()) + mDebugger->breakpointModel()->save(includeTrailingPathDelimiter(pSettings->dirs().config()) + +DEV_BREAKPOINTS_FILE); + else + removeFile(includeTrailingPathDelimiter(pSettings->dirs().config()) + +DEV_BREAKPOINTS_FILE); + if (pSettings->debugger().autosaveWatches()) + mDebugger->watchModel()->save(includeTrailingPathDelimiter(pSettings->dirs().config()) + +DEV_WATCH_FILE); + else + removeFile(includeTrailingPathDelimiter(pSettings->dirs().config()) + +DEV_WATCH_FILE); + } if (!mShouldRemoveAllSettings && pSettings->editor().autoLoadLastFiles()) { diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 8bbd4662..39e09353 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -3518,7 +3518,7 @@ SynEditorOptions SynEdit::getOptions() const void SynEdit::setOptions(const SynEditorOptions &Value) { if (Value != mOptions) { - bool bSetDrag = mOptions.testFlag(eoDropFiles) != Value.testFlag(eoDropFiles); + //bool bSetDrag = mOptions.testFlag(eoDropFiles) != Value.testFlag(eoDropFiles); //if (!mOptions.testFlag(eoScrollPastEol)) setLeftChar(mLeftChar); //if (!mOptions.testFlag(eoScrollPastEof)) @@ -3795,6 +3795,8 @@ void SynEdit::doUndoItem() Item->changeStr(), Item->changeSelMode()); break; + default: + break; } } } @@ -4013,6 +4015,8 @@ void SynEdit::doRedoItem() Item->changeEndPos(), Item->changeStr(), Item->changeSelMode()); break; } + default: + break; } } } @@ -5099,6 +5103,8 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData) case SynEditorCommand::ecToggleComment: doToggleComment(); break; + default: + break; } // procedure ForceCaretX(aCaretX: integer); @@ -5461,6 +5467,8 @@ bool SynEdit::event(QEvent *event) updateMouseCursor(); break; } + default: + break; } return QAbstractScrollArea::event(event); } @@ -5498,8 +5506,8 @@ void SynEdit::mousePressEvent(QMouseEvent *event) bool bWasSel = false; bool bStartDrag = false; mMouseMoved = false; - BufferCoord TmpBegin = mBlockBegin; - BufferCoord TmpEnd = mBlockEnd; +// BufferCoord TmpBegin = mBlockBegin; +// BufferCoord TmpEnd = mBlockEnd; Qt::MouseButton button = event->button(); int X=event->pos().x(); int Y=event->pos().y(); diff --git a/RedPandaIDE/qsynedit/exporter/synhtmlexporter.cpp b/RedPandaIDE/qsynedit/exporter/synhtmlexporter.cpp index 6e0e38e8..24248908 100644 --- a/RedPandaIDE/qsynedit/exporter/synhtmlexporter.cpp +++ b/RedPandaIDE/qsynedit/exporter/synhtmlexporter.cpp @@ -85,7 +85,7 @@ QString SynHTMLExporter::MakeValidName(const QString &Name) return Result; } -bool SynHTMLExporter::StyleNameCallback(PSynHighlighter Highlighter, PSynHighlighterAttribute Attri, const QString& UniqueAttriName, QList params) +bool SynHTMLExporter::StyleNameCallback(PSynHighlighter /*Highlighter*/, PSynHighlighterAttribute Attri, const QString& UniqueAttriName, QList params) { PSynHighlighterAttribute& AttriToFind = *static_cast(params[0]); QString& StyleName = *static_cast(params[1]); diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 7f182a71..2191a5ed 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -2831,6 +2831,26 @@ void Settings::Debugger::setSkipCustomLibraries(bool newSkipCustomLibraries) mSkipCustomLibraries = newSkipCustomLibraries; } +bool Settings::Debugger::autosaveWatches() const +{ + return mAutosaveWatches; +} + +void Settings::Debugger::setAutosaveWatches(bool newAutosaveWatches) +{ + mAutosaveWatches = newAutosaveWatches; +} + +bool Settings::Debugger::autosaveBreakpoints() const +{ + return mAutosaveBreakpoints; +} + +void Settings::Debugger::setAutosaveBreakpoints(bool newAutosaveBreakpoints) +{ + mAutosaveBreakpoints = newAutosaveBreakpoints; +} + bool Settings::Debugger::useIntelStyle() const { return mUseIntelStyle; @@ -2873,6 +2893,8 @@ void Settings::Debugger::doSave() saveValue("skip_system_lib", mSkipSystemLibraries); saveValue("skip_project_lib", mSkipProjectLibraries); saveValue("skip_custom_lib", mSkipCustomLibraries); + saveValue("autosave_breakpoints",mAutosaveBreakpoints); + saveValue("autosave_watches",mAutosaveWatches); } @@ -2888,6 +2910,8 @@ void Settings::Debugger::doLoad() mSkipSystemLibraries = boolValue("skip_system_lib",true); mSkipProjectLibraries = boolValue("skip_project_lib",true); mSkipCustomLibraries = boolValue("skip_custom_lib",false); + mAutosaveBreakpoints = boolValue("autosave_breakpoints",true); + mAutosaveWatches = boolValue("autosave_watches",true); } Settings::History::History(Settings *settings):_Base(settings, SETTING_HISTORY) diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 5914b5a0..102a1332 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -844,6 +844,12 @@ public: bool skipCustomLibraries() const; void setSkipCustomLibraries(bool newSkipCustomLibraries); + bool autosaveBreakpoints() const; + void setAutosaveBreakpoints(bool newAutosaveBreakpoints); + + bool autosaveWatches() const; + void setAutosaveWatches(bool newAutosaveWatches); + private: bool mShowCommandLog; bool mShowAnnotations; @@ -855,6 +861,8 @@ public: bool mSkipSystemLibraries; bool mSkipProjectLibraries; bool mSkipCustomLibraries; + bool mAutosaveBreakpoints; + bool mAutosaveWatches; // _Base interface protected: diff --git a/RedPandaIDE/settingsdialog/debuggeneralwidget.cpp b/RedPandaIDE/settingsdialog/debuggeneralwidget.cpp index 016bf1f2..b4255ed7 100644 --- a/RedPandaIDE/settingsdialog/debuggeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/debuggeneralwidget.cpp @@ -31,6 +31,8 @@ void DebugGeneralWidget::doLoad() ui->chkSkipSystemLib->setChecked(pSettings->debugger().skipSystemLibraries()); ui->chkSkipProjectLib->setChecked(pSettings->debugger().skipProjectLibraries()); ui->chkSkipCustomLib->setChecked(pSettings->debugger().skipCustomLibraries()); + ui->chkAutosaveBreakpoints->setChecked(pSettings->debugger().autosaveBreakpoints()); + ui->chkAutosaveWatches->setChecked(pSettings->debugger().autosaveWatches()); } void DebugGeneralWidget::doSave() @@ -45,6 +47,8 @@ void DebugGeneralWidget::doSave() pSettings->debugger().setSkipSystemLibraries(ui->chkSkipSystemLib->isChecked()); pSettings->debugger().setSkipProjectLibraries(ui->chkSkipProjectLib->isChecked()); pSettings->debugger().setSkipCustomLibraries(ui->chkSkipCustomLib->isChecked()); + pSettings->debugger().setAutosaveBreakpoints(ui->chkAutosaveBreakpoints->isChecked()); + pSettings->debugger().setAutosaveWatches(ui->chkAutosaveWatches->isChecked()); pSettings->debugger().save(); pMainWindow->updateDebuggerSettings(); } diff --git a/RedPandaIDE/settingsdialog/debuggeneralwidget.ui b/RedPandaIDE/settingsdialog/debuggeneralwidget.ui index 94296979..00be2fab 100644 --- a/RedPandaIDE/settingsdialog/debuggeneralwidget.ui +++ b/RedPandaIDE/settingsdialog/debuggeneralwidget.ui @@ -159,6 +159,29 @@ + + + + Autosave + + + + + + Autosave breakpoints + + + + + + + Autosave watches + + + + + + diff --git a/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp index 326e58e8..50c0d9a5 100644 --- a/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp @@ -38,7 +38,7 @@ void ExecutorGeneralWidget::doSave() pSettings->executor().save(); } -void ExecutorGeneralWidget::on_btnBrowse_triggered(QAction *arg1) +void ExecutorGeneralWidget::on_btnBrowse_clicked() { QString filename = QFileDialog::getOpenFileName( this, diff --git a/RedPandaIDE/settingsdialog/executorgeneralwidget.h b/RedPandaIDE/settingsdialog/executorgeneralwidget.h index 25ccba8e..7303b8d3 100644 --- a/RedPandaIDE/settingsdialog/executorgeneralwidget.h +++ b/RedPandaIDE/settingsdialog/executorgeneralwidget.h @@ -24,7 +24,7 @@ protected: void doLoad() override; void doSave() override; private slots: - void on_btnBrowse_triggered(QAction *arg1); + void on_btnBrowse_clicked(); }; #endif // EXECUTORGENERALWIDGET_H diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index 6e35b577..903a5f7f 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -48,6 +48,8 @@ #define DEV_SHORTCUT_FILE "shortcuts.json" #define DEV_TOOLS_FILE "tools.json" #define DEV_BOOKMARK_FILE "bookmarks.json" +#define DEV_BREAKPOINTS_FILE "breakpoints.json" +#define DEV_WATCH_FILE "watch.json" #ifdef Q_OS_WIN # define PATH_SENSITIVITY Qt::CaseInsensitive diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index a40548bc..7c0b4238 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -829,3 +829,9 @@ void StringToFile(const QString &str, const QString &fileName) stream<=0;i--) { + PBookmark bookmark = mBookmarks[i]; + if (bookmark->filename.compare(filename, PATH_SENSITIVITY) == 0) { + removeBookmarkAt(i); + } + } +} + void BookmarkModel::clear() { beginResetModel(); diff --git a/RedPandaIDE/widgets/bookmarkmodel.h b/RedPandaIDE/widgets/bookmarkmodel.h index 949a52d5..39bacfa0 100644 --- a/RedPandaIDE/widgets/bookmarkmodel.h +++ b/RedPandaIDE/widgets/bookmarkmodel.h @@ -23,6 +23,7 @@ public: PBookmark bookmark(int i); PBookmark bookmark(const QString&filename, int line); bool removeBookmark(const QString&filename, int line); + void removeBookmarks(const QString& filename); void clear(); bool updateDescription(const QString&filename, int line, const QString& description); void save(const QString& filename); diff --git a/RedPandaIDE/widgets/qconsole.cpp b/RedPandaIDE/widgets/qconsole.cpp index e2af3976..bc7b860d 100644 --- a/RedPandaIDE/widgets/qconsole.cpp +++ b/RedPandaIDE/widgets/qconsole.cpp @@ -444,13 +444,13 @@ void QConsole::contentsLayouted() updateScrollbars(); } -void QConsole::contentsRowsAdded(int rowCount) +void QConsole::contentsRowsAdded(int ) { ensureCaretVisible(); updateScrollbars(); } -void QConsole::contentsLastRowsRemoved(int rowCount) +void QConsole::contentsLastRowsRemoved(int ) { ensureCaretVisible(); updateScrollbars(); @@ -466,7 +466,6 @@ void QConsole::scrollTimerHandler() { QPoint iMousePos; - int X, Y; iMousePos = QCursor::pos(); iMousePos = mapFromGlobal(iMousePos); @@ -834,7 +833,7 @@ bool QConsole::caretInSelection() { if (!hasSelection()) return false; - LineChar selBegin = selectionBegin(); + //LineChar selBegin = selectionBegin(); LineChar selEnd = selectionEnd(); QString lastline = mContents.getLastLine(); int editBeginChar = lastline.length() - mCurrentEditableLine.length(); @@ -930,6 +929,8 @@ bool QConsole::event(QEvent *event) mInactiveSelectionBackground = palette().color(QPalette::Inactive,QPalette::Highlight); mInactiveSelectionForeground = palette().color(QPalette::Inactive,QPalette::HighlightedText); break; + default: + break; } return QAbstractScrollArea::event(event); } @@ -940,8 +941,7 @@ void QConsole::resizeEvent(QResizeEvent *) std::shared_ptr image = std::make_shared(clientWidth(),clientHeight(), QImage::Format_ARGB32); if (mContentImage) { - QRect newRect = image->rect().intersected(mContentImage->rect()); - + //QRect newRect = image->rect().intersected(mContentImage->rect()); QPainter painter(image.get()); painter.fillRect(viewport()->rect(),mBackground); // painter.drawImage(newRect,*mContentImage);