#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Text_Buffer.H>

enum {
    out_w = 500,
    out_h = 300,
    space = 10,
    win_h = out_h + 2 * space,
    win_w = out_w + 2 * space,
    font_size = 40
};

static void append_callback(void *user)
{
    Fl_Text_Buffer *buf = static_cast<Fl_Text_Buffer*>(user);
    buf->append("i am doing fine, it's all good\n");
}

int main()
{
    Fl_Window win(win_w, win_h, "output");

    Fl_Text_Buffer buf;

    Fl_Text_Display out(space, space, out_w, out_h);
    out.textsize(font_size);
    out.box(FL_FLAT_BOX);
    out.color(FL_BACKGROUND_COLOR);
    out.buffer(buf);

    buf.text("hello there\nhow are you?\nAlright\n");

    win.end();
    win.show();

    Fl::add_timeout(2.0, append_callback, &buf);

    return Fl::run();
}
