diff --git a/data/init.lua b/data/init.lua index 6937840..ad459aa 100644 --- a/data/init.lua +++ b/data/init.lua @@ -242,6 +242,11 @@ function MatchExec(s, meta) return {kind = "exec_console", cmd = s, working_dir = GetMainDir()} end + if s:match("^%$") then + Print(s:sub(2, -1)) + return {kind = "exec_console", cmd = s:sub(2, -1), working_dir = GetMainDir()} + end + Eval(s) return {kind = "skip"} end diff --git a/src/text_editor/buffer.cpp b/src/text_editor/buffer.cpp index 8e3de18..79be683 100644 --- a/src/text_editor/buffer.cpp +++ b/src/text_editor/buffer.cpp @@ -291,7 +291,7 @@ Int GetWordEnd(Buffer *buffer, Int pos) { } bool IsLoadWord(char16_t w) { - bool result = w == u'(' || w == u')' || w == u'/' || w == u'\\' || w == u':' || w == u'+' || w == u'_' || w == u'.' || w == u'-' || w == u','; + bool result = w == u'(' || w == u')' || w == u'/' || w == u'\\' || w == u':' || w == u'$' || w == u'_' || w == u'.' || w == u'@' || w == u','; if (!result) { result = !(IsSymbol(w) || IsWhitespace(w)); } diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index c508f46..2556243 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -721,6 +721,16 @@ void Command_KillSelectedLines(View *view) { Command_Replace(view, u""); } +void EncloseLine(View *view) { + Buffer *buffer = GetBuffer(view->active_buffer); + For (view->carets) { + Int eof = 0; + it.range.max = GetFullLineEnd(buffer, it.range.max, &eof); + it.range.min = GetFullLineStart(buffer, it.range.min); + it.range.min -= Clamp(eof, (Int)0, buffer->len); + } +} + void Command_Delete(View *view, int direction, bool ctrl = false) { Assert(direction == DIR_LEFT || direction == DIR_RIGHT); Scratch scratch; diff --git a/src/text_editor/commands_bindings.cpp b/src/text_editor/commands_bindings.cpp index 583cdfd..65e8f90 100644 --- a/src/text_editor/commands_bindings.cpp +++ b/src/text_editor/commands_bindings.cpp @@ -688,6 +688,10 @@ void OnCommand(Event event) { } + if (CtrlPress(SDLK_L)) { + EncloseLine(active.view); + } + if (CtrlShiftPress(SDLK_G)) { } else if (CtrlPress(SDLK_G)) { diff --git a/src/text_editor/generated.cpp b/src/text_editor/generated.cpp index 9869be8..93fdda6 100644 --- a/src/text_editor/generated.cpp +++ b/src/text_editor/generated.cpp @@ -308,12 +308,17 @@ function MatchExec(s, meta) return nil end - if c:match(".exe$") then - return {kind = "exec_console", cmd = c, working_dir = GetMainDir()} + if s:match(".exe$") then + return {kind = "exec_console", cmd = s, working_dir = GetMainDir()} + end + + if s:match("^%$") then + Print(s:sub(2, -1)) + return {kind = "exec_console", cmd = s:sub(2, -1), working_dir = GetMainDir()} end Eval(s) - return nil + return {kind = "skip"} end OnOpenMatchers = { diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index 59296f1..17536b1 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -5,18 +5,19 @@ - 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? + - 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 +- Fix jump scroll, the query ends up the last line on screen, kind of wacky - Fix Ctrl+1 Ctrl+2 (choosing window) - Fix search, should have an anchor - Use project file as working dir instead of scratch buffer path, separate project dir and project file -- Maybe Shift+Ctrl+Click sends a meta command of execute to Open(), it would allow to open exes - Enclose line (Ctrl + L) - Enclose most outer scope (but without the last chars, this would be for eval) - Enclose scope