50 #ifndef STAGE_WIDGET_ERROR_LOG_DISPLAY_H 51 #define STAGE_WIDGET_ERROR_LOG_DISPLAY_H 79 using Tag = Glib::RefPtr<Gtk::TextBuffer::Tag>;
89 Tag errorTag = Gtk::TextBuffer::Tag::create (cuString{TAG_ERROR});
90 errorTag->property_background() =
"Yellow";
91 errorTag->property_weight() = PANGO_WEIGHT_BOLD;
92 tagTable->add (errorTag);
94 Tag warnTag = Gtk::TextBuffer::Tag::create (cuString{TAG_WARN});
95 warnTag->property_background() =
"LightYellow";
96 tagTable->add (warnTag);
115 :
public Gtk::ScrolledWindow
118 using Mark = Glib::RefPtr<Gtk::TextBuffer::Mark>;
119 using Entry = std::pair<Mark,Mark>;
122 using SignalErrorChanged = sigc::signal<void, bool>;
124 vector<Entry> errorMarks_;
127 SignalErrorChanged errorChangedSignal_;
134 : Gtk::ScrolledWindow()
138 set_size_request (200, 80);
139 property_expand() =
true;
140 set_border_width (10);
141 set_shadow_type (Gtk::SHADOW_NONE);
144 set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
145 textLog_.set_editable (
false);
146 this->add (textLog_);
159 bool shallNotify = this->isError();
162 size_t lineCnt = max (0, textLog_.get_buffer()->get_line_count() - 1);
165 placeholder =
_Fmt{_(
"───════ %d preceding lines removed ════───\n")} % lineCnt;
166 textLog_.get_buffer()->set_text (placeholder);
169 errorChangedSignal_.emit (
false);
185 addEntry (
"WARNING: "+text, TAG_WARN);
198 bool shallNotify = not this->isError();
200 errorMarks_.emplace_back(
201 addEntry (
"ERROR: "+text, TAG_ERROR));
202 if (not expand.isExpanded())
206 errorChangedSignal_.emit (
true);
217 auto newBuff = Gtk::TextBuffer::create (textLog_.get_buffer()->get_tag_table());
218 vector<Entry> newMarks;
219 for (Entry&
entry : errorMarks_)
221 newBuff->insert (newBuff->end(),
"\n");
222 auto pos = newBuff->end();
224 newMarks.emplace_back(
226 newBuff->create_mark (pos,
true),
227 newBuff->create_mark (pos,
false)));
230 ,
entry.first->get_iter()
231 ,
entry.second->get_iter()
235 auto oldBuff = textLog_.get_buffer();
236 textLog_.set_buffer(newBuff);
237 swap (errorMarks_, newMarks);
240 int oldLines = oldBuff->get_line_count();
241 int newLines = newBuff->get_line_count();
242 ASSERT (oldLines >= newLines);
243 addInfo (
_Fmt{_(
"───════ %d old log lines removed ════───\n")} % (oldLines-newLines));
251 if (not isError())
return;
253 auto buff = textLog_.get_buffer();
254 for (Entry&
entry : errorMarks_)
256 auto begin =
entry.first->get_iter();
257 auto end =
entry.second->get_iter();
259 buff->remove_tag_by_name(uString{TAG_ERROR}, begin,end);
260 buff->apply_tag_by_name (uString{TAG_WARN}, begin,end);
263 errorChangedSignal_.emit (
false);
283 return not errorMarks_.empty();
290 return errorChangedSignal_;
313 auto buff = textLog_.get_buffer();
314 buff->insert (buff->end(),
"\n");
315 auto pos = buff->end();
317 auto begin = buff->create_mark (pos,
true);
318 auto after = buff->create_mark (pos,
false);
320 buff->insert_with_tag(pos, text, cuString{markupTagName});
322 buff->insert (pos, text);
323 textLog_.scroll_to (begin);
324 return make_pair (move(begin), move(after));
Major public Interface of the Lumiera GUI.
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
inline string literal This is a marker type to indicate that
A front-end for using printf-style formatting.
Helper components to implement some standard UI-element actions by installing a functor.
Functor component to support the default implementation of revealing an UI-Element.
Decorator to add the ability to display a visual flash action to a GTK widget.
Marker types to indicate a literal string and a Symbol.
Lumiera GTK UI implementation root.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Functor component to support the default implementation of expanding/collapsing.
Definition of access keys for uniform UI styling.
A set of basic GTK includes for the UI.