diff --git a/data/init.lua b/data/init.lua index f956f44..4801c99 100644 --- a/data/init.lua +++ b/data/init.lua @@ -57,6 +57,9 @@ SDLK_X = 0x00000078 SDLK_Y = 0x00000079 SDLK_Z = 0x0000007a +VERTICAL = 1 +HORIZONTAL = 2 + function IsAlpha(a) if a == nil then return false diff --git a/init.project.lua b/init.project.lua new file mode 100644 index 0000000..4d3f12d --- /dev/null +++ b/init.project.lua @@ -0,0 +1,13 @@ +FKey[2] = "remedybg.exe build\\te.exe" +FKey[5] = "remedybg.exe continue-execution" +FKey[9] = function () return 'remedybg.exe add-breakpoint-at-file '..GetFilename()..' '..tostring(GetLine()) end +FKey[10] = function () return 'remedybg.exe run-to-cursor '..GetFilename()..' '..tostring(GetLine()) end + + +function OnInit() + Open("init.project.lua") + Split(VERTICAL) + Open("src/text_editor/todo.txt") + Split(HORIZONTAL) + Open("src/text_editor/commands.cpp") +end \ No newline at end of file diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index b8f8bf4..69ee1fa 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -1364,4 +1364,25 @@ String16 FetchLoadWord(void) { if (GetSize(caret.range) == 0) range = EncloseLoadWord(active.buffer, GetFront(caret)); String16 string = GetString(active.buffer, range); return string; -} \ No newline at end of file +} + +void SplitWindow(WindowSplitKind kind) { + Window *window = CreateWindow(); + View *view = OpenBufferView(ScratchBuffer->name); + window->active_view = view->id; + CreateTitlebar(window->id); + CreateSearchBar(window->id); + + Window *active_window = GetActiveWindow(); + SplitWindowEx(NULL, &WindowSplits, active_window, window, kind); + ActiveWindow = window->id; +} + +int Lua_Split(lua_State *L) { + lua_Integer kind = lua_tointeger(L, -1); + lua_pop(L, 1); + if (kind == 1 || kind == 2) { + SplitWindow((WindowSplitKind)kind); + } + return 0; +} diff --git a/src/text_editor/generated.cpp b/src/text_editor/generated.cpp index 4de62c3..5b08c53 100644 --- a/src/text_editor/generated.cpp +++ b/src/text_editor/generated.cpp @@ -127,6 +127,9 @@ SDLK_X = 0x00000078 SDLK_Y = 0x00000079 SDLK_Z = 0x0000007a +VERTICAL = 1 +HORIZONTAL = 2 + function IsAlpha(a) if a == nil then return false @@ -137,7 +140,7 @@ function IsAlpha(a) end function SkipLineAndColumn(s) - local line, col = "1", "1" + local line, col = "-1", "-1" function parse_line_and_column(line_and_col, delimiter) ic, jc = line_and_col:find(delimiter) diff --git a/src/text_editor/lua_api_generated.cpp b/src/text_editor/lua_api_generated.cpp index 7c1392e..42658da 100644 --- a/src/text_editor/lua_api_generated.cpp +++ b/src/text_editor/lua_api_generated.cpp @@ -33,5 +33,6 @@ luaL_Reg LuaFunctions[] = { {"SetWorkDir", Lua_SetWorkDir}, {"ListCommands", Lua_ListCommands}, {"GetBufferList", Lua_GetBufferList}, + {"Split", Lua_Split}, {NULL, NULL}, }; diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index 753dd1c..a7e6d67 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -2,23 +2,19 @@ - commands for scrolling: center, cursor_at_bottom_of_screen, cursor_at_top - Add metadata to Lua bindings so that we would get a better listing (function args?, what else?) - Kill buffer command (it should be marked for deletion and deleted at the end of frame!) +- Save all command - Delete directory/file on disk command - Check. Convert more commands to taking buffer instead of view - Check. Rewrite more commands to use already implemented commands? - Lua namespaces for different kinds of commands (by ids, using main_set, using active_set)? - Some decl/function indexing in fuzzy format -- Set window layout using project file - - Split command - - not needed but would be nice: - - Query ids somehow - - Open buffer using id - - Set active window using id +- testing + - maybe setup folders, a folder with project, without project, stuff like that + - text_editor --record events.txt text_editor --playback events.txt + - Fix jump scroll, the query ends up the last line on screen, kind of wacky -- save all relevant buffers and build -- maybe most of the bindings should be in lua, but actual code in C - - maybe less code should be in lua ?? Lua code is very dodgey to change - LoadWord, EncloseWord configurable? - dump text editor state to file, restore state - proper lister @@ -41,7 +37,6 @@ backlog - Implement shell interaction (the valid cmd lines should start with '>' or '$', user can add more lines like this to expand the command size maybe?, if we have a case where we have a line with '>' but the last line doesn't have (just a space) then it should execute?) - drop text into window - I think the way sublime text and we display line highlights is confusing with multiple cursors (line highlight can be confused with selection) -- text_editor --record events.txt text_editor --playback events.txt - make the editor replayable, store events and then replay, be careful about globals - maybe open should return multiple options if there are many more? (like in sublime if many symbols you get a window and you choose and it automatically jumps you to the symbol in the background) - 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 @@ -50,7 +45,7 @@ backlog - redo tree - gap buffer - optimize rendering - command buffer, and vertice buffer instead of vertice buffer with scissor -- fix mouse cursor code, visual artifacts, fast cursor changing stuff +- fix sdl mouse cursor code, visual artifacts, fast cursor changing stuff !!As little lua code as possible, but lua code should be powerful just in case of quick edits \ No newline at end of file diff --git a/src/text_editor/window.cpp b/src/text_editor/window.cpp index 6dd40ff..e4da965 100644 --- a/src/text_editor/window.cpp +++ b/src/text_editor/window.cpp @@ -89,18 +89,6 @@ void SplitWindowEx(WindowSplit **node, WindowSplit *split, Window *target, Windo } } -void SplitWindow(WindowSplitKind kind) { - Window *window = CreateWindow(); - View *view = OpenBufferView(ScratchBuffer->name); - window->active_view = view->id; - CreateTitlebar(window->id); - CreateSearchBar(window->id); - - Window *active_window = GetActiveWindow(); - SplitWindowEx(NULL, &WindowSplits, active_window, window, kind); - ActiveWindow = window->id; -} - void SetVisibility(WindowID window_id, bool v) { Window *window = GetWindow(window_id); window->visible = v;