From 1e4e9fbccc6c40ef57a4652690e00608ef51fa9e Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Thu, 15 Jan 2026 23:14:39 +0100 Subject: [PATCH] Toying with the new plugin idea --- src/backup/todo.txt | 4 +- src/text_editor/buffer.cpp | 14 +- src/text_editor/commands.cpp | 214 +++++------------- src/text_editor/globals.cpp | 14 +- src/text_editor/plugin_build_window.cpp | 4 +- src/text_editor/plugin_command_window.cpp | 2 +- src/text_editor/plugin_debug_window.cpp | 2 +- src/text_editor/plugin_project_management.cpp | 15 ++ src/text_editor/plugin_project_management.h | 3 + src/text_editor/plugin_remedybg.cpp | 4 +- .../plugin_search_open_buffers.cpp | 92 ++++++++ src/text_editor/plugin_search_open_buffers.h | 1 + src/text_editor/plugin_search_window.cpp | 2 +- src/text_editor/plugin_status_window.cpp | 2 +- src/text_editor/text_editor.cpp | 9 +- 15 files changed, 200 insertions(+), 182 deletions(-) create mode 100644 src/text_editor/plugin_project_management.cpp create mode 100644 src/text_editor/plugin_project_management.h create mode 100644 src/text_editor/plugin_search_open_buffers.cpp create mode 100644 src/text_editor/plugin_search_open_buffers.h diff --git a/src/backup/todo.txt b/src/backup/todo.txt index 7e6611e..b98533c 100644 --- a/src/backup/todo.txt +++ b/src/backup/todo.txt @@ -11,11 +11,11 @@ - Maybe IPC for te.exe when it's already open and file arguments are passed it should perhaps open a buffer in current window?? Use session 4 -- Add <> <> template strings to Open (Then remove SEtWorkdirhere) +- Add <> <> template strings to Open (Then remove SEtWorkdirhere) - :Set Filename to name current buffer ??? :O and others like that!! - Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep) -- Make the equivalent of SearchProject but for cmds like !@git grep -n "@>" +- Make the equivalent of SearchOpenBuffers but for cmds like !@git grep -n "@>" - Add Bool variable - RegisterCommand should_appear_in_listing variable diff --git a/src/text_editor/buffer.cpp b/src/text_editor/buffer.cpp index 58899e2..b4fe72c 100644 --- a/src/text_editor/buffer.cpp +++ b/src/text_editor/buffer.cpp @@ -1408,24 +1408,26 @@ String GetUniqueBufferName(String working_dir, String prepend_name, String exten void InitBuffers() { Allocator sys_allocator = GetSystemAllocator(); Scratch scratch; - Buffer *null_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "logs", "")); + Buffer *null_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "logs", "")); null_buffer->special = true; View *null_view = CreateView(null_buffer->id); null_view->special = true; Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID); - TraceBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "trace")); + TraceBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "trace")); TraceBuffer->special = true; TraceBuffer->no_history = true; - GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "gc")); + GCInfoBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "gc")); GCInfoBuffer->special = true; GCInfoBuffer->no_history = true; - EventBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "events")); + EventBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "events")); EventBuffer->no_history = true; EventBuffer->special = true; - Buffer *search_project = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "search_project")); + Buffer *search_project = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "search_project")); search_project->no_history = true; search_project->special = true; - SearchProjectBufferID = search_project->id; +#ifdef PLUGIN_SEARCH_OPEN_BUFFERS + SearchOpenBuffersBufferID = search_project->id; +#endif } Int ConvertUTF8ToUTF16UnixLine(String string, char16_t *buffer, Int buffer_cap) { diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index b99126f..3204b64 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -501,17 +501,6 @@ bool IsOpenBoundary(char c) { return; \ } -void SetWorkDirHere(String dir) { - WorkDir = Intern(&GlobalInternTable, dir); - Scratch scratch; - For (Buffers) { - if (it->special) { - String name = SkipToLastSlash(it->name); - it->name = Intern(&GlobalInternTable, Format(scratch, "%S/%S", dir, name)); - } - } -} - void Set(String string) { String name = SkipIdent(&string); ExpectP(name.len != 0, "expected a variable name, instead got '%S'", string); @@ -558,9 +547,13 @@ void Set(String string) { if (name == "FontSize" || name == "PathToFont") { ReloadFont(PathToFont, (U32)FontSize); - } else if (name == "WorkDir") { - SetWorkDirHere(*var->string); } + +#ifdef PLUGIN_PROJECT_MANAGEMENT + if (name == "ProjectDirectory") { + SetProjectDirectory(*var->string); + } +#endif return; } @@ -703,7 +696,9 @@ ResolvedOpen ResolveOpen(Allocator alo, String path, ResolveOpenMeta meta) { result.kind = OpenKind_Goto; return result; } else { - String workspace_path = Format(alo, "%S/%S", WorkDir, path); + +#ifdef PLUGIN_PROJECT_MANAGEMENT + String workspace_path = Format(alo, "%S/%S", ProjectDirectory, path); bool existing_buffer = GetBuffer(workspace_path, NULL); if (existing_buffer || FileExists(workspace_path)) { result.existing_buffer = existing_buffer; @@ -711,6 +706,7 @@ ResolvedOpen ResolveOpen(Allocator alo, String path, ResolveOpenMeta meta) { result.kind = OpenKind_Goto; return result; } +#endif String rel_path = Format(alo, "%S/%S", GetMainDir(), path); existing_buffer = GetBuffer(rel_path, NULL); @@ -828,67 +824,6 @@ void CMD_ToggleFullscreen() { IsInFullscreen = !IsInFullscreen; } RegisterCommand(CMD_ToggleFullscreen, "f11"); -void CMD_SetWorkDirHere() { - BSet main = GetBSet(PrimaryWindowID); - SetWorkDirHere(GetDir(main.buffer)); -} RegisterCommand(CMD_SetWorkDirHere, "", "Sets work directory to the directory of the current buffer, it also renames couple special buffers to make them accomodate the new WorkDir"); - -void Coro_OpenCode(mco_coro *co) { - Array patterns = SplitWhitespace(CoCurr->arena, OpenCodePatterns); - Array exclude_patterns = SplitWhitespace(CoCurr->arena, OpenCodeExcludePatterns); - Array dirs = {CoCurr->arena}; - String *param_dir = (String *)CoCurr->user_ctx; - Add(&dirs, *param_dir); - for (int diri = 0; diri < dirs.len; diri += 1) { - for (FileIter it = IterateFiles(CoCurr->arena, dirs[diri]); IsValid(it); Advance(&it)) { - bool should_open = true; - if (!it.is_directory) { - should_open = false; - ForItem (ending, patterns) { - if (EndsWith(it.absolute_path, ending)) { - should_open = true; - break; - } - } - } - - ForItem (ending, exclude_patterns) { - if (EndsWith(it.absolute_path, ending)) { - should_open = false; - break; - } - } - - if (!should_open) { - continue; - } - - - if (it.is_directory) { - Add(&dirs, it.absolute_path); - } else { - BufferOpenFile(it.absolute_path); - } - - CoYield(co); - } - } -} - -void OpenCode(String dir) { - CoRemove("Coro_OpenCode"); - CoData *data = CoAdd(Coro_OpenCode); - String *string_param = AllocType(data->arena, String); - *string_param = Copy(data->arena, dir); - data->user_ctx = string_param; - data->dont_wait_until_resolved = true; - CoResume(data); -} - -void CMD_OpenCode() { - OpenCode(WorkDir); -} RegisterCommand(CMD_OpenCode, "", "Open all code files in current WorkDir, the code files are determined through NonCodePatterns_EndsWith config variable list"); - void CMD_KillProcess() { BSet main = GetBSet(PrimaryWindowID); KillProcess(main.view); @@ -1539,95 +1474,58 @@ void CMD_ReplaceAll() { CoResume(data); } RegisterCommand(CMD_ReplaceAll, "ctrl-shift-r", "Search and replace over the entire project, you need to select a text with format like this 'FindAnd@>ReplaceWith' and executing the command will change all occurences of FindAnd to ReplaceWith"); -struct SearchProjectParams { - String16 needle; - BufferID buffer; -}; - -void Coro_SearchProject(mco_coro *co) { - SearchProjectParams *param = (SearchProjectParams *)CoCurr->user_ctx; - - Array buffers = {CoCurr->arena}; - For (Buffers) { - Add(&buffers, it->id); - } - - ForItem (id, buffers) { - Buffer *it = GetBuffer(id, NULL); - if (it == NULL || it->special || it->is_dir || it->temp || it->dont_try_to_save_in_bulk_ops) { - continue; - } - - { - Scratch scratch; - Array occurences = FindAll(scratch, it, param->needle); - Buffer *out_buffer = GetBuffer(param->buffer); - ForItem (caret, occurences) { - Int pos = caret.range.min; - Int line = PosToLine(it, pos); - Range range = GetLineRangeWithoutNL(it, line); - Int column = pos - range.min; - String16 line_string = GetString(it, range); - String line_string8 = ToString(scratch, line_string); - RawAppendf(out_buffer, "%S ||> %S:%lld:%lld\n", line_string8, it->name, (long long)line + 1, (long long)column + 1); +void Coro_OpenCode(mco_coro *co) { + Array patterns = SplitWhitespace(CoCurr->arena, OpenCodePatterns); + Array exclude_patterns = SplitWhitespace(CoCurr->arena, OpenCodeExcludePatterns); + Array dirs = {CoCurr->arena}; + String *param_dir = (String *)CoCurr->user_ctx; + Add(&dirs, *param_dir); + for (int diri = 0; diri < dirs.len; diri += 1) { + for (FileIter it = IterateFiles(CoCurr->arena, dirs[diri]); IsValid(it); Advance(&it)) { + bool should_open = true; + if (!it.is_directory) { + should_open = false; + ForItem (ending, patterns) { + if (EndsWith(it.absolute_path, ending)) { + should_open = true; + break; + } + } } - } - CoYield(co); - } -} -void UpdateSearchProjectView() { - Scratch scratch; - BSet active = GetBSet(ActiveWindowID); - String16 line_string = GetLineStringWithoutNL(active.buffer, 0); - uint64_t hash = HashBytes(line_string.data, line_string.len * sizeof(char16_t)); - if (active.view->prev_search_line_hash != hash) { - active.view->prev_search_line_hash = hash; - if (line_string.len > 0) { - // @todo: do we reintroduce history here? like in fuzzy search view - Caret caret = active.view->carets[0]; - SelectEntireBuffer(active.view); - Replace(active.view, line_string); - Append(active.view, "\n", false); + ForItem (ending, exclude_patterns) { + if (EndsWith(it.absolute_path, ending)) { + should_open = false; + break; + } + } - CoRemove("Coro_SearchProject"); - CoData *dat = CoAdd(Coro_SearchProject); - SearchProjectParams *param = AllocType(dat->arena, SearchProjectParams); - param->needle = Copy16(dat->arena, line_string); - param->buffer = active.buffer->id; - dat->user_ctx = param; - dat->dont_wait_until_resolved = true; - CoResume(dat); + if (!should_open) { + continue; + } - active.view->carets[0] = caret; + + if (it.is_directory) { + Add(&dirs, it.absolute_path); + } else { + BufferOpenFile(it.absolute_path); + } + + CoYield(co); } } } -void CMD_SearchProject() { - BSet main = GetBSet(PrimaryWindowID); - String16 string = {}; - if (main.view->carets.len == 1 && GetSize(main.view->carets[0]) > 0) { - string = GetString(main.buffer, main.view->carets[0].range); - } +void OpenCode(String dir) { + CoRemove("Coro_OpenCode"); + CoData *data = CoAdd(Coro_OpenCode); + String *string_param = AllocType(data->arena, String); + *string_param = Copy(data->arena, dir); + data->user_ctx = string_param; + data->dont_wait_until_resolved = true; + CoResume(data); +} - NextActiveWindowID = main.window->id; - Buffer *search_project_buffer = GetBuffer(SearchProjectBufferID); - View *view = WindowOpenBufferView(main.window, search_project_buffer->name); - view->special = true; - AddCommand(&view->commands, "Open", "ctrl-q | enter | f12", []() { - BSet active = GetBSet(ActiveWindowID); - BSet main = GetBSet(PrimaryWindowID); - NextActiveWindowID = main.window->id; - String16 string = FetchFuzzyViewLoadLine(active.view); - main.window->active_goto_list = active.view->id; - main.window->goto_list_pos = active.view->carets[0].range.min; - Open(string); - }); - view->update_hook = UpdateSearchProjectView; - SelectRange(view, GetLineRangeWithoutNL(search_project_buffer, 0)); - if (string.len) { - Replace(view, string); - SelectEntireBuffer(view); - } -} RegisterCommand(CMD_SearchProject, "ctrl-shift-f", "Interactive search over the entire project in a new buffer view"); +void CMD_OpenCode() { + OpenCode(ProjectDirectory); +} RegisterCommand(CMD_OpenCode, "", "Open all code files in current ProjectDirectory, the code files are determined through NonCodePatterns_EndsWith config variable list"); diff --git a/src/text_editor/globals.cpp b/src/text_editor/globals.cpp index 36b88f1..a875b12 100644 --- a/src/text_editor/globals.cpp +++ b/src/text_editor/globals.cpp @@ -59,7 +59,10 @@ WindowID NullWindowID; BufferID BuildBufferID; #endif -BufferID SearchProjectBufferID; +#ifdef PLUGIN_SEARCH_OPEN_BUFFERS + BufferID SearchOpenBuffersBufferID; +#endif + BufferID GlobalConfigBufferID; WindowID NextActiveWindowID; @@ -180,7 +183,6 @@ RegisterVariable(Int, DrawScrollbar, 1); RegisterVariable(Int, IndentSize, 4); RegisterVariable(String, IndentKindWhichIsTabsOrSpaces, "spaces"); RegisterVariable(Int, FontSize, 15); -RegisterVariable(String, WorkDir, ""); RegisterVariable(String, PathToFont, ""); RegisterVariable(String, WindowsVCVarsPathToLoadDevEnviroment, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"); RegisterVariable(Float, UndoMergeTime, 0.3); @@ -190,7 +192,9 @@ RegisterVariable(String, OpenCodePatterns, ".c .h .cpp .hpp .cc .cxx .rs .go .zi RegisterVariable(String, OpenCodeExcludePatterns, ""); RegisterVariable(Int, TrimTrailingWhitespace, 1); -// BEGIN PLUGIN_REMEDYBG +// PROJECT_MANAGEMENT +RegisterVariable(String, ProjectDirectory, ""); + +// PLUGIN_REMEDYBG RegisterVariable(String, BinaryUnderDebug, "build/te.exe"); -RegisterVariable(String, RemedyBGPath, "remedybg.exe"); -// END PLUGIN_REMEDYBG \ No newline at end of file +RegisterVariable(String, RemedyBGPath, "remedybg.exe"); \ No newline at end of file diff --git a/src/text_editor/plugin_build_window.cpp b/src/text_editor/plugin_build_window.cpp index 40f8586..48bf08d 100644 --- a/src/text_editor/plugin_build_window.cpp +++ b/src/text_editor/plugin_build_window.cpp @@ -1,7 +1,7 @@ void InitBuildWindow() { Window *window = CreateWind(); BuildWindowID = window->id; - Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "build")); + Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(ProjectDirectory, "build")); buffer->special = true; buffer->no_history = true; BuildBufferID = buffer->id; @@ -32,7 +32,7 @@ BSet ExecBuild(String cmd) { BSet main = GetBSet(PrimaryWindowID); SelectRange(build.view, Range{}); ResetBuffer(build.buffer); - Exec(build.view->id, true, cmd, WorkDir); + Exec(build.view->id, true, cmd, ProjectDirectory); main.window->active_goto_list = build.view->id; main.window->goto_list_pos = 0; return build; diff --git a/src/text_editor/plugin_command_window.cpp b/src/text_editor/plugin_command_window.cpp index 362d388..df0ec3f 100644 --- a/src/text_editor/plugin_command_window.cpp +++ b/src/text_editor/plugin_command_window.cpp @@ -79,7 +79,7 @@ void LayoutCommandWindow(Rect2I *rect, int16_t wx, int16_t wy) { void InitCommandWindow() { Window *window = CreateWind(); CommandWindowID = window->id; - Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "command_bar")); + Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(ProjectDirectory, "command_bar")); buffer->special = true; buffer->no_history = true; View *view = CreateView(buffer->id); diff --git a/src/text_editor/plugin_debug_window.cpp b/src/text_editor/plugin_debug_window.cpp index 0a740b8..b2891e5 100644 --- a/src/text_editor/plugin_debug_window.cpp +++ b/src/text_editor/plugin_debug_window.cpp @@ -8,7 +8,7 @@ void InitDebugWindow() { window->primary = false; window->jump_history = false; - Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "debug")); + Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(ProjectDirectory, "debug")); DebugBufferID = buffer->id; buffer->no_history = true; buffer->special = true; diff --git a/src/text_editor/plugin_project_management.cpp b/src/text_editor/plugin_project_management.cpp new file mode 100644 index 0000000..9d0507c --- /dev/null +++ b/src/text_editor/plugin_project_management.cpp @@ -0,0 +1,15 @@ +void SetProjectDirectory(String dir) { + ProjectDirectory = Intern(&GlobalInternTable, dir); + Scratch scratch; + For (Buffers) { + if (it->special) { + String name = SkipToLastSlash(it->name); + it->name = Intern(&GlobalInternTable, Format(scratch, "%S/%S", dir, name)); + } + } +} + +void CMD_SetProjectDirectoryHere() { + BSet main = GetBSet(PrimaryWindowID); + SetProjectDirectory(GetDir(main.buffer)); +} RegisterCommand(CMD_SetProjectDirectoryHere, "", "Sets work directory to the directory of the current buffer, it also renames couple special buffers to make them accomodate the new ProjectDirectory"); diff --git a/src/text_editor/plugin_project_management.h b/src/text_editor/plugin_project_management.h new file mode 100644 index 0000000..1fbda5a --- /dev/null +++ b/src/text_editor/plugin_project_management.h @@ -0,0 +1,3 @@ +#define PLUGIN_PROJECT_MANAGEMENT + +void SetProjectDirectory(String name); \ No newline at end of file diff --git a/src/text_editor/plugin_remedybg.cpp b/src/text_editor/plugin_remedybg.cpp index 643c7da..5726c7b 100644 --- a/src/text_editor/plugin_remedybg.cpp +++ b/src/text_editor/plugin_remedybg.cpp @@ -2135,9 +2135,9 @@ bool RDBG_InitConnection() { MemoryZero(RDBG_Ctx.last_error, sizeof(RDBG_Ctx.last_error)); rdbg_Id cfg_id; - char *exe = Format(scratch, "%S/%S", WorkDir, BinaryUnderDebug).data; + char *exe = Format(scratch, "%S/%S", ProjectDirectory, BinaryUnderDebug).data; char *args = NULL; - char *work_dir = WorkDir.data; + char *work_dir = ProjectDirectory.data; char *env = NULL; AddSessionConfig(&RDBG_Ctx, exe, args, work_dir, env, true, true, &res, &cfg_id); if (ContextHadError(&RDBG_Ctx)) { diff --git a/src/text_editor/plugin_search_open_buffers.cpp b/src/text_editor/plugin_search_open_buffers.cpp new file mode 100644 index 0000000..11c44c6 --- /dev/null +++ b/src/text_editor/plugin_search_open_buffers.cpp @@ -0,0 +1,92 @@ +struct SearchOpenBuffersParams { + String16 needle; + BufferID buffer; +}; + +void Coro_SearchOpenBuffers(mco_coro *co) { + SearchOpenBuffersParams *param = (SearchOpenBuffersParams *)CoCurr->user_ctx; + + Array buffers = {CoCurr->arena}; + For (Buffers) { + Add(&buffers, it->id); + } + + ForItem (id, buffers) { + Buffer *it = GetBuffer(id, NULL); + if (it == NULL || it->special || it->is_dir || it->temp || it->dont_try_to_save_in_bulk_ops) { + continue; + } + + { + Scratch scratch; + Array occurences = FindAll(scratch, it, param->needle); + Buffer *out_buffer = GetBuffer(param->buffer); + ForItem (caret, occurences) { + Int pos = caret.range.min; + Int line = PosToLine(it, pos); + Range range = GetLineRangeWithoutNL(it, line); + Int column = pos - range.min; + String16 line_string = GetString(it, range); + String line_string8 = ToString(scratch, line_string); + RawAppendf(out_buffer, "%S ||> %S:%lld:%lld\n", line_string8, it->name, (long long)line + 1, (long long)column + 1); + } + } + CoYield(co); + } +} + +void UpdateSearchOpenBuffersView() { + Scratch scratch; + BSet active = GetBSet(ActiveWindowID); + String16 line_string = GetLineStringWithoutNL(active.buffer, 0); + uint64_t hash = HashBytes(line_string.data, line_string.len * sizeof(char16_t)); + if (active.view->prev_search_line_hash != hash) { + active.view->prev_search_line_hash = hash; + if (line_string.len > 0) { + // @todo: do we reintroduce history here? like in fuzzy search view + Caret caret = active.view->carets[0]; + SelectEntireBuffer(active.view); + Replace(active.view, line_string); + Append(active.view, "\n", false); + + CoRemove("Coro_SearchOpenBuffers"); + CoData *dat = CoAdd(Coro_SearchOpenBuffers); + SearchOpenBuffersParams *param = AllocType(dat->arena, SearchOpenBuffersParams); + param->needle = Copy16(dat->arena, line_string); + param->buffer = active.buffer->id; + dat->user_ctx = param; + dat->dont_wait_until_resolved = true; + CoResume(dat); + + active.view->carets[0] = caret; + } + } +} + +void CMD_SearchOpenBuffers() { + BSet main = GetBSet(PrimaryWindowID); + String16 string = {}; + if (main.view->carets.len == 1 && GetSize(main.view->carets[0]) > 0) { + string = GetString(main.buffer, main.view->carets[0].range); + } + + NextActiveWindowID = main.window->id; + Buffer *search_project_buffer = GetBuffer(SearchOpenBuffersBufferID); + View *view = WindowOpenBufferView(main.window, search_project_buffer->name); + view->special = true; + AddCommand(&view->commands, "Open", "ctrl-q | enter | f12", []() { + BSet active = GetBSet(ActiveWindowID); + BSet main = GetBSet(PrimaryWindowID); + NextActiveWindowID = main.window->id; + String16 string = FetchFuzzyViewLoadLine(active.view); + main.window->active_goto_list = active.view->id; + main.window->goto_list_pos = active.view->carets[0].range.min; + Open(string); + }); + view->update_hook = UpdateSearchOpenBuffersView; + SelectRange(view, GetLineRangeWithoutNL(search_project_buffer, 0)); + if (string.len) { + Replace(view, string); + SelectEntireBuffer(view); + } +} RegisterCommand(CMD_SearchOpenBuffers, "ctrl-shift-f", "Interactive search over the entire project in a new buffer view"); diff --git a/src/text_editor/plugin_search_open_buffers.h b/src/text_editor/plugin_search_open_buffers.h new file mode 100644 index 0000000..f0ee9c5 --- /dev/null +++ b/src/text_editor/plugin_search_open_buffers.h @@ -0,0 +1 @@ +#define PLUGIN_SEARCH_OPEN_BUFFERS diff --git a/src/text_editor/plugin_search_window.cpp b/src/text_editor/plugin_search_window.cpp index 5d7643b..4c019f9 100644 --- a/src/text_editor/plugin_search_window.cpp +++ b/src/text_editor/plugin_search_window.cpp @@ -58,7 +58,7 @@ void CMD_ToggleSearchWordBoundary() { void InitSearchWindow() { Window *window = CreateWind(); SearchWindowID = window->id; - Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "search")); + Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(ProjectDirectory, "search")); buffer->special = true; SearchBufferID = buffer->id; View *view = CreateView(buffer->id); diff --git a/src/text_editor/plugin_status_window.cpp b/src/text_editor/plugin_status_window.cpp index 98c69b9..89fe2f6 100644 --- a/src/text_editor/plugin_status_window.cpp +++ b/src/text_editor/plugin_status_window.cpp @@ -1,7 +1,7 @@ void InitStatusWindow() { Window *window = CreateWind(); StatusWindowID = window->id; - Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "status_bar")); + Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(ProjectDirectory, "status_bar")); buffer->special = true; View *view = CreateView(buffer->id); view->special = true; diff --git a/src/text_editor/text_editor.cpp b/src/text_editor/text_editor.cpp index b3dfa11..bdfec60 100644 --- a/src/text_editor/text_editor.cpp +++ b/src/text_editor/text_editor.cpp @@ -20,6 +20,8 @@ #include "plugin_debug_window.h" #include "plugin_status_window.h" #include "plugin_build_window.h" +#include "plugin_project_management.h" +#include "plugin_search_open_buffers.h" #if OS_WINDOWS #include "plugin_remedybg.h" #endif @@ -37,7 +39,9 @@ #include "draw.cpp" #include "test/tests.cpp" +#include "commands_search_open_buffers.cpp" #include "commands_clipboard.cpp" +#include "plugin_project_management.cpp" #include "plugin_command_window.cpp" #include "plugin_search_window.cpp" #include "plugin_status_window.cpp" @@ -718,7 +722,7 @@ void Windows_SetupVCVarsall(mco_coro *co) { View *view = NULL; { Scratch scratch; - String working_dir = WorkDir; + String working_dir = ProjectDirectory; String buffer_name = GetUniqueBufferName(working_dir, "vcvarsall-"); String cmd = Format(scratch, "\"%S\" && set", WindowsVCVarsPathToLoadDevEnviroment); view = ExecHidden(buffer_name, cmd, working_dir); @@ -836,7 +840,7 @@ int main(int argc, char **argv) } #endif - WorkDir = GetWorkingDir(Perm); + ProjectDirectory = GetWorkingDir(Perm); { String sdl_config_path = SDL_GetPrefPath("krzosa", "text_editor"); if (sdl_config_path.len && sdl_config_path.data[sdl_config_path.len - 1] == '\\') { @@ -939,7 +943,6 @@ int main(int argc, char **argv) } } - ReportConsolef(":Set WorkDir '%S'", WorkDir); if (Testing) InitTests(); #if OS_WINDOWS CoRemove("Windows_SetupVCVarsall");