Lua_GetProjectPath, SDLK_Period
This commit is contained in:
47
te.lua_project
Normal file
47
te.lua_project
Normal file
@@ -0,0 +1,47 @@
|
||||
function OnCommandTE(e)
|
||||
if e.key == SDLK_B and e.ctrl == 1 then
|
||||
local cmd = "cd "..GetProjectPath().." && build.bat"
|
||||
C(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
function MatchProject(s)
|
||||
if s:sub(1,1) == '"' then
|
||||
s = s:sub(2)
|
||||
end
|
||||
|
||||
local s, file_path, drive = SkipPath(s)
|
||||
if not file_path then
|
||||
return nil
|
||||
end
|
||||
if drive ~= nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
local line, col, s = SkipLineAndColumn(s)
|
||||
|
||||
local fp = GetActiveMainWindowBufferDir().."/"..file_path
|
||||
if FileExists(fp) then
|
||||
return {kind = "text", file_path = fp, line = line, col = col}
|
||||
end
|
||||
|
||||
local fp = GetProjectPath().."/src/"..file_path
|
||||
if FileExists(fp) then
|
||||
return {kind = "text", file_path = fp, line = line, col = col}
|
||||
end
|
||||
|
||||
local fp = GetProjectPath().."/"..file_path
|
||||
if FileExists(fp) then
|
||||
return {kind = "text", file_path = fp, line = line, col = col}
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
function MatchGrep(s)
|
||||
return {kind = "exec", cmd = "git grep -n "..GetLoadWord().." :/", working_dir = GetProjectPath()}
|
||||
end
|
||||
|
||||
table.insert(OnCommandCallbacks, OnCommandTE)
|
||||
table.insert(Rules, 1, MatchGrep)
|
||||
table.insert(Rules, MatchProject)
|
||||
Reference in New Issue
Block a user