Redirecting cout to a TextBuffer

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?


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