Config files

This commit is contained in:
Krzosa Karol
2025-12-31 13:47:15 +01:00
parent 6c0a4d0633
commit a40797abb2
13 changed files with 120 additions and 48 deletions

View File

@@ -648,7 +648,7 @@ void Windows_SetupVCVarsall(mco_coro *co) {
Scratch scratch;
String working_dir = WorkDir;
String buffer_name = GetUniqueBufferName(working_dir, "vcvarsall-");
String cmd = Format(scratch, "\"%S\" && set", ConfigVCVarsall);
String cmd = Format(scratch, "\"%S\" && set", VCVarsall);
view = ExecHidden(buffer_name, cmd, working_dir);
}
for (;;) {
@@ -701,9 +701,9 @@ void MainLoop() {
}
}
WaitForEvents = ConfigWaitForEvents;
WaitForEventsState = WaitForEvents;
if (IsDocumentSelectionValid() || IsScrollbarSelectionValid() || ActiveProcesses.len || dont_wait_until_resolved) {
WaitForEvents = false;
WaitForEventsState = false;
}
// This shouldn't matter to the state of the program, only appearance for
@@ -846,7 +846,7 @@ int main(int argc, char **argv)
InitBuffers();
InitRender();
ReloadFont(ConfigFont, (U32)ConfigFontSize);
ReloadFont(Font, (U32)FontSize);
InitWindows();
InitOS(ReportWarningf);
@@ -873,6 +873,23 @@ int main(int argc, char **argv)
}
}
{
Scratch scratch;
String exe_dir = GetExeDir(scratch);
String config_path = Format(scratch, "%S/config.te", exe_dir);
Window *window = GetWindow(NullWindowID);
View *view = WindowOpenBufferView(window, config_path);
Buffer *buffer = GetBuffer(view->active_buffer);
bool file_exists = buffer->file_mod_time != 0;
if (!file_exists) {
GenerateConfig(buffer);
} else {
EvalCommandsLineByLine({window, view, buffer});
}
buffer->dirty = false;
}
ReportConsolef("WorkDir = %S", WorkDir);
if (Testing) InitTests();
#if OS_WINDOWS