struct View;
struct ViewID { Int id; View *o; };

typedef void Function();
struct FunctionData { String name; Function *function; };
struct CommandData { String name; String binding; Function *function; struct Trigger *trigger; };

struct View {
    ViewID       id;
    BufferID     active_buffer;
    Vec2I        scroll;
    Array<Caret> carets;

    // window | view
    Caret main_caret_on_begin_frame;
    bool  update_scroll;

    String hook_cmd;
    Array<CommandData> hooks;
    String16 prev_search_line;
    struct {
        unsigned close : 1;
        unsigned special : 1;
    };
};

struct GotoCrumb {
    ViewID view_id;
    Caret caret;
    double time;
};

API ViewID AllocViewID(View *view);
API View  *CreateView(BufferID active_buffer);
API View  *FindView(ViewID view_id, View *default_view = NULL);
API View  *FindView(BufferID buffer_id, View *default_view = NULL);
API View  *FindView(String name, View *default_view = NULL);
API View  *GetView(ViewID id);
API View  *OpenBufferView(String name);
API bool   ViewIsCrumb(ViewID view_id);
API bool   ViewIsReferenced(ViewID view);
