From 885b9e9208b16bba744d1519da39c2a1aa84e5b5 Mon Sep 17 00:00:00 2001 From: Vadim Yegorov Date: Tue, 19 Apr 2016 23:45:23 +0000 Subject: [PATCH] =?UTF-8?q?1.=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=D1=8B=D1=85=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D1=82=D0=B5=D0=B9=20=D0=B2=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- far/changelog | 6 +++++- far/edit.cpp | 53 +++++++++----------------------------------------- far/edit.hpp | 13 +++---------- far/editor.cpp | 44 +++-------------------------------------- far/editor.hpp | 5 ----- far/vbuild.m4 | 2 +- 6 files changed, 21 insertions(+), 102 deletions(-) diff --git a/far/changelog b/far/changelog index fc332defe8..d1f1c3e052 100644 --- a/far/changelog +++ b/far/changelog @@ -1,4 +1,8 @@ -w17 20.04.2016 01:39:19 +0300 - build 4627 +zg 20.04.2016 02:44:24 +0200 - build 4628 + +1. убрана отложенная сортировка цветовых областей в редакторе. + +w17 20.04.2016 01:39:19 +0300 - build 4627 1. Fix 4492. diff --git a/far/edit.cpp b/far/edit.cpp index 30d7295c28..fd190665bf 100644 --- a/far/edit.cpp +++ b/far/edit.cpp @@ -2139,56 +2139,19 @@ void Edit::DeleteBlock() Changed(true); } -void Edit::AddColor(const ColorItem& col,bool skipsort) +void Edit::AddColor(const ColorItem& col) { - if (skipsort && !ColorListFlags.Check(ECLF_NEEDSORT) && !ColorList.empty() && ColorList.back().Priority > col.Priority) - { - ColorListFlags.Set(ECLF_NEEDSORT); - } - - ColorList.emplace_back(col); - - if (!skipsort) - { - std::stable_sort(ALL_RANGE(ColorList)); - } + ColorList.insert(col); } -void Edit::SortColorUnlocked() -{ - if (ColorListFlags.Check(ECLF_NEEDFREE)) - { - ColorListFlags.Clear(ECLF_NEEDFREE); - if (ColorList.empty()) - { - clear_and_shrink(ColorList); - } - } - - if (ColorListFlags.Check(ECLF_NEEDSORT)) - { - ColorListFlags.Clear(ECLF_NEEDSORT); - std::stable_sort(ALL_RANGE(ColorList)); - } -} - -void Edit::DeleteColor(const delete_color_condition& Condition, bool skipfree) +void Edit::DeleteColor(const delete_color_condition& Condition) { if (!ColorList.empty()) { - ColorList.erase(std::remove_if(ALL_RANGE(ColorList), Condition), ColorList.end()); - - if (ColorList.empty()) + std::for_each(RANGE(ColorList, color) { - if (skipfree) - { - ColorListFlags.Set(ECLF_NEEDFREE); - } - else - { - clear_and_shrink(ColorList); - } - } + if (Condition(color)) ColorList.erase(color); + }); } } @@ -2197,7 +2160,9 @@ bool Edit::GetColor(ColorItem& col, size_t Item) const if (Item >= ColorList.size()) return false; - col = ColorList[Item]; + auto it = ColorList.begin(); + std::advance(it, Item); + col = *it; return true; } diff --git a/far/edit.hpp b/far/edit.hpp index ffe6172398..8174505b14 100644 --- a/far/edit.hpp +++ b/far/edit.hpp @@ -102,11 +102,6 @@ class Editor; class Edit: public SimpleScreenObject { - enum EDITCOLORLISTFLAGS - { - ECLF_NEEDSORT = 0x1, - ECLF_NEEDFREE = 0x2, - }; struct ShowInfo { int LeftPos; @@ -182,9 +177,8 @@ class Edit: public SimpleScreenObject void SetEditorMode(bool Mode) {m_Flags.Change(FEDITLINE_EDITORMODE, Mode);} bool ReplaceTabs(); void InsertTab(); - void AddColor(const ColorItem& col, bool skipsort); - void SortColorUnlocked(); - void DeleteColor(const delete_color_condition& Condition,bool skipfree); + void AddColor(const ColorItem& col); + void DeleteColor(const delete_color_condition& Condition); bool GetColor(ColorItem& col, size_t Item) const; void Xlat(bool All=false); void SetDialogParent(DWORD Sets); @@ -258,11 +252,10 @@ class Edit: public SimpleScreenObject friend class FileEditor; // KEEP ALIGNED! - std::vector ColorList; + std::multiset ColorList; int m_SelStart; int m_SelEnd; int LeftPos; - TBitFlags ColorListFlags; unsigned char EndType; }; diff --git a/far/editor.cpp b/far/editor.cpp index 3a79550f1d..a33d763628 100644 --- a/far/editor.cpp +++ b/far/editor.cpp @@ -131,8 +131,6 @@ Editor::Editor(window_ptr Owner, bool DialogUsed): NewSessionPos(), EditorID(::EditorID++), HostFileEditor(nullptr), - SortColorLockCount(0), - SortColorUpdate(false), EditorControlLock(0), Color(colors::PaletteColorToFarColor(COL_EDITORTEXT)), SelColor(colors::PaletteColorToFarColor(COL_EDITORSELECTEDTEXT)), @@ -310,9 +308,7 @@ void Editor::ShowEditor() if (!m_Flags.Check(FEDITOR_DIALOGMEMOEDIT)) { _SYS_EE_REDRAW(SysLog(L"Call ProcessEditorEvent(EE_REDRAW)")); - SortColorLock(); Global->CtrlObject->Plugins->ProcessEditorEvent(EE_REDRAW, EEREDRAW_ALL, this); - SortColorUnlock(); } } _SYS_EE_REDRAW(else SysLog(L"ScrBuf Locked !!!")); @@ -2702,9 +2698,7 @@ int Editor::ProcessKey(const Manager::Key& Key) { //_D(SysLog(L"%08d EE_REDRAW",__LINE__)); _SYS_EE_REDRAW(SysLog(L"Editor::ProcessKey[%d](!EdOpt.CursorBeyondEOL): EE_REDRAW(EEREDRAW_ALL)",__LINE__)); - SortColorLock(); Global->CtrlObject->Plugins->ProcessEditorEvent(EE_REDRAW, EEREDRAW_ALL, this); - SortColorUnlock(); } /*$ 03.02.2001 SKV @@ -2987,9 +2981,7 @@ int Editor::ProcessMouse(const MOUSE_EVENT_RECORD *MouseEvent) if (!m_Flags.Check(FEDITOR_DIALOGMEMOEDIT)) { _SYS_EE_REDRAW(SysLog(L"Editor::ProcessMouse[%08d] ProcessEditorEvent(EE_REDRAW)",__LINE__)); - SortColorLock(); Global->CtrlObject->Plugins->ProcessEditorEvent(EE_REDRAW, EEREDRAW_ALL, this); - SortColorUnlock(); } ShowEditor(); } @@ -5967,9 +5959,8 @@ int Editor::EditorControl(int Command, intptr_t Param1, void *Param2) return FALSE; } - CurPtr->AddColor(newcol, SortColorLocked()); + CurPtr->AddColor(newcol); if (col->Flags&ECF_AUTODELETE) m_AutoDeletedColors.emplace(&*CurPtr); - SortColorUpdate=true; return TRUE; } @@ -6027,12 +6018,7 @@ int Editor::EditorControl(int Command, intptr_t Param1, void *Param2) _ECTLLOG(SysLog(L"GetStringByNumber(%d) return nullptr",col->StringNumber)); return FALSE; } - - SortColorUpdate=true; - - CurPtr->DeleteColor( - [&](const ColorItem& Item) { return (col->StartPos == -1 || col->StartPos == Item.StartPos) && col->Owner == Item.GetOwner(); }, - SortColorLocked()); + CurPtr->DeleteColor([&](const ColorItem& Item) { return (col->StartPos == -1 || col->StartPos == Item.StartPos) && col->Owner == Item.GetOwner();}); return TRUE; } @@ -7342,30 +7328,6 @@ void Editor::DrawScrollbar() } } -void Editor::SortColorLock() -{ - SortColorLockCount++; -} - -void Editor::SortColorUnlock() -{ - if (SortColorLockCount > 0) - SortColorLockCount--; - else - SortColorLockCount = 0; - - if (SortColorLockCount == 0 && SortColorUpdate) - { - SortColorUpdate = false; - std::for_each(ALL_RANGE(Lines), std::mem_fn(&Edit::SortColorUnlocked)); - } -} - -bool Editor::SortColorLocked() const -{ - return SortColorLockCount > 0; -} - void Editor::Change(EDITOR_CHANGETYPE Type,int StrNum) { if (ChangeEventSubscribers.empty()) @@ -7427,7 +7389,7 @@ void Editor::AutoDeleteColors() { std::for_each(CONST_RANGE(m_AutoDeletedColors, i) { - i->DeleteColor([](const ColorItem& Item){ return (Item.Flags & ECF_AUTODELETE) != 0; }, SortColorLocked()); + i->DeleteColor([](const ColorItem& Item){ return (Item.Flags & ECF_AUTODELETE) != 0; }); }); m_AutoDeletedColors.clear(); } diff --git a/far/editor.hpp b/far/editor.hpp index 1f32cef9f4..415865cd81 100644 --- a/far/editor.hpp +++ b/far/editor.hpp @@ -124,9 +124,6 @@ class Editor: public SimpleScreenObject int GetCurRow() const { return static_cast(m_it_CurLine.Number()); } void SetCurPos(int NewCol, int NewRow = -1); void DrawScrollbar(); - void SortColorLock(); - void SortColorUnlock(); - bool SortColorLocked() const; bool EditorControlLocked() const { return EditorControlLock != 0; } const FarColor& GetNormalColor() const { return Color; } const FarColor& GetSelectedColor() const { return SelColor; } @@ -372,8 +369,6 @@ class Editor: public SimpleScreenObject bool NewSessionPos; int EditorID; FileEditor *HostFileEditor; - int SortColorLockCount; - bool SortColorUpdate; int EditorControlLock; std::vector decoded; FarColor Color; diff --git a/far/vbuild.m4 b/far/vbuild.m4 index d1678de704..b616515d32 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -m4_define(BUILD,4627)m4_dnl +m4_define(BUILD,4628)m4_dnl