#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Text_Editor.H>

enum {
    input_w = 1000,
    input_h = 1000,
    font_size = 40
};

static void print_callback(Fl_Widget *w, void *user)
{
    Fl_Text_Editor *editor = static_cast<Fl_Text_Editor*>(user);
    char* str = editor->buffer()->text();
    fputs(str, stdout);
    fflush(stdout);
    free(str);
    editor->take_focus();
}

int main(int argc, char **argv)
{
    Fl_Window *win = new Fl_Window(input_w, input_h, "input demo");

    Fl_Text_Buffer *buf = new Fl_Text_Buffer;
    Fl_Text_Editor *ed = new Fl_Text_Editor(0, 0, input_w, input_h);
    ed->buffer(buf);
    ed->textsize(font_size);
    ed->labelsize(font_size);
    ed->textcolor(FL_GRAY);
    ed->color(FL_BLACK);
    ed->cursor_color(FL_GRAY);

    ed->callback(print_callback, (void*)ed);

    win->end();
    win->show();
    return Fl::run();
}
