59 #ifndef STAGE_WIDGET_ERROR_LOG_DISPLAY_H 60 #define STAGE_WIDGET_ERROR_LOG_DISPLAY_H 88 using Tag = Glib::RefPtr<Gtk::TextBuffer::Tag>;
98 Tag errorTag = Gtk::TextBuffer::Tag::create (cuString{TAG_ERROR});
99 errorTag->property_background() =
"Yellow";
100 errorTag->property_weight() = PANGO_WEIGHT_BOLD;
101 tagTable->add (errorTag);
103 Tag warnTag = Gtk::TextBuffer::Tag::create (cuString{TAG_WARN});
104 warnTag->property_background() =
"LightYellow";
105 tagTable->add (warnTag);
124 :
public Gtk::ScrolledWindow
127 using Mark = Glib::RefPtr<Gtk::TextBuffer::Mark>;
128 using Entry = std::pair<Mark,Mark>;
131 using SignalErrorChanged = sigc::signal<void, bool>;
133 vector<Entry> errorMarks_;
136 SignalErrorChanged errorChangedSignal_;
143 : Gtk::ScrolledWindow()
147 set_size_request (200, 80);
148 property_expand() =
true;
149 set_border_width (10);
150 set_shadow_type (Gtk::SHADOW_NONE);
153 set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
154 textLog_.set_editable (
false);
155 this->add (textLog_);
168 bool shallNotify = this->isError();
171 size_t lineCnt = max (0, textLog_.get_buffer()->get_line_count() - 1);
174 placeholder =
_Fmt{_(
"───════ %d preceding lines removed ════───\n")} % lineCnt;
175 textLog_.get_buffer()->set_text (placeholder);
178 errorChangedSignal_.emit (
false);
194 addEntry (
"WARNING: "+text, TAG_WARN);
207 bool shallNotify = not this->isError();
209 errorMarks_.emplace_back(
210 addEntry (
"ERROR: "+text, TAG_ERROR));
211 if (not expand.isExpanded())
215 errorChangedSignal_.emit (
true);
226 auto newBuff = Gtk::TextBuffer::create (textLog_.get_buffer()->get_tag_table());
227 vector<Entry> newMarks;
228 for (Entry&
entry : errorMarks_)
230 newBuff->insert (newBuff->end(),
"\n");
231 auto pos = newBuff->end();
233 newMarks.emplace_back(
235 newBuff->create_mark (pos,
true),
236 newBuff->create_mark (pos,
false)));
239 ,
entry.first->get_iter()
240 ,
entry.second->get_iter()
244 auto oldBuff = textLog_.get_buffer();
245 textLog_.set_buffer(newBuff);
246 swap (errorMarks_, newMarks);
249 int oldLines = oldBuff->get_line_count();
250 int newLines = newBuff->get_line_count();
251 ASSERT (oldLines >= newLines);
252 addInfo (
_Fmt{_(
"───════ %d old log lines removed ════───\n")} % (oldLines-newLines));
260 if (not isError())
return;
262 auto buff = textLog_.get_buffer();
263 for (Entry&
entry : errorMarks_)
265 auto begin =
entry.first->get_iter();
266 auto end =
entry.second->get_iter();
268 buff->remove_tag_by_name(uString{TAG_ERROR}, begin,end);
269 buff->apply_tag_by_name (uString{TAG_WARN}, begin,end);
272 errorChangedSignal_.emit (
false);
292 return not errorMarks_.empty();
299 return errorChangedSignal_;
322 auto buff = textLog_.get_buffer();
323 buff->insert (buff->end(),
"\n");
324 auto pos = buff->end();
326 auto begin = buff->create_mark (pos,
true);
327 auto after = buff->create_mark (pos,
false);
329 buff->insert_with_tag(pos, text, cuString{markupTagName});
331 buff->insert (pos, text);
332 textLog_.scroll_to (begin);
333 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.