Improve ApplyRules
This commit is contained in:
@@ -176,6 +176,15 @@ char *C(const char *value) {
|
||||
}
|
||||
|
||||
S8_String LuaScript = R"==(
|
||||
KEY_CTRL = 1073742048
|
||||
KEY_PAGE_DOWN = 1073741902
|
||||
KEY_PAGE_UP = 1073741899
|
||||
KEY_DOWN = 1073741905 -- 0x40000051
|
||||
KEY_UP = 1073741906 -- 0x40000052u
|
||||
KEY_RIGHT = 1073741903
|
||||
KEY_LEFT = 1073741904
|
||||
KEY_Q = 113
|
||||
|
||||
function SkipLineAndColumn(s)
|
||||
local line, col = "1", "1"
|
||||
|
||||
@@ -294,7 +303,11 @@ function MatchWindowsPath(_s)
|
||||
end
|
||||
local line, col, s = SkipLineAndColumn(s)
|
||||
|
||||
print("OPEN :: INPUT = ".._s.." KIND = ".."text".." ".."FILE_PATH = "..file_path.."["..line..","..col.."]")
|
||||
local exists = FileExists(file_path) or BufferNameExists(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
|
||||
|
||||
@@ -303,7 +316,16 @@ function MatchGitCommit(s)
|
||||
if i then
|
||||
s = s:sub(8)
|
||||
local command = "git --no-pager show "..s
|
||||
return {kind = "exec", cmd = command, working_dir = GetActiveMainWindowBufferName()}
|
||||
return {kind = "exec", cmd = command, working_dir = GetActiveMainWindowBufferDir()}
|
||||
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()}
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@@ -311,6 +333,7 @@ end
|
||||
Rules = {
|
||||
MatchWindowsPath,
|
||||
MatchGitCommit,
|
||||
MatchURL,
|
||||
}
|
||||
|
||||
function ApplyRules(s)
|
||||
|
||||
Reference in New Issue
Block a user