lua api improvements
This commit is contained in:
@@ -184,6 +184,8 @@ char *C(const char *value) {
|
||||
}
|
||||
|
||||
S8_String LuaScript = R"==(
|
||||
INTERNET_BROWSER = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
||||
|
||||
SDLK_CTRL = 1073742048
|
||||
SDLK_PAGE_DOWN = 1073741902
|
||||
SDLK_PAGE_UP = 1073741899
|
||||
@@ -336,32 +338,19 @@ function SkipPath(s)
|
||||
return s, path, drive, cells
|
||||
end
|
||||
|
||||
function BufferNameExists(name)
|
||||
buffers = GetBufferList()
|
||||
for i = 1,#buffers do
|
||||
buff = buffers[i]
|
||||
if buff == name then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function MatchWindowsPath(_s)
|
||||
local s, file_path, drive = SkipPath(_s)
|
||||
if not file_path then return nil end
|
||||
|
||||
if not drive then
|
||||
local d = GetActiveMainWindowBufferDir()
|
||||
local d = GetDir()
|
||||
file_path = d..'/'..file_path
|
||||
end
|
||||
local line, col, s = SkipLineAndColumn(s)
|
||||
|
||||
local exists = FileExists(file_path) or BufferNameExists(file_path)
|
||||
local exists = FileExists(file_path) or BufferExists(file_path)
|
||||
if not exists then return nil end
|
||||
|
||||
|
||||
Print("OPEN :: INPUT = ".._s.." KIND = ".."text".." ".."FILE_PATH = "..file_path.."["..line..","..col.."]")
|
||||
return {kind = "text", file_path = file_path, line = line, col = col}
|
||||
end
|
||||
|
||||
@@ -370,16 +359,15 @@ function MatchGitCommit(s)
|
||||
if i then
|
||||
s = s:sub(8)
|
||||
local command = "git --no-pager show "..s
|
||||
return {kind = "exec", cmd = command, working_dir = GetActiveMainWindowBufferDir()}
|
||||
return {kind = "exec", cmd = command, working_dir = GetDir()}
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
InternetBrowser = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
||||
function MatchURL(s)
|
||||
local i, j = string.find(s, "^https://")
|
||||
if i then
|
||||
return {kind = "exec_console", cmd = '"'..InternetBrowser..'" '..s, working_dir = GetActiveMainWindowBufferDir()}
|
||||
return {kind = "exec_console", cmd = '"'..INTERNET_BROWSER..'" '..s, working_dir = GetDir()}
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@@ -429,8 +417,6 @@ table.insert(OnCommandCallbacks, function (e)
|
||||
Eval(GetLoadWord()) end
|
||||
end)
|
||||
|
||||
-- REMEBER: AS LITTLE ACTUAL CODE AS POSSIBLE IN LUA
|
||||
-- ONLY CONFIGURABLES
|
||||
function OnCommand(e)
|
||||
for i = #OnCommandCallbacks,1,-1 do
|
||||
on_command = OnCommandCallbacks[i]
|
||||
|
||||
Reference in New Issue
Block a user