Re: Redirecting cout to a TextBuffer



I guess you should set up a watch on stdout using Glib::IOChannel. I'm not sure how to do this for C++ streams since the IOChannel API, while wrapped into C++, still operates on C FDs only, but this would solve the problem.

2008/5/10 Søren Hauberg <hauberg gmail com>:
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
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]