Fix dirty buffer after doing anything in title bar, OnCommand in lua stops c code, FKeys

This commit is contained in:
Krzosa Karol
2025-05-12 22:44:45 +02:00
parent 0c7a424f5e
commit 7eec390752
6 changed files with 94 additions and 37 deletions

View File

@@ -281,14 +281,6 @@ function AddCo(f)
return Coroutines[i]
end
OnCommandCallbacks = {}
table.insert(OnCommandCallbacks, function (e)
if e.key == SDLK_F and e.ctrl == 1 and e.shift == 1 then
C("git grep -n "..GetLoadWord().." :/") end
if e.key == SDLK_B and e.ctrl == 1 then
Cmd { working_dir = GetWorkDir(), kind = "console", cmd = "build.bat" } end
end)
function OnUpdate(e)
local new_co_list = {}
for key, co in pairs(Coroutines) do
@@ -301,11 +293,45 @@ function OnUpdate(e)
Coroutines = new_co_list
end
function KeybindsBasic(e)
if e.key == SDLK_F and e.ctrl == 1 and e.shift == 1 then
C("git grep -n "..GetLoadWord().." :/")
return true
end
return false
end
FKey = {"build.bat", "", "", "", "", "", "", "", "", "", "", ""}
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}
function KeybindsFKeys(e)
for i = #FKey,1,-1 do
if FKey[i] ~= "" then
if e.key == FKeySDLK[i] then
Cmd { working_dir = GetWorkDir(), kind = "console", cmd = FKey[i] }
return true
end
end
end
return false
end
BuiltinOnCommandCallbacks = {
KeybindsBasic,
KeybindsFKeys,
}
OnCommandCallbacks = BuiltinOnCommandCallbacks
function OnCommand(e)
for i = #OnCommandCallbacks,1,-1 do
on_command = OnCommandCallbacks[i]
on_command(e)
local result = on_command(e)
if result then
return true
end
end
return false
end
function OnInit()