Make disabling plugins easier

This commit is contained in:
KK
2026-07-04 08:51:41 +02:00
parent 46d758c191
commit e40d8773c4
16 changed files with 35 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
#if PLUGIN_BASIC_COMMANDS
void CMD_Redo() { void CMD_Redo() {
BSet active = GetBSet(ActiveWindowID); BSet active = GetBSet(ActiveWindowID);
RedoEdit(active.buffer, &active.view->carets); RedoEdit(active.buffer, &active.view->carets);
@@ -270,4 +271,5 @@ void CMD_PlayMacro() {
} }
For (MacroPlayback) Add(&EventPlayback, it); For (MacroPlayback) Add(&EventPlayback, it);
} RegisterCommand(CMD_PlayMacro, "alt-m", "Start playing back a macro recording"); } RegisterCommand(CMD_PlayMacro, "alt-m", "Start playing back a macro recording");
#endif

View File

@@ -1,3 +1,4 @@
#if PLUGIN_BUILD_WINDOW
WindowID BuildWindowID; WindowID BuildWindowID;
ViewID BuildViewID; ViewID BuildViewID;
BufferID BuildBufferID; BufferID BuildBufferID;
@@ -90,3 +91,4 @@ void CMD_ShowBuildWindow() {
main.window->visible = false; main.window->visible = false;
} }
} RegisterCommand(CMD_ShowBuildWindow, "ctrl-grave", "Toggles visibility of the build window"); } RegisterCommand(CMD_ShowBuildWindow, "ctrl-grave", "Toggles visibility of the build window");
#endif

View File

@@ -1,3 +1,4 @@
#if PLUGIN_COMMAND_RUNNER_WINDOW
WindowID CommandRunnerWindowID; WindowID CommandRunnerWindowID;
void CMD_ShowCommandRunner() { void CMD_ShowCommandRunner() {
@@ -65,3 +66,4 @@ void InitCommandRunnerWindow() {
window->jump_history = false; window->jump_history = false;
AddCommand(&view->commands, "Open", OpenKeySet, CMD_OpenForRunnerWindow); AddCommand(&view->commands, "Open", OpenKeySet, CMD_OpenForRunnerWindow);
} }
#endif // PLUGIN_COMMAND_RUNNER_WINDOW

View File

@@ -1,3 +1,4 @@
#if PLUGIN_COMMAND_WINDOW
WindowID CommandWindowID; WindowID CommandWindowID;
void CMD_ShowCommands() { void CMD_ShowCommands() {
@@ -84,3 +85,4 @@ void InitCommandWindow() {
window->lose_focus_on_escape = true; window->lose_focus_on_escape = true;
window->jump_history = false; window->jump_history = false;
} }
#endif // PLUGIN_COMMAND_WINDOW

View File

@@ -1,3 +1,4 @@
#if PLUGIN_DEBUG_WINDOW
WindowID DebugWindowID; WindowID DebugWindowID;
ViewID DebugViewID; ViewID DebugViewID;
BufferID DebugBufferID; BufferID DebugBufferID;
@@ -65,3 +66,4 @@ void CMD_ToggleDebug() {
Window *window = GetWindow(DebugWindowID); Window *window = GetWindow(DebugWindowID);
window->visible = !window->visible; window->visible = !window->visible;
} RegisterCommand(CMD_ToggleDebug, "ctrl-0", "Open a floating window that might become useful for debugging"); } RegisterCommand(CMD_ToggleDebug, "ctrl-0", "Open a floating window that might become useful for debugging");
#endif // PLUGIN_DEBUG_WINDOW

View File

@@ -1,3 +1,4 @@
#if PLUGIN_DIRECTORY_NAVIGATION
// @todo: On save rename files, delete files it should apply the changes // @todo: On save rename files, delete files it should apply the changes
// Instead of toying with Reopen maybe it should actually detect changes in directory etc. on update // Instead of toying with Reopen maybe it should actually detect changes in directory etc. on update
@@ -203,4 +204,5 @@ void DestroyDirectoryWatcher(DirectoryWatcher *w)
} }
#endif #endif
#endif
#endif #endif

View File

@@ -1,3 +1,4 @@
#if PLUGIN_PROJECT_MANAGEMENT
void SetProjectFolder(String dir) { void SetProjectFolder(String dir) {
ProjectFolder = Intern(&GlobalInternTable, dir); ProjectFolder = Intern(&GlobalInternTable, dir);
Scratch scratch; Scratch scratch;
@@ -134,4 +135,5 @@ void CO_CreateProject(mco_coro *co) {
} }
CO_OpenCode(co); CO_OpenCode(co);
} RegisterCoroutineCommand(CO_CreateProject, "", "Creates a project in current buffer directory with template files and all that, asks user for input etc."); } RegisterCoroutineCommand(CO_CreateProject, "", "Creates a project in current buffer directory with template files and all that, asks user for input etc.");
#endif

View File

@@ -1 +1,3 @@
#if PLUGIN_PROJECT_MANAGEMENT
void SetProjectFolder(String name); void SetProjectFolder(String name);
#endif

View File

@@ -1,3 +1,4 @@
#if PLUGIN_RECORD_EVENTS
Buffer *EventBuffer; Buffer *EventBuffer;
void Serialize(Buffer *buffer, String name, EventKind *kind) { void Serialize(Buffer *buffer, String name, EventKind *kind) {
@@ -67,4 +68,5 @@ void Serialize(Buffer *buffer, Event *e) {
void CMD_CopyEvents() { void CMD_CopyEvents() {
SaveStringInClipboard(GetString(EventBuffer)); SaveStringInClipboard(GetString(EventBuffer));
} RegisterCommand(CMD_CopyEvents, "ctrl-shift-alt-j", "Copy all the events from the EventBuffer"); } RegisterCommand(CMD_CopyEvents, "ctrl-shift-alt-j", "Copy all the events from the EventBuffer");
#endif

View File

@@ -1 +1,3 @@
Buffer *GCInfoBuffer; #if PLUGIN_RECORD_GC
Buffer *GCInfoBuffer;
#endif

View File

@@ -1,3 +1,4 @@
#if PLUGIN_SEARCH_OPEN_BUFFERS
struct SearchOpenBuffersParams { struct SearchOpenBuffersParams {
String16 needle; String16 needle;
BufferID buffer; BufferID buffer;
@@ -127,3 +128,4 @@ void CMD_SearchOpenBuffers() {
} }
SelectRange(main.view, GetLineRangeWithoutNL(main.buffer, 0)); SelectRange(main.view, GetLineRangeWithoutNL(main.buffer, 0));
} RegisterCommand(CMD_SearchOpenBuffers, "ctrl-shift-f", "Interactive search over the entire project in a new buffer view"); } RegisterCommand(CMD_SearchOpenBuffers, "ctrl-shift-f", "Interactive search over the entire project in a new buffer view");
#endif

View File

@@ -1,3 +1,4 @@
#if PLUGIN_SEARCH_WINDOW
Int SearchBufferChangeID; Int SearchBufferChangeID;
void CMD_Search() { void CMD_Search() {
@@ -110,3 +111,4 @@ void UpdateSearchWindow() {
} }
} }
} }
#endif

View File

@@ -1,3 +1,4 @@
#if PLUGIN_STATUS_WINDOW
WindowID StatusWindowID; WindowID StatusWindowID;
void InitStatusWindow() { void InitStatusWindow() {
@@ -97,3 +98,4 @@ void UpdateStatusWindow() {
SelectRange(title.view, MakeRange(0)); SelectRange(title.view, MakeRange(0));
ResetHistory(title.buffer); ResetHistory(title.buffer);
} }
#endif

View File

@@ -1,6 +1,5 @@
#if PLUGIN_TESTS #if PLUGIN_TESTS
void Wait(mco_coro *co) { void Wait(mco_coro *co) {
{Event ev = {};ev.kind = EVENT_KIND_INVALID; Add(&EventPlayback, ev);} {Event ev = {};ev.kind = EVENT_KIND_INVALID; Add(&EventPlayback, ev);}
Event *event = NULL; Event *event = NULL;
@@ -120,4 +119,4 @@ Memes and stuff)FOO";
} RegisterCoroutineCommand(CO_RunTests, "", "Basic tests"); } RegisterCoroutineCommand(CO_RunTests, "", "Basic tests");
#endif #endif // PLUGIN_TESTS

View File

@@ -1,3 +1,4 @@
#if PLUGIN_WINDOW_MANAGEMENT
void CMD_JumpPrev() { void CMD_JumpPrev() {
BSet main = GetBSet(PrimaryWindowID); BSet main = GetBSet(PrimaryWindowID);
JumpToLastValidView(main.window); JumpToLastValidView(main.window);
@@ -80,3 +81,4 @@ void CMD_GotoPrevInList() {
BSet main = GetBSet(PrimaryWindowID); BSet main = GetBSet(PrimaryWindowID);
GotoNextInList(main.window, -1); GotoNextInList(main.window, -1);
} RegisterCommand(CMD_GotoPrevInList, "alt-e | shift-f8", "For example: when jumping from build panel to build error, a jump point is setup, user can click this button to go over to the previous compiler error"); } RegisterCommand(CMD_GotoPrevInList, "alt-e | shift-f8", "For example: when jumping from build panel to build error, a jump point is setup, user can click this button to go over to the previous compiler error");
#endif

View File

@@ -73,8 +73,6 @@
#include "render_opengl.cpp" #include "render_opengl.cpp"
#define PLUGIN_CONFIG 1 #define PLUGIN_CONFIG 1
#define PLUGIN_SEARCH_WINDOW 1
#define PLUGIN_PROJECT_MANAGEMENT 1
#define PLUGIN_WINDOW_MANAGEMENT 1 #define PLUGIN_WINDOW_MANAGEMENT 1
#define PLUGIN_DIRECTORY_NAVIGATION 1 #define PLUGIN_DIRECTORY_NAVIGATION 1
#define PLUGIN_SEARCH_OPEN_BUFFERS 1 #define PLUGIN_SEARCH_OPEN_BUFFERS 1
@@ -88,7 +86,6 @@
#define PLUGIN_DEBUG_WINDOW 1 #define PLUGIN_DEBUG_WINDOW 1
#define PLUGIN_RECORD_GC 1 #define PLUGIN_RECORD_GC 1
#define PLUGIN_RECORD_EVENTS 1 #define PLUGIN_RECORD_EVENTS 1
#define PLUGIN_DIRECTORY_NAVIGATION 1
#define PLUGIN_LOAD_VCVARS OS_WINDOWS #define PLUGIN_LOAD_VCVARS OS_WINDOWS
#define PLUGIN_REMEDYBG OS_WINDOWS #define PLUGIN_REMEDYBG OS_WINDOWS
#define PLUGIN_FILE_COMMANDS 1 #define PLUGIN_FILE_COMMANDS 1
@@ -987,6 +984,7 @@ int main(int argc, char **argv, char **envp)
} }
#endif #endif
#if PLUGIN_TESTS
if (1) { if (1) {
RunArenaTest(); RunArenaTest();
For (TestFunctions) { For (TestFunctions) {
@@ -996,6 +994,7 @@ int main(int argc, char **argv, char **envp)
// ReportErrorf("Testing DONE\n"); // ReportErrorf("Testing DONE\n");
// return 0; // return 0;
} }
#endif
if (!SDL_Init(SDL_INIT_VIDEO)) { if (!SDL_Init(SDL_INIT_VIDEO)) {
ReportErrorf("Couldn't initialize SDL! %s", SDL_GetError()); ReportErrorf("Couldn't initialize SDL! %s", SDL_GetError());