From 49ac9818dd285e135bf1fc755ce63a6e53e71f00 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 24 Oct 2014 16:34:08 +0000 Subject: [PATCH] ide: Error messages improved git-svn-id: svn://ultimatepp.org/upp/trunk@7824 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/Bottom.cpp | 2 +- uppsrc/ide/Build.cpp | 1 - uppsrc/ide/Errors.cpp | 42 ++++++++++++++++++++++++++++++------------ uppsrc/ide/ide.h | 5 ++--- uppsrc/ide/idebar.cpp | 2 +- uppsrc/ide/idewin.cpp | 11 +++++------ 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/uppsrc/ide/Bottom.cpp b/uppsrc/ide/Bottom.cpp index 5d622472f..561adba66 100644 --- a/uppsrc/ide/Bottom.cpp +++ b/uppsrc/ide/Bottom.cpp @@ -168,7 +168,7 @@ void Ide::SyncBottom() if(editor_bottom.GetZoom() >= 0) editor_bottom.NoZoom(); console.Show(q == BCONSOLE); - errors.Show(q == BERRORS); + error.Show(q == BERRORS); ffound.Show(q == BFINDINFILES); calc.Show(q == BCALC); if(bottomctrl) diff --git a/uppsrc/ide/Build.cpp b/uppsrc/ide/Build.cpp index bc816f661..b63f7ec02 100644 --- a/uppsrc/ide/Build.cpp +++ b/uppsrc/ide/Build.cpp @@ -48,7 +48,6 @@ void Ide::BeginBuilding(bool sync_files, bool clear_console) SyncErrorsMessage(); error_count = 0; warning_count = 0; - notes.Clear(); if(clear_console) console.Clear(); build_time = GetTickCount(); diff --git a/uppsrc/ide/Errors.cpp b/uppsrc/ide/Errors.cpp index a3d42e2d8..2246f6bf3 100644 --- a/uppsrc/ide/Errors.cpp +++ b/uppsrc/ide/Errors.cpp @@ -416,31 +416,49 @@ void Ide::AddNote(const ErrorInfo& f) error.Set(cnt - 1, "NOTES", n); } -void Ide::ShowNote() -{ - if(notes.IsCursor()) - GoToError(notes); -} - void Ide::ShowFound() { if(ffound.IsCursor()) GoToError(ffound); } -void Ide::ShowError() +void Ide::SelError() { - notes.Clear(); + if(removing_notes) + return; if(error.IsCursor()) { - ValueArray n = error.Get("NOTES"); - for(int i = 0; i < n.GetCount(); i++) { - const ErrorInfo& f = ValueTo(n[i]); - notes.Add(f.file, f.lineno, f.message, n[i]); + Value v = error.Get("NOTES"); + if(v != "0") { + int sc = error.GetScroll(); + removing_notes = true; + for(int i = error.GetCount() - 1; i >= 0; i--) + if(error.Get(i, "NOTES") == "0") + error.Remove(i); + removing_notes = false; + error.ScrollTo(sc); + error.ScrollIntoCursor(); + ValueArray n = v; + int ii = error.GetCursor(); + for(int i = 0; i < n.GetCount(); i++) { + const ErrorInfo& f = ValueTo(n[i]); + error.Insert(++ii); + error.Set(ii, 0, f.file); + error.Set(ii, 1, f.lineno); + error.Set(ii, 2, f.message); + error.Set(ii, "INFO", n[i]); + error.Set(ii, "NOTES", "0"); + } } GoToError(error); } } +void Ide::ShowError() +{ + if(error.IsCursor()) + GoToError(error); +} + void Ide::FoundDisplay::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { String s = q; diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index 36473f8e0..ee7097210 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -650,14 +650,13 @@ public: ArrayCtrl ffound; - Splitter errors; ArrayCtrl error; int error_count; int warning_count; - ArrayCtrl notes; bool addnotes; bool linking; Vector linking_line; + bool removing_notes; IdeCalc calc; Ptr bottomctrl; @@ -1162,9 +1161,9 @@ public: void ConsoleRunEnd(); void AddNote(const ErrorInfo& f); void SyncErrorsMessage(); - void ShowNote(); void ShowError(); void ShowFound(); + void SelError(); struct FoundDisplay : Display { virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const; diff --git a/uppsrc/ide/idebar.cpp b/uppsrc/ide/idebar.cpp index 478f9d785..c8407ce62 100644 --- a/uppsrc/ide/idebar.cpp +++ b/uppsrc/ide/idebar.cpp @@ -491,7 +491,7 @@ void Ide::BuildMenu(Bar& menu) { bool ff = btabs.GetCursor() == BFINDINFILES; String hh = ff ? "position" : "error line"; - bool ffb = ff ? ffound.GetCount() : errors.GetCount(); + bool ffb = ff ? ffound.GetCount() : error.GetCount(); menu.Add(ffb, AK_FINDNEXTERROR, THISBACK(FindNextError)) .Help("Find next " + hh + "according to console pane"); menu.Add(ffb, AK_FINDPREVERROR, THISBACK(FindPrevError)) diff --git a/uppsrc/ide/idewin.cpp b/uppsrc/ide/idewin.cpp index 1813308c6..cb24d456b 100644 --- a/uppsrc/ide/idewin.cpp +++ b/uppsrc/ide/idewin.cpp @@ -385,29 +385,28 @@ Ide::Ide() SetupError(error, "Message"); error.AddIndex("NOTES"); + error.ColumnWidths("207 41 834"); - SetupError(notes, "Note"); - SetupError(ffound, "Source"); ffound.ColumnWidths("207 41 834"); ffound.ColumnAt(0).SetDisplay(Single()); ffound.ColumnAt(2).SetDisplay(Single()); - errors.Horz(error, notes); - error.WhenSel = error.WhenLeftClick = THISBACK(ShowError); - notes.WhenSel = notes.WhenLeftClick = THISBACK(ShowNote); + error.WhenSel = THISBACK(SelError); + error.WhenLeftClick = THISBACK(ShowError); ffound.WhenSel = ffound.WhenLeftClick = THISBACK(ShowFound); console.WhenLine = THISBACK(ConsoleLine); console.WhenRunEnd = THISBACK(ConsoleRunEnd); addnotes = false; + removing_notes = false; editor_bottom.Vert(right_split, bottom); console.WhenBar = THISBACK(ConsoleMenu); editor_bottom.SetPos(8000); bottom.SetFrame(btabs); bottom.Add(console.SizePos().SetFrame(NullFrame())); - bottom.Add(errors.SizePos().SetFrame(NullFrame())); + bottom.Add(error.SizePos().SetFrame(NullFrame())); bottom.Add(ffound.SizePos().SetFrame(NullFrame())); bottom.Add(calc.SizePos().SetFrame(NullFrame())); btabs <<= THISBACK(SyncBottom);