diff --git a/src/gui/widget/error-log-display.hpp b/src/gui/widget/error-log-display.hpp index 19d2064f4..a818056e2 100644 --- a/src/gui/widget/error-log-display.hpp +++ b/src/gui/widget/error-log-display.hpp @@ -67,6 +67,7 @@ //#include "lib/util.hpp" //#include +#include #include @@ -76,7 +77,9 @@ namespace widget { using util::_Fmt; using lib::Literal; + using std::make_pair; using std::vector; + using std::move; namespace { @@ -107,17 +110,25 @@ namespace widget { /** - * @todo WIP-WIP as of 9/2017 - * Just a text display box with scrollbars. - * Need to add formatting etc. + * Widget to display log and error messages. + * Based on a multiline text display box with scrollbars. + * Warning and error messages are highlighted by special formatting. + * And [error entries are treated specially](\ref addError()), insofar + * they are tracked by an index, allowing to build additional convenience + * features later on... + * @remarks this is _just a widget_ intended for direct use. By default, + * it is managed by the \ref NotificationHub, which is a controller, + * attached to the UI-Bus and responding to the [UI-Element protocol] + * (\ref tangible.hpp). */ class ErrorLogDisplay : public Gtk::ScrolledWindow { using Mark = Glib::RefPtr; + using Entry = std::pair; - vector errorMarks_; + vector errorMarks_; Gtk::TextView textLog_; public: @@ -188,10 +199,38 @@ namespace widget { expand (true); } + /** + * clear all mere information messages; + * retain just the errors with tags + * @remark in fact populates a new buffer + */ void clearInfoMsg() { - UNIMPLEMENTED ("clear all mere information messages; then re-insert the errors with tags"); + auto newBuff = Gtk::TextBuffer::create (textLog_.get_buffer()->get_tag_table()); + vector newMarks; + for (Entry& entry : errorMarks_) + { + newMarks.emplace_back( + make_pair ( + newBuff->create_mark (newBuff->end(), true), // "left gravity": stays to the left of inserted text + newBuff->create_mark (newBuff->end(), false))); // "right gravity": sticks right behind the inserted text)) + + newBuff->insert (newBuff->end() + ,entry.first->get_iter() + ,entry.second->get_iter() + ); + } + // install the reduced new buffer + auto oldBuff = textLog_.get_buffer(); + textLog_.set_buffer(newBuff); + swap (errorMarks_, newMarks); + + // add a marker line to indicate the removed old log contents + int oldLines = oldBuff->get_line_count(); + int newLines = newBuff->get_line_count(); + ASSERT (oldLines >= newLines); + addInfo (_Fmt{_("───════ %d old log lines removed ════───\n")} % (oldLines-newLines)); } void @@ -220,19 +259,19 @@ namespace widget { * [GTKmm tutorial]: https://developer.gnome.org/gtkmm-tutorial/stable/sec-textview-buffer.html.en#textview-marks * [insert-mark]: https://developer.gnome.org/gtkmm/3.22/classGtk_1_1TextMark.html#details */ - Mark + Entry addEntry (string const& text, Literal markupTagName =nullptr) { auto buff = textLog_.get_buffer(); - auto cursor = buff->get_insert(); - buff->move_mark (cursor, buff->end()); + auto begin = buff->create_mark (buff->end(), true); // "left gravity": stays to the left of inserted text + auto after = buff->create_mark (buff->end(), false);// "right gravity": sticks right behind the inserted text if (markupTagName) buff->insert_with_tag(buff->end(), text, cuString{markupTagName}); else buff->insert (buff->end(), text); buff->insert (buff->end(), "\n"); - textLog_.scroll_to (cursor); - return cursor; + textLog_.scroll_to (after); + return make_pair (move(begin), move(after)); } }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 4f616e56b..f8d26919a 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -2063,8 +2063,7 @@ daß hier ## Zeilen gelöscht wurden

- - + @@ -2140,6 +2139,29 @@ + + + + + + + + + + + + + +

+ ...das liegt vermutlich daran, daß ich die zweite Marke mit "right gravity" einfüge, +

+

+ aber eben am absoluten Ende des Buffers. Damit wird sie hinter jeder Einfügung bleiben +

+ + +
+
@@ -2190,14 +2212,17 @@ - - + + - - + + - - + + + + + @@ -2223,9 +2248,9 @@ - - - + + + @@ -2263,9 +2288,9 @@ - - - + + + @@ -2276,8 +2301,15 @@ - - + + + + + + + + + @@ -2386,7 +2418,7 @@ - + @@ -2644,8 +2676,8 @@ - - + + @@ -2692,23 +2724,24 @@ - - - + + +

- TODO: how can the Log-Widget be 'revealed'?? + Lösung: delegiere über zwei Stufen...

- Possibly allocate Widget, expand it. But how to make it visible? + Neue Revealer-Komponente bindet einen Funktor

-
- + + +
@@ -2942,7 +2975,7 @@ - + @@ -2957,8 +2990,7 @@ und nicht string wie für alle anderen state marks

- -
+
@@ -2974,8 +3006,7 @@ k

- - + @@ -3013,8 +3044,7 @@ Konzept ist nicht, sie gleich in die description zu übernehmen

- - +
@@ -3049,8 +3079,7 @@ keines! Impl verwendet strdup()

- - +
@@ -3097,8 +3126,7 @@ ...denn wir verwenden das Lumiera-Exception-API gar nicht

- - +
@@ -3119,8 +3147,7 @@ der Handler im ProcDispatcher sorgt dafür

- - +
@@ -3143,8 +3170,7 @@ ...welches keinen separaten Thread aufruft....?

- - +
@@ -3167,8 +3193,7 @@ nämlich im shutdownAll() weiter oben im Stack

- - +
@@ -3185,8 +3210,7 @@ aber genau der andere Thread, der das gemacht hat...

- - +
@@ -3236,8 +3260,7 @@ Wenn das nun wirklich fehlschlägt, bleibt uns sinnvollerweise nur noch die Selbstmord-Option

- - +
@@ -3262,8 +3285,7 @@ ein ZombieCheck spricht an

- - + @@ -3341,8 +3363,7 @@ Abgebrochen

- - + @@ -3415,8 +3436,7 @@ ..damit ~GtkLumiera() garantiert vorher aufgerufen wird

- - +
@@ -3534,8 +3554,7 @@ (hiv)~/devel/lumi-$

- - +