Using file path rules

This commit is contained in:
Krzosa Karol
2024-07-28 10:39:57 +02:00
parent a486a09d9e
commit d6b850178e
4 changed files with 66 additions and 41 deletions

View File

@@ -187,8 +187,6 @@ char *ToColor(const char *value) {
S8_String LuaScript = R"==(
-- @todo: should we rewrite linux paths to windows on windows and vice-versa?
WorkingDir = "C:/text_editor"
OperatingSystem = "Windows"
function GenericTextFileRule(_s)
function match_path(s)
@@ -197,7 +195,7 @@ function GenericTextFileRule(_s)
local working_dir_i, working_dir_j = string.find(s, "^%./.+")
if working_dir_j then
result = s:sub(3)
result = WorkingDir.."/"..result
result = GetWorkingDir().."/"..result
return result
end
@@ -225,8 +223,8 @@ function GenericTextFileRule(_s)
end
function match_line_col(s)
local line = 0
local col = 0
local line = 1
local col = 1
-- filename:line:column
local lci, lcj = s:find(":%d+:%d+$")
@@ -297,7 +295,7 @@ end
Rules = {}
Rules[#Rules + 1] = GenericTextFileRule
function ResolvePath(s)
function ApplyRules(s)
for i = #Rules,1,-1 do
rule = Rules[i]
result = rule(s)