Redirecting cout to a TextBuffer
- From: "Søren Hauberg" <hauberg gmail com>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: Redirecting cout to a TextBuffer
- Date: Sat, 10 May 2008 11:41:07 +0200
Hi all,
I'm using gtksourceviewmm as terminal-like widget, and I want to
redirect std::cout to this widget. Currently I'm doing something like
this in my constructor:
std::ostringstream outs;
std::cout.rdbuf (outs.rdbuf ());
and then I have a function 'update' that looks something like this
bool update (int timer_number)
{
// Update text output
buffer->insert (buffer->end(), outs.str ());
outs.str (""); // Empty stream
return true;
}
this function is then called on a reglar basis using a
'Glib::signal_timeout'. This works, but the timer has to have a very
high frequency if the output should appear smoothly. So, I'm not
really a fan of this approach. Can I somehow redirect 'std::cout'
directly to the TextBuffer?
Thanks,
Søren
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]