Hey all,

I'm working on a scripting console for my game engine and I've run into a problem getting everything from the real console to come up on my fake one. What I need to do is have some kind of buffered connection (preferably into a string or something similar) between stdout and my own acceptString function (ideally sending a string for every line that comes in from stdout). The solution I have to this right now works a little but not completely. Here's the python code that does it:
Code:
class RedirectStdout:
    def __init__(self):
        self.oldstdout = sys.stdout
        
    def __del__(self):
        sys.stdout = self.oldstdout
        
    def write(self, s):
        if s.strip() != "":
            self.oldstdout.write(s + "\n")
            gfxServer.appendString(s)

sys.stdout = RedirectStdout()
The problem with this is that it only redirects some of the python output. What I need is something similar in C++ that will work at a lower level and hopefully catch all of the output from stdout.