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

@@ -98,8 +98,6 @@ Color.Selection = GruvboxLight1
Color.WhitespaceDuringSelection = GruvboxLight2
-- @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)
@@ -108,7 +106,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
@@ -136,8 +134,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+$")
@@ -208,7 +206,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)