From 33d623268a889159df9eff66f16c48be61f92047 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Sun, 1 Feb 2026 12:28:34 +0100 Subject: [PATCH] Fix outside of buffer access and add docs --- src/text_editor/buffer.cpp | 3 +-- src/text_editor/ui.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/text_editor/buffer.cpp b/src/text_editor/buffer.cpp index 84e52b4..a4c7800 100644 --- a/src/text_editor/buffer.cpp +++ b/src/text_editor/buffer.cpp @@ -415,8 +415,7 @@ API Int OnCharClassBoundary_GetNextWordEnd(Buffer *buffer, Int pos) { } API Int OnCharClassBoundary_GetPrevWordStart(Buffer *buffer, Int pos) { - pos = Clamp(pos, (Int)0, buffer->len); - Int i = pos - 1; + Int i = Clamp(pos - 1, (Int)0, buffer->len); if (i >= 0 && GetCharClass(buffer->str[i]) == CharClass_Whitespace) { i -= 1; diff --git a/src/text_editor/ui.cpp b/src/text_editor/ui.cpp index 474f94e..7d770fb 100644 --- a/src/text_editor/ui.cpp +++ b/src/text_editor/ui.cpp @@ -217,6 +217,41 @@ bool IsOpenBoundary(char c) { return result; } +/* + +Variables that control the default shell for '!' commands + DefaultShellWindows - "cmd" + DefaultShellUnix - "bash | sh" + +Variables: + @ProjectDirectory/build/te + @(ProjectDirectory)/build/te + +Start of string matchers: + ! Execute with default shell + !! Execute hidden with default shell + :Command Execute editor command + :Set Special case for config stuff + http:// + https:// + commit + py: @todo, execute in python shell, this will use the python3 shell and pass the rest to it's stdin or maybe as a file + +More comprehensive syntax for commands: + !{/usr/bin/python,Hidden,Input:Clipboard,Output:Clipboard,WorkingDirectory:@ProjectDirectory,Env:{Thing:asd}} + +Otherwise it does filepath parsing: + C:/windows/path + /unix/path + ./it/also/does/linenums:32:3 + /as/well/as/this/format(111,1) + ./thing(10) + + +TODO: need to add '~', but where? +TODO: on linux find shell on first command and set as default + +*/ ResolvedOpen ResolveOpen(Allocator alo, Window *window, String path, ResolveOpenMeta meta) { ResolvedOpen result = {}; path = Trim(path);