VCVarsall improvements, reload entire config every time

This commit is contained in:
krzosa
2025-04-29 18:02:25 +02:00
parent 92139cf799
commit daa0d2d4c4
7 changed files with 30 additions and 35 deletions

View File

@@ -551,6 +551,7 @@ void GenerateConfig() {
style.add({"FontSize", "12"}); style.add({"FontSize", "12"});
style.add({"FontFilter", "0"}); // nearest = 0, linear = 1 - seems like nearest always better? style.add({"FontFilter", "0"}); // nearest = 0, linear = 1 - seems like nearest always better?
style.add({"Font", "C:/Windows/Fonts/consola.ttf"}); style.add({"Font", "C:/Windows/Fonts/consola.ttf"});
style.add({"VCVarsall", "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat"});
{ {
MA_Scratch scratch; MA_Scratch scratch;

View File

@@ -66,6 +66,7 @@ Style.ClangFormatOnSave = 0
Style.FontSize = 12 Style.FontSize = 12
Style.FontFilter = 0 Style.FontFilter = 0
Style.Font = "C:/Windows/Fonts/consola.ttf" Style.Font = "C:/Windows/Fonts/consola.ttf"
Style.VCVarsall = "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat"
SDLK_CTRL = 1073742048 SDLK_CTRL = 1073742048
SDLK_PAGE_DOWN = 1073741902 SDLK_PAGE_DOWN = 1073741902
@@ -390,4 +391,5 @@ void ReloadStyle() {
StyleFontSize = GetStyleInt("FontSize", StyleFontSize); StyleFontSize = GetStyleInt("FontSize", StyleFontSize);
StyleFontFilter = GetStyleInt("FontFilter", StyleFontFilter); StyleFontFilter = GetStyleInt("FontFilter", StyleFontFilter);
StyleFont = GetStyleString("Font", StyleFont); StyleFont = GetStyleString("Font", StyleFont);
StyleVCVarsall = GetStyleString("VCVarsall", StyleVCVarsall);
} }

View File

@@ -63,3 +63,4 @@ Int StyleClangFormatOnSave = 0;
Int StyleFontSize = 12; Int StyleFontSize = 12;
Int StyleFontFilter = 0; Int StyleFontFilter = 0;
String StyleFont = "C:/Windows/Fonts/consola.ttf"; String StyleFont = "C:/Windows/Fonts/consola.ttf";
String StyleVCVarsall = "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat";

View File

@@ -414,8 +414,7 @@ int Lua_Play(lua_State *L) {
void ReloadStyle(); void ReloadStyle();
extern String BaseLuaConfig; extern String BaseLuaConfig;
int LoadLuaBuffer(Buffer *lua_buffer) { void LoadLuaBuffer(Buffer *lua_buffer) {
if (!lua_buffer || lua_buffer->dirty || lua_buffer->change_id == lua_buffer->user_change_id) return false;
ReportConsolef("reloading config: %.*s", FmtString(lua_buffer->name)); ReportConsolef("reloading config: %.*s", FmtString(lua_buffer->name));
Scratch scratch; Scratch scratch;
@@ -432,24 +431,31 @@ int LoadLuaBuffer(Buffer *lua_buffer) {
lua_pop(LuaState, 1); lua_pop(LuaState, 1);
} }
lua_buffer->user_change_id = lua_buffer->change_id; lua_buffer->user_change_id = lua_buffer->change_id;
return true;
} }
void ReloadLuaConfigs() { void ReloadLuaConfigs() {
int base_config_reload = LoadLuaBuffer(LuaConfigBuffer); bool reload = false;
int project_config_reload = LoadLuaBuffer(LuaProjectBuffer); if (LuaConfigBuffer && !LuaConfigBuffer->dirty && LuaConfigBuffer->change_id != LuaConfigBuffer->user_change_id) {
reload = true;
}
if (LuaProjectBuffer && !LuaProjectBuffer->dirty && LuaProjectBuffer->change_id != LuaProjectBuffer->user_change_id) {
reload = true;
}
if (reload == false) {
return;
}
LoadLuaBuffer(LuaConfigBuffer);
LoadLuaBuffer(LuaProjectBuffer);
if (base_config_reload || project_config_reload) {
ReportConsolef("reloading style variables because config changed");
ReloadStyle(); ReloadStyle();
ReloadFont(); // @todo: maybe don't reload font if nothing changed ReloadFont();
For(Windows) { For(Windows) {
Window *window = it.o; Window *window = it.o;
if (!window->visible || window->absolute_position || window->is_title_bar) continue; if (!window->visible || window->absolute_position || window->is_title_bar) continue;
window->draw_scrollbar = StyleDrawScrollbar; window->draw_scrollbar = StyleDrawScrollbar;
window->draw_line_numbers = StyleDrawLineNumbers; window->draw_line_numbers = StyleDrawLineNumbers;
} }
}
} }
bool CallIsLoadWord(char16_t c) { bool CallIsLoadWord(char16_t c) {

View File

@@ -1,12 +0,0 @@
-- this is going to output all the enviroment variables into the bar after it executes vcvarsall.
-- Sentinel is for separating errors from data
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" amd64 && echo SOME_SENTINEL_VALUE && set
local id = '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 && echo SOME_SENTINEL_VALUE && set'
local buffer_id = GetBufferID(id)
while ProcessIsRunning(id) do coroutine.yield() end
local string = GetBufferString(buffer_id)
local lines = SplitIntoLines(string)
Skip past sentinel value
Parse the enviroment and then pass that value into new processes

View File

@@ -223,7 +223,8 @@ void Windows_SetupVCVarsall(mco_coro *co) {
Scratch scratch; Scratch scratch;
String working_dir = GetActiveMainWindowBufferDir(); String working_dir = GetActiveMainWindowBufferDir();
String buffer_name = GetUniqueBufferName(scratch, working_dir, "+cmd-"); String buffer_name = GetUniqueBufferName(scratch, working_dir, "+cmd-");
View *view = Command_ExecHidden(buffer_name, "\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat\" && set", working_dir); String cmd = Format(scratch, "\"%.*s\" && set", FmtString(StyleVCVarsall));
View *view = Command_ExecHidden(buffer_name, cmd, working_dir);
for (;;) { for (;;) {
if (!ProcessIsActive(view->id)) { if (!ProcessIsActive(view->id)) {
break; break;

View File

@@ -1,10 +1,9 @@
- search
- dump text editor state to file, restore state - dump text editor state to file, restore state
- help menu popup when for example in process buffer, on tile bar buffer and stuff like that - help menu popup when for example in process buffer, on tile bar buffer and stuff like that
- Processing cmd.exe command encoding!!!
- shift click inside selection should move the selection - shift click inside selection should move the selection
- report errors (try showing a window) - report errors (try showing a window)
- proper lister - proper lister
- search
- adding items to directory should create files on save - it should ask the user (syntax: dir/ | file) - adding items to directory should create files on save - it should ask the user (syntax: dir/ | file)
- ask user if he really wants to quit even though he has an unsaved buffer - popup window - ask user if he really wants to quit even though he has an unsaved buffer - popup window
@@ -31,10 +30,7 @@
- Cmd should reuse the window which already has the build - Cmd should reuse the window which already has the build
- escapeing multiple cursor after ctrl + d should put the cursor where it was (probably will need to swap secondary and primary cursor for new cursor - escapeing multiple cursor after ctrl + d should put the cursor where it was (probably will need to swap secondary and primary cursor for new cursor
- open lua file with proper name it should do the work for setting up a project (double-click on desktop)
- when do we regen directory buffers? - when do we regen directory buffers?
- load project command which loads files and config
- global config and local config
- draw indentation levels like in sublime (those lines) - we render chars one by one so seems relatively easy to figure out if whitespace belongs to beginning of line (make sure to add max value like 40 because of big files) - draw indentation levels like in sublime (those lines) - we render chars one by one so seems relatively easy to figure out if whitespace belongs to beginning of line (make sure to add max value like 40 because of big files)
- code sections, visual demarkation if beginning of line has a very specific text + goto next / goto prev section hotkey! - code sections, visual demarkation if beginning of line has a very specific text + goto next / goto prev section hotkey!