Toying with windows paths, ExecInNewBuffer, c'', Fix caret loss in title bar
This commit is contained in:
@@ -176,7 +176,56 @@ char *C(const char *value) {
|
||||
}
|
||||
|
||||
S8_String LuaScript = R"==(
|
||||
function ExtractLineAndColumn(s)
|
||||
function SkipLineAndColumn(s)
|
||||
local line, col = "1", "1"
|
||||
|
||||
function parse_line_and_column(line_and_col, delimiter)
|
||||
ic, jc = line_and_col:find(delimiter)
|
||||
line = line_and_col:sub(1, ic - 1)
|
||||
col = line_and_col:sub(ic + 1)
|
||||
return line, col
|
||||
end
|
||||
|
||||
do -- :line:column
|
||||
local i, j = s:find("^:%d+:%d+")
|
||||
if i then
|
||||
skip_pattern = s:sub(j + 1)
|
||||
line, col = parse_line_and_column(s:sub(2, j), ":")
|
||||
return line, col, skip_pattern
|
||||
end
|
||||
end
|
||||
|
||||
do -- :line
|
||||
local i, j = s:find("^:%d+")
|
||||
if i then
|
||||
skip_pattern = s:sub(j + 1)
|
||||
line = s:sub(2, j)
|
||||
return line, col, skip_pattern
|
||||
end
|
||||
end
|
||||
|
||||
do -- (line,column)
|
||||
local i, j = s:find("^%(%d+,%d+%)")
|
||||
if i then
|
||||
skip_pattern = s:sub(j + 1)
|
||||
line, col = parse_line_and_column(s:sub(2, j - 1), ",")
|
||||
return line, col, skip_pattern
|
||||
end
|
||||
end
|
||||
|
||||
do -- (line)
|
||||
local i, j = s:find("^%(%d+%)")
|
||||
if i then
|
||||
skip_pattern = s:sub(j + 1)
|
||||
line = s:sub(2, j - 1)
|
||||
return line, col, skip_pattern
|
||||
end
|
||||
end
|
||||
|
||||
return line, col, s
|
||||
end
|
||||
|
||||
function ChopLineAndColumn(s)
|
||||
local line = 1
|
||||
local col = 1
|
||||
|
||||
@@ -237,7 +286,7 @@ function ExtractLineAndColumn(s)
|
||||
end
|
||||
end
|
||||
|
||||
return -1, -1, s
|
||||
return 1, 1, s
|
||||
end
|
||||
|
||||
function BufferNameExists(name)
|
||||
@@ -251,6 +300,13 @@ function BufferNameExists(name)
|
||||
return false
|
||||
end
|
||||
|
||||
function ChopColon(s)
|
||||
if s:sub(-1) == ':' then
|
||||
s = s:sub(1, -2)
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
function GenericTextFileRule(_s)
|
||||
function match_path(s)
|
||||
-- ./something
|
||||
@@ -258,7 +314,7 @@ function GenericTextFileRule(_s)
|
||||
local working_dir_i, working_dir_j = string.find(s, "^%./.+")
|
||||
if working_dir_j then
|
||||
result = s:sub(3)
|
||||
result = GetWorkingDir().."/"..result
|
||||
result = GetCurrentBufferDir().."/"..result
|
||||
return result
|
||||
end
|
||||
|
||||
@@ -294,13 +350,14 @@ function GenericTextFileRule(_s)
|
||||
end
|
||||
end
|
||||
|
||||
line, col, _s = ExtractLineAndColumn(_s)
|
||||
line, col, _s = ChopLineAndColumn(_s)
|
||||
_s = ChopColon(_s)
|
||||
file_path = match_path(_s)
|
||||
return {kind = "text", file_path = file_path, line = line, col = col}
|
||||
end
|
||||
|
||||
function MatchAgainstIncludes(s)
|
||||
line, col, s = ExtractLineAndColumn(s)
|
||||
line, col, s = ChopLineAndColumn(s)
|
||||
include_paths = {
|
||||
"C:/Work/text_editor/src",
|
||||
"C:/Work/text_editor/src/text_editor",
|
||||
|
||||
Reference in New Issue
Block a user