Hi All,

I'm trying to use a pipe and execute a command such that the stdout from it is 
displayed in a text display box.  I've read Erco's tutorial on this but it is 
unix based and this is for Win32.

The problem -as anyone would likely guess- is the failure to redraw the text 
display in real-time.  Instead the data is displayed after the command is 
executed.

I've tried fiddling with Fl:check() to no avail.  Anyways, some sample code is 
below.  This function is called with a command and then the results pipe out 
into db_log which is a Fl_Text_Display object.

std::string NewProjectWindow::exec(char* cmd)
{
    FILE* pipe = _popen(cmd, "r");
    Fl_Text_Buffer *buff = new Fl_Text_Buffer();

    if (!pipe)
        return "ERROR";
    char buffer[128];
    std::string result = "";
    while(!feof(pipe)) {

        if(fgets(buffer, 128, pipe) != NULL)
        {
            result += buffer;
            buff->text(result.c_str());
            this->db_log->buffer(buff);
            this->db_log->redraw();
            Fl::check();
        }
    }
    _pclose(pipe);
    return result;
}

Any help/pointers are greatly appreciated. :)

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to