struct Window;
struct WindowID { Int id; Window *o; };

struct Window {
    WindowID id;
    ViewID active_view;

    Rect2I total_rect;
    Rect2I document_rect;
    Rect2I scrollbar_rect;
    Rect2I line_numbers_rect;
    Rect2I resizer_rect;

    Font  *font;
    double mouse_scroller_offset;
    int    z;
    double weight;
    Int status_bar_last_buffer_change_id;

    Array<GotoCrumb> goto_history;
    Array<GotoCrumb> goto_redo;

    ViewID active_goto_list;
    Int goto_list_pos;

    struct {
        bool draw_scrollbar : 1;
        bool draw_line_numbers : 1;
        bool draw_darker : 1;
        bool draw_line_highlight : 1;
        bool visible : 1;
        bool layout : 1;
        bool close : 1;
        bool sync_visibility_with_focus : 1;
        bool lose_focus_on_escape : 1;
        bool jump_history : 1;
        bool eval_command : 1;
    };
};

struct Scroller {
    Rect2  rect;
    double begin;
    double end;
    Int    line_count;
};

inline bool operator==(WindowID a, WindowID b) { return a.id == b.id; }
inline bool operator!=(WindowID a, WindowID b) { return a.id != b.id; }
Rect2I GetVisibleCells(Window *window);
Window *CreateWind();

void CommandWindowLayout(Rect2I *rect, Int wx, Int wy);
void CommandWindowInit();

void SearchWindowLayout(Rect2I *rect, Int wx, Int wy);
void SearchWindowInit();

void StatusWindowInit();
void StatusWindowLayout(Rect2I *rect, Int wx, Int wy);

void DebugWindowInit();
void DebugWindowLayout(Rect2I *rect, Int wx, Int wy);
