From 0c9f9d476f66620d95ab600677d40e16210b3715 Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 31 Jan 2018 08:31:00 +0000 Subject: [PATCH] ide: Remove DDUMPs (a function) git-svn-id: svn://ultimatepp.org/upp/trunk@11752 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/ide.h | 2 ++ uppsrc/ide/idebar.cpp | 13 ++++++++++--- uppsrc/ide/idetool.cpp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index 1b9a84dad..ecaadd7da 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -812,6 +812,7 @@ public: void InsertMenu(Bar& bar); void InsertInclude(Bar& bar); void InsertAdvanced(Bar& bar); + void AssistEdit(Bar& menu); void EditorMenu(Bar& bar); void ToggleWordwrap(); @@ -943,6 +944,7 @@ public: void GotoDirDiffRight(int line, DirDiffDlg *df); void DoDirDiff(); void AsErrors(); + void RemoveDs(); void HelpMenu(Bar& menu); void ViewIdeLogFile(); diff --git a/uppsrc/ide/idebar.cpp b/uppsrc/ide/idebar.cpp index c0b09e257..62c0717b0 100644 --- a/uppsrc/ide/idebar.cpp +++ b/uppsrc/ide/idebar.cpp @@ -115,11 +115,18 @@ void Ide::OnlineSearchMenu(Bar& menu) menu.Add(b, AK_GOOGLEUPP, IdeImg::GoogleUpp(), THISBACK(OnlineSearchOnTheOfficialSite)); } +void Ide::AssistEdit(Bar& menu) +{ + bool b = !editor.IsReadOnly() && !designer; + menu.Add(b, "Insert", THISBACK(InsertMenu)); + menu.Add(b, "Insert #include", THISBACK(InsertInclude)); + menu.Add(b, "Remove debugging logs (DDUMP...)", [=] { RemoveDs(); }); +} + void Ide::InsertAdvanced(Bar& bar) { bool b = !editor.IsReadOnly(); - bar.Add(b, "Insert", THISBACK(InsertMenu)); - bar.Add(b, "Insert #include", THISBACK(InsertInclude)); + AssistEdit(bar); bar.Add(b, "Advanced", THISBACK(EditSpecial)); } @@ -680,7 +687,7 @@ void Ide::BrowseMenu(Bar& menu) menu.Add(!designer, AK_COMPLETE, callback(&editor, &AssistEditor::Complete)); menu.Add(!designer, AK_ABBR, callback(&editor, &AssistEditor::Abbr)); menu.Add(!designer, AK_GO_TO_LINE, THISBACK(GoToLine)); - menu.Add(!designer, "Insert", THISBACK(InsertMenu)); + AssistEdit(menu); menu.MenuSeparator(); } diff --git a/uppsrc/ide/idetool.cpp b/uppsrc/ide/idetool.cpp index c22953cb7..936882e37 100644 --- a/uppsrc/ide/idetool.cpp +++ b/uppsrc/ide/idetool.cpp @@ -518,6 +518,38 @@ void Ide::AsErrors() SetErrorEditor(); } +void Ide::RemoveDs() +{ + if(designer || editor.IsReadOnly()) + return; + static Index ds = { "DLOG", "DDUMP", "DDUMPC", "DDUMPM", "DTIMING", + "DLOGHEX", "DDUMPHEX", "DTIMESTOP", "DHITCOUNT" }; + editor.NextUndo(); + int l = 0; + int h = editor.GetLineCount() - 1; + int ll, hh; + if(editor.GetSelection(ll, hh)) { + l = editor.GetLine(ll); + h = editor.GetLine(hh); + } + for(int i = h; i >= l; i--) { + String ln = editor.GetUtf8Line(i); + try { + CParser p(ln); + if(p.IsId()) { + String id = p.ReadId(); + if(ds.Find(id) >= 0 && p.Char('(')) { + int pos = editor.GetPos(i); + int end = min(editor.GetLength(), editor.GetPos(i) + editor.GetLineLength(i) + 1); + editor.Remove(editor.GetPos(i), end - pos); + } + } + } + catch(CParser::Error) {} + } + editor.GotoLine(l); +} + void Ide::LaunchAndroidSDKManager(const AndroidSDK& androidSDK) { One host = CreateHost(false);