diff --git a/src/basic/basic.h b/src/basic/basic.h index 83b7345..d8bf62c 100644 --- a/src/basic/basic.h +++ b/src/basic/basic.h @@ -1034,8 +1034,11 @@ inline TempArena GetScratch(Arena *c1 = NULL, Arena *c2 = NULL) { struct Scratch { TempArena checkpoint; Scratch() { this->checkpoint = GetScratch(); } + Scratch(Arena *conflict) { this->checkpoint = GetScratch(conflict); } Scratch(Arena *c1, Arena *c2) { this->checkpoint = GetScratch(c1, c2); } + Scratch(Allocator conflict) { this->checkpoint = GetScratch((Arena *)conflict.object); } + Scratch(Allocator c1, Allocator c2) { this->checkpoint = GetScratch((Arena *)c1.object, (Arena *)c2.object); } ~Scratch() { EndTemp(checkpoint); } operator Arena *() { return checkpoint.arena; } operator Allocator() { return *checkpoint.arena; } diff --git a/src/basic/win32.cpp b/src/basic/win32.cpp index 8804736..926e076 100644 --- a/src/basic/win32.cpp +++ b/src/basic/win32.cpp @@ -270,7 +270,7 @@ String GetExePath(Allocator allocator) { } String GetExeDir(Allocator allocator) { - Scratch scratch; + Scratch scratch((Arena *)allocator.object); String path = GetExePath(scratch); path = ChopLastSlash(path); path = Copy(allocator, path); diff --git a/src/text_editor/commands_window.cpp b/src/text_editor/commands_window.cpp index 3f7ac86..a5c7c82 100644 --- a/src/text_editor/commands_window.cpp +++ b/src/text_editor/commands_window.cpp @@ -217,20 +217,20 @@ void MergeCarets(View *view, Range *mouse_selection_anchor) { Swap(&view->carets[first_caret_index], &view->carets[0]); } -String DebugViewList() { - Scratch scratch; +String DebugViewList(Allocator allocator) { + Scratch scratch((Arena *)allocator.object); Array strings = {scratch}; For(Views) { Buffer *buffer = GetBuffer(it.active_buffer); String string = Format(scratch, "view = %lld buffer = %lld name = %.*s", (long long)it.id.id, (long long)buffer->id.id, FmtString(buffer->name)); Add(&strings, string); } - String result = Merge(scratch, strings, "\n"); + String result = Merge(allocator, strings, "\n"); return result; } -String DebugWindowList() { - Scratch scratch; +String DebugWindowList(Allocator allocator) { + Scratch scratch((Arena *)allocator.object); Array strings = {scratch}; For(Windows) { View *view = GetActiveView(&it); @@ -244,7 +244,7 @@ String DebugWindowList() { Add(&strings, child_string); } } - String result = Merge(scratch, strings, "\n"); + String result = Merge(allocator, strings, "\n"); return result; } @@ -264,11 +264,11 @@ void ReplaceDebugData() { String16 string = ToString16(scratch, s); ReplaceText(buffer, GetRange(*buffer), string); - // String view_list = DebugViewList(); - // Append(buffer, ToString16(scratch, view_list)); + String view_list = DebugViewList(scratch); + Append(buffer, ToString16(scratch, view_list)); - // String window_list = DebugWindowList(); - // Append(buffer, ToString16(scratch, window_list)); + String window_list = DebugWindowList(scratch); + Append(buffer, ToString16(scratch, window_list)); } void ReplaceInfobarData() { @@ -292,7 +292,7 @@ void ReplaceInfobarData() { ReplaceText(buffer, GetEndAsRange(*buffer), L" |"); } - String s = Format(scratch, "Line %lld Column %lld", (long long)xy.line + 1ll, (long long)xy.col + 1ll); + String s = Format(scratch, " Line %lld Column %lld", (long long)xy.line + 1ll, (long long)xy.col + 1ll); String16 string = ToString16(scratch, s); ReplaceText(buffer, replace_range, string); Command_SelectRangeOneCursor(view, {}); diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index 1bb4f3c..56abd86 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -10,8 +10,9 @@ - open "asd/asd/asd/asd" - word completion - Colored strings -- open project files in folder and only show open views in Ctrl+P - Set scroll centered +- file lister +- Remove view children, replace with view history - font cache and on demand unicode loads diff --git a/src/text_editor/window.cpp b/src/text_editor/window.cpp index fe4cf36..ebdd8c0 100644 --- a/src/text_editor/window.cpp +++ b/src/text_editor/window.cpp @@ -120,14 +120,14 @@ void LayoutWindows() { int i = 0; Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex * 0.5)); Windows[i].document_rect = Windows[i].total_rect; - if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, FontCharSpacing); + if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)(10.f * DPIScale)); if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size); } { int i = 1; Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex)); Windows[i].document_rect = Windows[i].total_rect; - if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, FontCharSpacing); + if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)(10.f * DPIScale)); if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size); } {