From bb6eaf9e4ffdaa038cce11c6225584d54a59b131 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Thu, 7 Aug 2025 09:49:34 +0200 Subject: Added custom vimrc and fixed typo in examples --- .vimrc | 30 ++++++++++++++++++++++++++++++ examples/graphics.lua | 2 +- examples/json.lua | 2 +- main.c | 7 +++---- 4 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 .vimrc diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..a2da4a7 --- /dev/null +++ b/.vimrc @@ -0,0 +1,30 @@ +set makeprg=make +set errorformat=%f:%l:%c:\ %m + +let g:gdb_executable = 'bidi' +let g:gdb_arguments = '-r examples/json.lua' + +nnoremap m :call LocalMake() +nnoremap bm :execute '!make && gdb -ex "break main" -ex "run" --args ' . g:gdb_executable . ' ' . g:gdb_arguments +nnoremap bl :execute '!make && gdb -ex "break ' . line('.') . '" -ex "run" --args ' . g:gdb_executable . ' ' . g:gdb_arguments + +function! LocalMake() + silent make + + " Filter non valid errors out of quicklist. + let qfl = getqflist() + let filtered = filter(copy(qfl), {_, entry -> entry.valid == 1}) + call setqflist(filtered, 'r') + + redraw! + + if len(filtered) > 0 + copen + else + cclose + endif +endfunction + +" Hardcoded example +" nnoremap bm :!gdb -ex "break main" -ex "run" --args bidi -r examples/json.lua +" nnoremap bl :execute '!gdb -ex "break ' . line('.') . '" -ex "run" --args bidi -r examples/json.lua' diff --git a/examples/graphics.lua b/examples/graphics.lua index 2ac5219..cd1ee12 100644 --- a/examples/graphics.lua +++ b/examples/graphics.lua @@ -1,4 +1,4 @@ -open_window(800, 800, "My Game") +open_window(800, 800, "Sample Window") set_fps(60) while window_running() do diff --git a/examples/json.lua b/examples/json.lua index f656942..17a1930 100644 --- a/examples/json.lua +++ b/examples/json.lua @@ -1,4 +1,4 @@ -local file = io.open("test/test.json", "r") +local file = io.open("examples/test.json", "r") local content = file:read("*a") file:close() diff --git a/main.c b/main.c index b237a46..00e11d2 100644 --- a/main.c +++ b/main.c @@ -120,9 +120,9 @@ static int l_draw_info(lua_State *L) { double runtime = GetTime(); int height = GetScreenHeight(); - DrawTextEx(ctx.font, TextFormat("dt: %f", delta), (Vector2){ 20, height - 80 }, 20, 0, RAYWHITE); + DrawTextEx(ctx.font, TextFormat("fps: %d", fps), (Vector2){ 20, height - 80 }, 20, 0, RAYWHITE); DrawTextEx(ctx.font, TextFormat("run: %f", runtime), (Vector2){ 20, height - 60 }, 20, 0, RAYWHITE); - DrawTextEx(ctx.font, TextFormat("fps: %d", fps), (Vector2){ 20, height - 40 }, 20, 0, RAYWHITE); + DrawTextEx(ctx.font, TextFormat("dt: %f", delta), (Vector2){ 20, height - 40 }, 20, 0, RAYWHITE); return 0; } @@ -183,7 +183,6 @@ int main(int argc, char *argv[]) { if (run_file) { SetTraceLogLevel(debug_level); - lua_State *L = luaL_newstate(); luaL_openlibs(L); @@ -209,7 +208,7 @@ int main(int argc, char *argv[]) { return 1; } - UnloadFont(ctx.font); // Unload font from GPU memory (VRAM) + UnloadFont(ctx.font); lua_close(L); } -- cgit v1.2.3