diff --git a/build.sh b/build.sh index d15a943..816aaaf 100644 --- a/build.sh +++ b/build.sh @@ -1,3 +1,5 @@ +#!/usr/bin/bash + mkdir build cd build @@ -42,6 +44,7 @@ fi clang ../src/text_editor/text_editor.cpp ../src/basic/unix.cpp \ -o te_linux.exe \ -nostdlib++ -fno-exceptions -fdiagnostics-absolute-paths -g \ + -DDEBUG_BUILD=1 \ -Wno-writable-strings \ -I../src/external/SDL/include \ -I../src/external/lua/src \ diff --git a/src/basic/unix.cpp b/src/basic/unix.cpp index fe76be5..5817748 100644 --- a/src/basic/unix.cpp +++ b/src/basic/unix.cpp @@ -262,6 +262,9 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin const int PIPE_WRITE = 1; bool error = false; + printf("cmd = %.*s\n", FmtString(command_line)); + printf("cwd = %.*s\n", FmtString(working_dir)); + char *buffer = AllocArray(scratch, char, 4096); chdir(working_dir.data); getcwd(buffer, 4096); diff --git a/src/text_editor/commands_bindings.cpp b/src/text_editor/commands_bindings.cpp index b2e4a0e..3c8a4ee 100644 --- a/src/text_editor/commands_bindings.cpp +++ b/src/text_editor/commands_bindings.cpp @@ -300,9 +300,9 @@ void OnCommand(Event event) { ToggleVisibility(DebugWindowID); } - if (Press(SDLK_F11)) { - Command_ToggleFullscreen(); - } + // if (Press(SDLK_F11)) { + // Command_ToggleFullscreen(); + // } if (CtrlPress(SDLK_GRAVE)) { if (ActiveWindow != NullWindowID) { @@ -511,14 +511,14 @@ void OnCommand(Event event) { MergeCarets(active.buffer, &active.view->carets); } - if (ShiftPress(SDLK_F3)) { + if (AltPress(SDLK_N)) { Scratch scratch; String16 search_string = GetSearchString(main.window); Caret caret = FindPrev(main.buffer, search_string, main.view->carets[0]); BSet search = GetBSet(main.window->search_bar_window); search.window->search_bar_anchor = caret; Command_SelectRangeOneCursor(main.view, caret); - } else if (Press(SDLK_F3)) { + } else if (CtrlPress(SDLK_N)) { Scratch scratch; String16 search_string = GetSearchString(main.window); Caret caret = FindNext(main.buffer, search_string, main.view->carets[0]); diff --git a/src/text_editor/generated.cpp b/src/text_editor/generated.cpp index 0daed62..25f4910 100644 --- a/src/text_editor/generated.cpp +++ b/src/text_editor/generated.cpp @@ -278,7 +278,6 @@ function MatchUnixPath(s, meta) local path = s:sub(i, j) local rest = s:sub(j + 1, -1) local line, col, s = SkipLineAndColumn(rest) - Print(path, rest, line, col) return {kind = "text", file_path = path, line = line, col = col} end @@ -329,13 +328,14 @@ function MatchExec(s, meta) return nil end - if s:match(".exe$") or s:match(".bat$") or s:match(".sh$") then - return {kind = "exec_console", cmd = s, working_dir = GetMainDir()} + if s:match("^%$") then + Print(""); + return {kind = "exec_console", cmd = s:sub(2, -1), 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()} + if s:match(".exe$") or s:match(".bat$") or s:match(".sh$") then + Print(""); + return {kind = "exec_console", cmd = s, working_dir = GetMainDir()} end Eval(s) @@ -387,22 +387,32 @@ end function KeybindsBasic(e) if e.key == SDLK_F and e.ctrl == 1 and e.shift == 1 then - C("git grep -n "..GetLoadWord().." :/") + C("git -C "..GetMainDir().." grep -n "..GetLoadWord().." :/") return true end return false end -FKey = {"build.bat", "", "", "", "", "", "", "", "", "", "", ""} +FKey = {"build.bat", "", "", "", "", "", "", "", "", "", ToggleFullscreen, ""} FKeySDLK = {SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_F11, SDLK_F12} +if OS_VALUE == OS_WINDOWS then + FKey[1] = "build.bat" +else + FKey[1] = "./build.sh" +end + function KeybindsFKeys(e) for i = #FKey,1,-1 do if FKey[i] ~= "" then if e.key == FKeySDLK[i] then local cmdline = FKey[i] - if type(cmdline) == "function" then cmdline = FKey[i]() end - Cmd { working_dir = GetWorkDir(), kind = "console", cmd = cmdline } + if type(cmdline) == "function" then + cmdline = FKey[i]() + end + if cmdline ~= nil then + Cmd { working_dir = GetWorkDir(), kind = "console", cmd = cmdline } + end return true end end diff --git a/src/text_editor/process.cpp b/src/text_editor/process.cpp index 3bfb2a9..5252630 100644 --- a/src/text_editor/process.cpp +++ b/src/text_editor/process.cpp @@ -40,7 +40,7 @@ void UpdateProcesses() { } - Command_Append(view, Format(scratch, "process exited with code: %d\n", it.exit_code), it.scroll_to_end); + printf("exit code = %d\n", it.exit_code); remove_item = true; } } diff --git a/src/text_editor/text_editor.cpp b/src/text_editor/text_editor.cpp index c2821de..74cd782 100644 --- a/src/text_editor/text_editor.cpp +++ b/src/text_editor/text_editor.cpp @@ -309,6 +309,7 @@ void Windows_SetupVCVarsall(mco_coro *co) { #if _WIN32 int WinMain(void *hInstance, void *hPrevInstance, const char *lpCmdLine, int nShowCmd) #else +extern char **environ; int main(int argc, char **argv) #endif { @@ -320,6 +321,12 @@ int main(int argc, char **argv) InitScratch(); InitArena(&Perm); +#if !OS_WINDOWS + for (int i = 0; environ[i]; i += 1) { + Add(&Enviroment, Copy(GetSystemAllocator(), environ[i])); + } +#endif + WorkDir = GetWorkingDir(Perm); { String sdl_config_path = SDL_GetPrefPath("krzosa", "text_editor"); diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index 07b9a40..3217e76 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -1,3 +1,8 @@ +- Add GetExeDir to lua, point at font automatically +- Rework PollStdout and stuff there to match both Unix and Windows properly +- Add metaprogram? +- Fix windows build + - Changing window properties by changing the window name? - 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?)