Add debug references to ids
This commit is contained in:
@@ -29,9 +29,9 @@ Window *ScrollbarSelected = NULL;
|
|||||||
Window *DocumentSelected = NULL;
|
Window *DocumentSelected = NULL;
|
||||||
Range DocumentRangeAnchor;
|
Range DocumentRangeAnchor;
|
||||||
|
|
||||||
inline ViewID AllocViewID() { return {ViewIDs.id++}; }
|
inline ViewID AllocViewID(View *view) { return {ViewIDs.id++, view}; }
|
||||||
inline WindowID AllocWindowID() { return {WindowIDs.id++}; }
|
inline WindowID AllocWindowID(Window *window) { return {WindowIDs.id++, window}; }
|
||||||
inline BufferID AllocBufferID() { return {BufferIDs.id++}; }
|
inline BufferID AllocBufferID(Buffer *buffer) { return {BufferIDs.id++, buffer}; }
|
||||||
|
|
||||||
inline Window *GetWindow(WindowID id) {
|
inline Window *GetWindow(WindowID id) {
|
||||||
For(Windows) if (it.id.id == id.id) return ⁢
|
For(Windows) if (it.id.id == id.id) return ⁢
|
||||||
@@ -65,7 +65,7 @@ inline Window *GetActiveWindow() { return GetWindow(ActiveWindow); }
|
|||||||
inline View *GetActiveView(Window *window) { return GetView(window->active_view); }
|
inline View *GetActiveView(Window *window) { return GetView(window->active_view); }
|
||||||
|
|
||||||
void InitBuffer(Allocator allocator, Buffer *buffer, String name, Int size = 4096) {
|
void InitBuffer(Allocator allocator, Buffer *buffer, String name, Int size = 4096) {
|
||||||
buffer->id = AllocBufferID();
|
buffer->id = AllocBufferID(buffer);
|
||||||
buffer->name = name;
|
buffer->name = name;
|
||||||
buffer->cap = size;
|
buffer->cap = size;
|
||||||
buffer->data = AllocArray(allocator, U16, buffer->cap);
|
buffer->data = AllocArray(allocator, U16, buffer->cap);
|
||||||
@@ -97,13 +97,13 @@ Window *CreateWindow() {
|
|||||||
w->visible = true;
|
w->visible = true;
|
||||||
w->draw_scrollbar = StyleDrawScrollbar;
|
w->draw_scrollbar = StyleDrawScrollbar;
|
||||||
w->draw_line_numbers = StyleDrawLineNumbers;
|
w->draw_line_numbers = StyleDrawLineNumbers;
|
||||||
w->id = AllocWindowID();
|
w->id = AllocWindowID(w);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
View *CreateView(BufferID active_buffer) {
|
View *CreateView(BufferID active_buffer) {
|
||||||
View *w = Alloc(&Views);
|
View *w = Alloc(&Views);
|
||||||
w->id = AllocViewID();
|
w->id = AllocViewID(w);
|
||||||
w->active_buffer = active_buffer;
|
w->active_buffer = active_buffer;
|
||||||
Add(&w->carets, {0, 0});
|
Add(&w->carets, {0, 0});
|
||||||
return w;
|
return w;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
struct BufferID { Int id; };
|
struct Buffer; struct Window; struct View;
|
||||||
struct ViewID { Int id; };
|
struct BufferID { Int id; Buffer *d; };
|
||||||
struct WindowID { Int id; };
|
struct ViewID { Int id; View *d; };
|
||||||
|
struct WindowID { Int id; Window *d; }; // @warning refs are for debug !!!
|
||||||
|
|
||||||
union Range { struct { Int min; Int max; }; Int e[2]; };
|
union Range { struct { Int min; Int max; }; Int e[2]; };
|
||||||
struct Caret { union { Range range; Int pos[2]; }; Int ifront;};
|
struct Caret { union { Range range; Int pos[2]; }; Int ifront;};
|
||||||
@@ -112,18 +113,17 @@ String ExeDir;
|
|||||||
Arena Perm;
|
Arena Perm;
|
||||||
float DPIScale = 1.0f;
|
float DPIScale = 1.0f;
|
||||||
|
|
||||||
String16 EvalString(Allocator allocator, String16 string16);
|
String16 EvalString(Allocator allocator, String16 string16);
|
||||||
Rect2I GetVisibleCells(Window *window);
|
Rect2I GetVisibleCells(Window *window);
|
||||||
void AfterEdit(View *view, Array<Edit> edits);
|
void AfterEdit(View *view, Array<Edit> edits);
|
||||||
Scroller ComputeScrollerRect(Window *window);
|
Scroller ComputeScrollerRect(Window *window);
|
||||||
void Command_EvalLua(View *view, String16 string);
|
void Command_EvalLua(View *view, String16 string);
|
||||||
void MergeCarets(View *view, Range *mouse_selection_anchor = NULL);
|
void MergeCarets(View *view, Range *mouse_selection_anchor = NULL);
|
||||||
inline BufferID AllocBufferID();
|
void Command_SelectEntireBuffer(View *view);
|
||||||
void Command_SelectEntireBuffer(View *view);
|
void Command_Replace(View *view, String16 string);
|
||||||
void Command_Replace(View *view, String16 string);
|
void Open(String path);
|
||||||
void Open(String path);
|
void Open(String16 path);
|
||||||
void Open(String16 path);
|
void UpdateScroll(Window *window, bool update_caret_scrolling);
|
||||||
void UpdateScroll(Window *window, bool update_caret_scrolling);
|
|
||||||
|
|
||||||
void ReportErrorf(const char *fmt, ...);
|
void ReportErrorf(const char *fmt, ...);
|
||||||
void ReportWarningf(const char *fmt, ...);
|
void ReportWarningf(const char *fmt, ...);
|
||||||
Reference in New Issue
Block a user