From 7c0ee9857baa13316b9e80667863ffa06c4afc26 Mon Sep 17 00:00:00 2001 From: royqh1979 Date: Sat, 13 Nov 2021 17:41:16 +0800 Subject: [PATCH] - fix: "collapse all" and "uncollapse all" doesn't work --- NEWS.md | 13 ++++++++----- RedPandaIDE/mainwindow.cpp | 5 ++--- RedPandaIDE/qsynedit/SynEdit.cpp | 16 ++++++++++++++++ RedPandaIDE/qsynedit/SynEdit.h | 2 ++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index ccb464bb..a87eed53 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,14 +1,17 @@ -Version 0.8.7 For Dev-C++ 7 Beta - - enhancement: auto indent line to column 1 when enter '#' at beginning of line - - fix: when enter '{' or '}' at beginning of line, auto indent will remove all contents of the line - - fix: auto indent should be turned off when reformat code - - fix: auto indent should be turned off when replace in code +Version 0.8.8 For Dev-C++ 7 Beta - enhancement: drag & drop text in the editor - enhancement: auto calcuate caret line size basing on font size - enhancement: shift+mouse wheel to scroll horizontally - fix: greatly reduces paste time - fix: auto indent shouldn't use preprocessor's indent to calculate - fix: option "don't add leading zeros to line numbers" not work + - fix: "collapse all" and "uncollapse all" doesn't work + +Version 0.8.7 For Dev-C++ 7 Beta + - enhancement: auto indent line to column 1 when enter '#' at beginning of line + - fix: when enter '{' or '}' at beginning of line, auto indent will remove all contents of the line + - fix: auto indent should be turned off when reformat code + - fix: auto indent should be turned off when replace in code Version 0.8.6 For Dev-C++ 7 Beta - enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 80m+) diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 06939749..8c6058df 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -3773,7 +3773,7 @@ void MainWindow::on_actionUnfoldAll_triggered() { Editor * editor = mEditorList->getEditor(); if (editor != NULL ) { - //editor->clearFolds(); + editor->unCollpaseAll(); } } @@ -3781,8 +3781,7 @@ void MainWindow::on_actionFoldAll_triggered() { Editor * editor = mEditorList->getEditor(); if (editor != NULL ) { - //editor->clearFolds(); - //editor->foldAll(); + editor->collapseAll(); } } diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 6b4caa5c..37590b7a 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -1066,6 +1066,20 @@ void SynEdit::setCaretAndSelection(const BufferCoord &ptCaret, const BufferCoord setBlockEnd(ptAfter); } +void SynEdit::collapseAll() +{ + for (int i = mAllFoldRanges.count()-1;i>=0;i--){ + collapse(mAllFoldRanges[i]); + } +} + +void SynEdit::unCollpaseAll() +{ + for (int i = mAllFoldRanges.count()-1;i>=0;i--){ + uncollapse(mAllFoldRanges[i]); + } +} + void SynEdit::processGutterClick(QMouseEvent *event) { int X = event->pos().x(); @@ -5054,6 +5068,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value) bool bChangeScroll; // int SpaceCount; int Result = 0; + int startLine = mCaretY; sLeftSide = lineText().mid(0, mCaretX - 1); if (mCaretX - 1 > sLeftSide.length()) { if (StringIsBlank(sLeftSide)) @@ -5122,6 +5137,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value) internalSetCaretXY(BufferCoord{lineText().length()+1,caretY}); } else internalSetCaretXY(BufferCoord{Str.length() - sRightSide.length()+1,caretY}); + onLinesPutted(startLine-1,Result+1); return Result; } diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index 571848ad..596bdc63 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -219,6 +219,8 @@ public: const BufferCoord& ptBefore, const BufferCoord& ptAfter); + void collapseAll(); + void unCollpaseAll(); void uncollapseAroundLine(int line); PSynEditFoldRange foldHidesLine(int line); void setSelLength(int Value);