diff --git a/src/backup/todo.txt b/src/backup/todo.txt index 200f520..c5e5f24 100644 --- a/src/backup/todo.txt +++ b/src/backup/todo.txt @@ -2,6 +2,8 @@ - From a user (novice) point of view, how does it look like? - ctrl + p like in VSCode (without special buffers) + - Move to the top so that it can be progressively expanded using coroutines by appending at the end + - Maybe 2 windows? - Guide on the first page for new users with links to configs, tutorials - Window, View, Buffer + flags design (or is completely new kind based approach needed for Windows/Views?) diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index 83ce1ce..b8664ad 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -647,36 +647,13 @@ void Command_SetWorkDir() { String CodeEndings[] = { ".c", ".cpp", ".h", ".hpp", ".py", ".lua", ".cxx", ".hxx", }; -void ListFilesRecursive(Buffer *buffer, String dir) { - Scratch scratch(buffer->line_starts.allocator); - for (FileIter it = IterateFiles(scratch, dir); IsValid(it); Advance(&it)) { - if (it.filename == ".git") { - continue; - } - if (it.is_directory) { - ListFilesRecursive(buffer, it.absolute_path); - } else { - bool match = false; - ForItem (ending, CodeEndings) { - if (EndsWith(it.absolute_path, ending)) { - match = true; - break; - } - } - if (match) RawAppendf(buffer, "%-80S || %S\n", it.filename, it.absolute_path); - } - } -} - void OpenCodeRecursive(String dir) { Scratch scratch; for (FileIter it = IterateFiles(scratch, dir); IsValid(it); Advance(&it)) { if (it.filename == ".git") { continue; } - if (it.filename == "SDL") { - continue; - } + if (it.is_directory) { OpenCodeRecursive(it.absolute_path); } else { diff --git a/src/text_editor/profiler.h b/src/text_editor/profiler.h index beb5304..a0f7a93 100644 --- a/src/text_editor/profiler.h +++ b/src/text_editor/profiler.h @@ -396,11 +396,12 @@ void EndProfileScope() { (uint64_t)GetTimeMicros() // timestamp in microseconds -- end of your timing block ); } - #define ProfileScope(name) ProfileScope_ PROFILE_SCOPE_VAR_##name(#name, sizeof(#name) - 1) - #define ProfileFunction() ProfileScope_ PROFILE_SCOPE_FUNCTION(__FUNCTION__, sizeof(__FUNCTION__) - 1) -struct ProfileScope_ { - ProfileScope_(const char *name, int len) { _BeginProfileScope(name, len); } - ~ProfileScope_() { EndProfileScope(); } + #define ProfileScopeD(name) ProfileScopeEx PROFILE_SCOPE_VAR_##name((name).data, (name).len) + #define ProfileScope(name) ProfileScopeEx PROFILE_SCOPE_VAR_##name(#name, sizeof(#name) - 1) + #define ProfileFunction() ProfileScopeEx PROFILE_SCOPE_FUNCTION(__FUNCTION__, sizeof(__FUNCTION__) - 1) +struct ProfileScopeEx { + ProfileScopeEx(const char *name, int len) { _BeginProfileScope(name, len); } + ~ProfileScopeEx() { EndProfileScope(); } }; #else #define ProfileScope(name) diff --git a/src/text_editor/text_editor.cpp b/src/text_editor/text_editor.cpp index 737be9c..99660e5 100644 --- a/src/text_editor/text_editor.cpp +++ b/src/text_editor/text_editor.cpp @@ -392,9 +392,8 @@ void OnCommand(Event event) { For (CommandFunctions) { if (it.trigger && MatchEvent(it.trigger, &event)) { - double start = GetTimeSeconds(); + ProfileScopeEx(it.name.data, (int)it.name.len); it.function(); - ReportConsolef("%S: %f", it.name, GetTimeSeconds() - start); LastExecutedCommand = it.function; } } diff --git a/src/text_editor/text_editor.h b/src/text_editor/text_editor.h index cc7dac9..8818c04 100644 --- a/src/text_editor/text_editor.h +++ b/src/text_editor/text_editor.h @@ -133,7 +133,6 @@ struct FunctionData { String name; Function *function; }; struct CommandData { String name; String binding; Function *function; struct Trigger *trigger; }; struct PFunctionData { String name; PFunction *function; }; - struct Register_Function { Register_Function(Array *functions, String name, Function *f) { int64_t pos = 0; diff --git a/src/text_editor/window_command.cpp b/src/text_editor/window_command.cpp index 14362fe..6dbb64b 100644 --- a/src/text_editor/window_command.cpp +++ b/src/text_editor/window_command.cpp @@ -75,6 +75,24 @@ void Command_ShowCommands() { SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer)); } RegisterCommand(Command_ShowCommands, "ctrl-shift-p"); +void Command_ShowDebugBufferList() { + if (ActiveWindowID == CommandBarWindowID && LastExecutedCommand == Command_ShowDebugBufferList) { + ActiveWindowID = LastActiveLayoutWindowID; + return; + } + + BSet command_bar = GetBSet(CommandBarWindowID); + command_bar.window->visible = true; + command_bar.window->eval_command = false; + ActiveWindowID = command_bar.window->id; + ResetBuffer(command_bar.buffer); + For(Buffers) { + RawAppendf(command_bar.buffer, "%-80S || %S\n", SkipToLastSlash(it->name), it->name); + } + command_bar.view->update_scroll = true; + SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer)); +} RegisterCommand(Command_ShowDebugBufferList, ""); + void Command_ShowBufferList() { if (ActiveWindowID == CommandBarWindowID && LastExecutedCommand == Command_ShowBufferList) { ActiveWindowID = LastActiveLayoutWindowID; @@ -87,6 +105,9 @@ void Command_ShowBufferList() { ActiveWindowID = command_bar.window->id; ResetBuffer(command_bar.buffer); For(Buffers) { + if (it->special) { + continue; + } RawAppendf(command_bar.buffer, "%-80S || %S\n", SkipToLastSlash(it->name), it->name); } command_bar.view->update_scroll = true;