console size, ListCommands, Indent on bracket

This commit is contained in:
Krzosa Karol
2025-05-03 18:45:05 +02:00
parent 93c1ba606a
commit 7a5d949a12
11 changed files with 51 additions and 17 deletions

View File

@@ -253,16 +253,18 @@ void GenerateConfig() {
colors.add({"TitleBarSelection", "GruvboxLight3"});
Array<Var> style = {};
style.add({"ConsoleSizeSmall", "10"});
style.add({"ConsoleSizeBig", "30"});
style.add({"WaitForEvents", "1"});
style.add({"DrawLineNumbers", "1"});
style.add({"DrawScrollbar", "1"});
style.add({"IndentSize", "4"});
style.add({"TrimWhitespaceOnSave", "1"});
style.add({"ClangFormatOnSave", "0"});
style.add({"FontSize", "12"});
style.add({"FontSize", "15"});
style.add({"FontFilter", "0"}); // nearest = 0, linear = 1 - seems like nearest always better?
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"});
style.add({"VCVarsall", "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"});
{
MA_Scratch scratch;

View File

@@ -11,6 +11,9 @@ SDLK_Q = 113
SDLK_BACKSLASH = 0x5c
SDLK_RETURN = 13
SDLK_EQUALS = 0x0000003d
SDLK_MINUS = 0x0000002d
SDLK_F1 = 0x4000003a
SDLK_F2 = 0x4000003b
SDLK_F3 = 0x4000003c

View File

@@ -497,6 +497,13 @@ void OnCommand(Event event) {
Command_IndentSelectedLines(active.view);
}
if (CtrlPress(SDLK_LEFTBRACKET)) {
Command_IndentSelectedLines(active.view, SHIFT_PRESSED);
}
if (CtrlPress(SDLK_RIGHTBRACKET)) {
Command_IndentSelectedLines(active.view);
}
if (CtrlShiftPress(SDLK_K)) {
Command_KillSelectedLines(active.view);
}

View File

@@ -57,16 +57,18 @@ Color.TitleBarText = GruvboxDark2
Color.TitleBarBackground = GruvboxLight1
Color.TitleBarSelection = GruvboxLight3
Style = {}
Style.ConsoleSizeSmall = 10
Style.ConsoleSizeBig = 30
Style.WaitForEvents = 1
Style.DrawLineNumbers = 1
Style.DrawScrollbar = 1
Style.IndentSize = 4
Style.TrimWhitespaceOnSave = 1
Style.ClangFormatOnSave = 0
Style.FontSize = 12
Style.FontSize = 15
Style.FontFilter = 0
Style.Font = "C:/Windows/Fonts/consola.ttf"
Style.VCVarsall = "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat"
Style.VCVarsall = "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"
INTERNET_BROWSER = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
SDLK_CTRL = 1073742048
@@ -80,6 +82,9 @@ SDLK_Q = 113
SDLK_BACKSLASH = 0x5c
SDLK_RETURN = 13
SDLK_EQUALS = 0x0000003d
SDLK_MINUS = 0x0000002d
SDLK_F1 = 0x4000003a
SDLK_F2 = 0x4000003b
SDLK_F3 = 0x4000003c
@@ -343,6 +348,8 @@ void ReloadStyle() {
ColorTitleBarText = GetColor("TitleBarText", ColorTitleBarText);
ColorTitleBarBackground = GetColor("TitleBarBackground", ColorTitleBarBackground);
ColorTitleBarSelection = GetColor("TitleBarSelection", ColorTitleBarSelection);
StyleConsoleSizeSmall = GetStyleInt("ConsoleSizeSmall", StyleConsoleSizeSmall);
StyleConsoleSizeBig = GetStyleInt("ConsoleSizeBig", StyleConsoleSizeBig);
StyleWaitForEvents = GetStyleInt("WaitForEvents", StyleWaitForEvents);
StyleDrawLineNumbers = GetStyleInt("DrawLineNumbers", StyleDrawLineNumbers);
StyleDrawScrollbar = GetStyleInt("DrawScrollbar", StyleDrawScrollbar);

View File

@@ -54,13 +54,15 @@ Color ColorScrollbarScrollerSelected = GruvboxLight0Hard;
Color ColorTitleBarText = GruvboxDark2;
Color ColorTitleBarBackground = GruvboxLight1;
Color ColorTitleBarSelection = GruvboxLight3;
Int StyleConsoleSizeSmall = 10;
Int StyleConsoleSizeBig = 30;
Int StyleWaitForEvents = 1;
Int StyleDrawLineNumbers = 1;
Int StyleDrawScrollbar = 1;
Int StyleIndentSize = 4;
Int StyleTrimWhitespaceOnSave = 1;
Int StyleClangFormatOnSave = 0;
Int StyleFontSize = 12;
Int StyleFontSize = 15;
Int StyleFontFilter = 0;
String StyleFont = "C:/Windows/Fonts/consola.ttf";
String StyleVCVarsall = "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat";
String StyleVCVarsall = "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat";

View File

@@ -1,5 +1,7 @@
lua_State *LuaState = NULL;
String16 LuaCommandResult = {};
extern luaL_Reg LuaFunctions[];
String FieldString(lua_State *L, String name) {
String result = {};
@@ -254,6 +256,20 @@ int Lua_SetProjectFile(lua_State *L) {
return 0;
}
int Lua_ListCommands(lua_State *L) {
BSet main = GetActiveMainSet();
Command_BeginConsoleJump(&main);
for (int i = 0; LuaFunctions[i].name != NULL; i += 1) {
Command_Appendf(main.view, "%20s() ", LuaFunctions[i].name);
if (((i + 1) % 6) == 0) {
Command_Appendf(main.view, "\n");
}
}
Command_EndConsoleJump(main);
ActiveWindow = main.window->id;
return 0;
}
int Lua_Reopen(lua_State *L) {
ReopenBuffer(GetActiveMainSet());
return 0;
@@ -370,8 +386,6 @@ static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
luaL_error(L, "lua execution got interrupted");
}
extern luaL_Reg LuaFunctions[];
Int GetStyleInt(String name, Int default_int) {
Int result = default_int;
lua_getglobal(LuaState, "Style");

View File

@@ -9,6 +9,7 @@ luaL_Reg LuaFunctions[] = {
{"New", Lua_New},
{"Open", Lua_Open},
{"SetProjectFile", Lua_SetProjectFile},
{"ListCommands", Lua_ListCommands},
{"Reopen", Lua_Reopen},
{"ToggleFullscreen", Lua_ToggleFullscreen},
{"ListBuffers", Lua_ListBuffers},

View File

@@ -9,7 +9,6 @@ Array<WindowID> Windows;
BufferID NullBufferID; // +buffer
ViewID NullViewID;
WindowID NullWindowID;
Int NullWindowSize = 5;
WindowID DebugWindowID; // +debug
BufferID DebugBufferID;

View File

@@ -337,7 +337,7 @@ int main(int argc, char **argv)
String it = argv[i];
if (!FileExists(it)) continue;
if (EndsWith(it, ".lua_project")) {
if (EndsWith(it, ".project.lua")) {
if (!LuaProjectBuffer) {
LuaProjectBuffer = BufferOpenFile(it);
LuaProjectBuffer->user_change_id = -1;

View File

@@ -275,13 +275,13 @@ void LayoutWindows(int16_t wx, int16_t wy) {
{
Window *window = GetWindow(NullWindowID);
Int console_panel_size = StyleConsoleSizeSmall;
if (ActiveWindow == window->id) {
NullWindowSize = 20;
} else {
NullWindowSize = 5;
console_panel_size = StyleConsoleSizeBig;
}
Rect2I rect = CutBottom(&screen_rect, FontLineSpacing*NullWindowSize);
Rect2I rect = CutBottom(&screen_rect, FontLineSpacing*console_panel_size);
Window *title_bar_window = GetWindow(window->title_bar_window);
title_bar_window->total_rect = CutBottom(&window->total_rect, GetTitleBarSize(title_bar_window));

View File

@@ -1,7 +1,6 @@
function OnCommandTE(e)
if e.key == SDLK_B and e.ctrl == 1 then
local cmd = "cd "..GetProjectPath().." && build.bat"
C(cmd)
Cmd { working_dir = GetProjectPath(), destination = "console", cmd = "build.bat" }
end
end