From 8fc1081cef8c9266646a1c1b0de5fdb1a441f16e Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Mon, 5 May 2025 10:18:33 +0200 Subject: [PATCH] Go to end, start --- data/init.lua | 6 ++++++ src/text_editor/commands_bindings.cpp | 6 +++++- src/text_editor/generated.cpp | 6 ++++++ src/text_editor/lua_api.cpp | 12 +++++++----- src/text_editor/todo.txt | 5 ++--- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/data/init.lua b/data/init.lua index e231edb..0146dfb 100644 --- a/data/init.lua +++ b/data/init.lua @@ -221,6 +221,10 @@ function ApplyRules(s) return nil end +function CFiles() + Cmd({working_dir = GetProjectPath(), destination ="a", cmd = "dir /s/b | findstr .*\\.c"}) +end + Coroutines = {} function AddCo(f) local i = #Coroutines + 1 @@ -233,6 +237,8 @@ OnCommandCallbacks = {} table.insert(OnCommandCallbacks, function (e) if e.key == SDLK_F and e.ctrl == 1 and e.shift == 1 then C("git grep -n "..GetLoadWord().." :/") end + if e.key == SDLK_B and e.ctrl == 1 then + Cmd { working_dir = GetProjectPath(), destination = "console", cmd = "build.bat" } end end) function OnUpdate(e) diff --git a/src/text_editor/commands_bindings.cpp b/src/text_editor/commands_bindings.cpp index 55335eb..23319dd 100644 --- a/src/text_editor/commands_bindings.cpp +++ b/src/text_editor/commands_bindings.cpp @@ -540,13 +540,17 @@ void OnCommand(Event event) { if (ShiftPress(SDLK_PAGEUP)) { Command_MoveCursorsByPageSize(active.window, DIR_UP, SHIFT_PRESSED); + } else if (CtrlPress(SDLK_PAGEUP)) { + Command_SelectRangeOneCursor(active.view, Rng(0)); } else if (Press(SDLK_PAGEUP)) { Command_MoveCursorsByPageSize(active.window, DIR_UP); } if (ShiftPress(SDLK_PAGEDOWN)) { Command_MoveCursorsByPageSize(active.window, DIR_DOWN, SHIFT_PRESSED); - } else if (Press(SDLK_PAGEDOWN)) { + } else if (CtrlPress(SDLK_PAGEDOWN)) { + Command_SelectRangeOneCursor(active.view, Rng(active.buffer->len)); + } else if (Press(SDLK_PAGEDOWN)) { Command_MoveCursorsByPageSize(active.window, DIR_DOWN); } diff --git a/src/text_editor/generated.cpp b/src/text_editor/generated.cpp index 1c1fb13..be65abe 100644 --- a/src/text_editor/generated.cpp +++ b/src/text_editor/generated.cpp @@ -293,6 +293,10 @@ function ApplyRules(s) return nil end +function CFiles() + Cmd({working_dir = GetProjectPath(), destination ="a", cmd = "dir /s/b | findstr .*\\.c"}) +end + Coroutines = {} function AddCo(f) local i = #Coroutines + 1 @@ -305,6 +309,8 @@ OnCommandCallbacks = {} table.insert(OnCommandCallbacks, function (e) if e.key == SDLK_F and e.ctrl == 1 and e.shift == 1 then C("git grep -n "..GetLoadWord().." :/") end + if e.key == SDLK_B and e.ctrl == 1 then + Cmd { working_dir = GetProjectPath(), destination = "console", cmd = "build.bat" } end end) function OnUpdate(e) diff --git a/src/text_editor/lua_api.cpp b/src/text_editor/lua_api.cpp index 803978d..ba65d63 100644 --- a/src/text_editor/lua_api.cpp +++ b/src/text_editor/lua_api.cpp @@ -229,14 +229,16 @@ int Lua_GetLoadWord(lua_State *L) { } int Lua_New(lua_State *L) { + Scratch scratch; String name = luaL_checkstring(L, 1); lua_pop(L, 1); - BSet main = GetActiveMainSet(); - String dir = GetDir(main.buffer); - Scratch scratch; - String new_dir = Format(scratch, "%.*s/%.*s", FmtString(dir), FmtString(name)); - WindowOpenBufferView(main.window, new_dir); + BSet main = GetActiveMainSet(); + if (!IsAbsolute(name)) { + String dir = GetDir(main.buffer); + name = Format(scratch, "%.*s/%.*s", FmtString(dir), FmtString(name)); + } + WindowOpenBufferView(main.window, name); return 0; } diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index e4afd2e..907e83c 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -1,9 +1,9 @@ !!As little lua code as possible, but lua code should be powerful just in case of quick edits - maybe we could allow user to change window titles which would make them special in some way. A:/text_editor/+test_buffer:1:1:ADE | -- Windows, Buffers, Views should not be in a dynamic list it risks memory errors. Should be instead in a Double linked list, any freeing should happen at GC stage - Fix B: not opening - Scroll the console properly - commands for scrolling: center, cursor_at_bottom_of_screen, cursor_at_top +- need a buffer for every window that will be cleared on command and replaced with new content -------------- buffer = make_buffer() @@ -18,7 +18,7 @@ activate_buffer - help menu popup when for example in process buffer, on tile bar buffer and stuff like that - report errors (try showing a window) - proper lister -- revamp windows/layout/resize +- Setting size of splits - 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 | we could just show ForceClose() in the titlebar @@ -48,7 +48,6 @@ backlog - we could rewrite kill lines with simpler commands - extend selection to encompass lines->replace - I want a way to assign flags to buffers/views/windows from user perspective so that console window concept can be created from user space - font cache and on demand unicode loads -- Set scroll centered, what was the use case for this? - color parens, braces - redo tree - gap buffer