112 lines
2.7 KiB
C
112 lines
2.7 KiB
C
// clang-format off
|
|
struct BufferID { Int id; };
|
|
struct ViewID { Int id; };
|
|
struct WindowID { Int id; };
|
|
|
|
union Range { struct { Int min; Int max; }; Int e[2]; };
|
|
struct Caret { union { Range range; Int pos[2]; }; Int ifront;};
|
|
struct XY { Int col; Int line; };
|
|
// clang-format on
|
|
|
|
struct Edit {
|
|
Range range;
|
|
String16 string;
|
|
};
|
|
|
|
// @idea: maybe redo tree?
|
|
struct HistoryEntry {
|
|
Array<Edit> edits;
|
|
Array<Caret> carets;
|
|
};
|
|
|
|
// @todo: gap buffer to improve speed of inserting on big files with only one cursor?
|
|
struct Buffer {
|
|
BufferID id;
|
|
String name;
|
|
Int change_id;
|
|
|
|
union {
|
|
U16 *data;
|
|
wchar_t *str;
|
|
};
|
|
Int len;
|
|
Int cap;
|
|
Array<Int> line_starts;
|
|
|
|
Array<HistoryEntry> undo_stack;
|
|
Array<HistoryEntry> redo_stack;
|
|
int debug_edit_phase;
|
|
bool no_history;
|
|
bool dirty;
|
|
};
|
|
|
|
struct View {
|
|
ViewID id;
|
|
BufferID active_buffer;
|
|
Vec2I scroll;
|
|
Array<Caret> carets;
|
|
|
|
// window | view
|
|
Range selection_anchor;
|
|
Caret main_caret_on_begin_frame;
|
|
bool update_scroll;
|
|
};
|
|
|
|
struct Window {
|
|
WindowID id;
|
|
ViewID active_view;
|
|
Array<ViewID> views;
|
|
|
|
Rect2I total_rect;
|
|
Rect2I tabs_rect;
|
|
Rect2I scrollbar_rect;
|
|
Rect2I line_numbers_rect;
|
|
Rect2I document_rect;
|
|
|
|
double mouse_scroller_offset;
|
|
int z;
|
|
|
|
struct {
|
|
bool mouse_selecting_scrollbar : 1;
|
|
bool mouse_selecting : 1;
|
|
bool mouse_in_scrollbar : 1;
|
|
|
|
bool draw_scrollbar : 1;
|
|
bool draw_line_numbers : 1;
|
|
bool draw_tabs : 1;
|
|
bool visible : 1;
|
|
|
|
bool fuzzy_search : 1; // @todo: consider moving this to view and introducing view commands
|
|
bool execute_line : 1;
|
|
bool invisible_when_inactive : 1;
|
|
bool dont_save_in_active_window_history : 1;
|
|
bool deactivate_on_escape : 1;
|
|
};
|
|
};
|
|
|
|
struct Scroller {
|
|
Rect2 rect;
|
|
double begin;
|
|
double end;
|
|
Int line_count;
|
|
};
|
|
|
|
Int FrameID;
|
|
String WorkingDir;
|
|
String ConfigDir;
|
|
String ExeDir;
|
|
Arena Perm;
|
|
float DPIScale = 1.0f;
|
|
|
|
String16 EvalString(Allocator allocator, String16 string16);
|
|
Rect2I GetVisibleCells(Window *window);
|
|
void AfterEdit(View *view, Array<Edit> edits);
|
|
Scroller ComputeScrollerRect(Window *window);
|
|
void Command_EvalLua(View *view, String16 string);
|
|
void MergeCarets(View *view, Range *mouse_selection_anchor = NULL);
|
|
inline BufferID AllocBufferID();
|
|
void Command_SelectEntireBuffer(View *view);
|
|
void Command_Replace(View *view, String16 string);
|
|
|
|
void ReportErrorf(const char *fmt, ...);
|
|
void ReportWarningf(const char *fmt, ...); |