From 507bd578540cc8182a9054777e90cd9ba68704b0 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Fri, 9 Jan 2026 23:07:47 +0100 Subject: [PATCH] Continuing hook refactor --- src/text_editor/commands.cpp | 1 - src/text_editor/text_editor.h | 24 +++++++++--------------- src/text_editor/window_command.cpp | 1 - 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index 55fd3ba..1395172 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -1609,7 +1609,6 @@ void CMD_SearchProject(HookParam param) { Buffer *search_project_buffer = GetBuffer(SearchProjectBufferID); View *view = WindowOpenBufferView(main.window, search_project_buffer->name); view->special = true; - view->kind = ViewKind_ActiveSearch; AddCommand(&view->hooks, "Open", "ctrl-q | enter | f12", [](HookParam param) { BSet active = GetBSet(ActiveWindowID); BSet main = GetBSet(PrimaryWindowID); diff --git a/src/text_editor/text_editor.h b/src/text_editor/text_editor.h index 774b284..ae94877 100644 --- a/src/text_editor/text_editor.h +++ b/src/text_editor/text_editor.h @@ -64,22 +64,23 @@ enum HookKind { HookKind_AppUpdate, HookKind_AppQuit, + // Should we have commands like PostCommand, PreCommand? what would be the purpose? HookKind_Command, - HookKind_BeforeLayoutWindow, - HookKind_LayoutWindow, - HookKind_AfterLayoutWindow, - HookKind_BeforeRenderWindow, - HookKind_HandleRenderWindow, - HookKind_AfterRenderWindow, + // Currently we are only basically allowing control over non-layouted windows. + // How can this be expanded? + // - Changing the layout algorithm: this seems like a decent one + // - What beside that? + HookKind_LayoutWindow, + HookKind_RenderWindow HookKind_BeforeBufferSave, - HookKind_HandleBufferSave, + HookKind_BufferSave, HookKind_AfterBufferSave, HookKind_BeforeBufferOpen, - HookKind_HandleBufferOpen, + HookKind_BufferOpen, HookKind_AfterBufferOpen, HookKind_ViewUpdate, @@ -108,16 +109,9 @@ struct Hook { struct Trigger *trigger; }; -enum ViewKind { - ViewKind_Normal, - ViewKind_FuzzySearch, - ViewKind_ActiveSearch, -}; - struct View { ViewID id; BufferID active_buffer; - ViewKind kind; Vec2I scroll; Array carets; diff --git a/src/text_editor/window_command.cpp b/src/text_editor/window_command.cpp index ceccd55..9daef48 100644 --- a/src/text_editor/window_command.cpp +++ b/src/text_editor/window_command.cpp @@ -209,7 +209,6 @@ void UpdateFuzzySearchView(HookParam param) { } void SetFuzzy(View *view) { - view->kind = ViewKind_FuzzySearch; AddCommand(&view->hooks, "Open", "ctrl-q | enter | f12", [](HookParam){ BSet active = GetBSet(ActiveWindowID); BSet main = GetBSet(PrimaryWindowID);