Error reporting and popup, debug window
This commit is contained in:
126
build_file.cpp
126
build_file.cpp
@@ -185,6 +185,131 @@ char *ToColor(const char *value) {
|
||||
return f.str;
|
||||
}
|
||||
|
||||
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)
|
||||
-- ./something
|
||||
-- add working directory
|
||||
local working_dir_i, working_dir_j = string.find(s, "^%./.+")
|
||||
if working_dir_j then
|
||||
result = s:sub(3)
|
||||
result = WorkingDir.."/"..result
|
||||
return result
|
||||
end
|
||||
|
||||
-- C:/something
|
||||
local abs_i, abs_j = string.find(s, "^%a:/.+")
|
||||
if abs_i then
|
||||
return s
|
||||
end
|
||||
|
||||
-- C:\something
|
||||
local abs_i, abs_j = s:find("^%a:\\.+")
|
||||
if abs_i then
|
||||
s = s:gsub("\\", "/")
|
||||
return s
|
||||
end
|
||||
|
||||
-- /mnt/something
|
||||
local abs_i, abs_j = s:find("^/.*")
|
||||
if abs_i then
|
||||
return s
|
||||
end
|
||||
|
||||
-- other_random_filename
|
||||
return s
|
||||
end
|
||||
|
||||
function match_line_col(s)
|
||||
local line = 0
|
||||
local col = 0
|
||||
|
||||
-- filename:line:column
|
||||
local lci, lcj = s:find(":%d+:%d+$")
|
||||
if lci then
|
||||
local line_and_col = s:sub(lci, lcj)
|
||||
local i, j = line_and_col:find("%d+")
|
||||
line = line_and_col:sub(i, j)
|
||||
col = line_and_col:sub(j + 2, -1)
|
||||
s = s:sub(1, lci - 1)
|
||||
return line, col, s
|
||||
else
|
||||
local li, lj = s:find(":%d+$")
|
||||
if li then
|
||||
local line_string = s:sub(li, lj)
|
||||
line = line_string:sub(2, -1)
|
||||
s = s:sub(1, li - 1)
|
||||
return line, col, s
|
||||
end
|
||||
end
|
||||
|
||||
-- filename(line,col):
|
||||
local lci, lcj = s:find("%(%d+,%d+%):$")
|
||||
if lci then
|
||||
local line_and_col = s:sub(lci, lcj)
|
||||
local i, j = line_and_col:find("%d+")
|
||||
line = line_and_col:sub(i, j)
|
||||
col = line_and_col:sub(j + 2, -3)
|
||||
s = s:sub(1, lci - 1)
|
||||
return line, col, s
|
||||
else
|
||||
local li, lj = s:find("(%d+):$")
|
||||
if li then
|
||||
local line_string = s:sub(li, lj)
|
||||
line = line_string:sub(2, -3)
|
||||
s = s:sub(1, li - 1)
|
||||
return line, col, s
|
||||
end
|
||||
end
|
||||
|
||||
-- filename(line,col)
|
||||
local lci, lcj = s:find("%(%d+,%d+%)$")
|
||||
if lci then
|
||||
local line_and_col = s:sub(lci, lcj)
|
||||
local i, j = line_and_col:find("%d+")
|
||||
line = line_and_col:sub(i, j)
|
||||
col = line_and_col:sub(j + 2, -2)
|
||||
s = s:sub(1, lci - 1)
|
||||
return line, col, s
|
||||
else
|
||||
local li, lj = s:find("(%d+)$")
|
||||
if li then
|
||||
local line_string = s:sub(li, lj)
|
||||
line = line_string:sub(2, -2)
|
||||
s = s:sub(1, li - 1)
|
||||
return line, col, s
|
||||
end
|
||||
end
|
||||
|
||||
return 0, 0, s
|
||||
end
|
||||
|
||||
line, col, _s = match_line_col(_s)
|
||||
file_path = match_path(_s)
|
||||
return {kind = "open_textfile", file_path = file_path, line = line, col = col}
|
||||
end
|
||||
|
||||
|
||||
Rules = {}
|
||||
Rules[#Rules + 1] = GenericTextFileRule
|
||||
|
||||
function ResolvePath(s)
|
||||
for i = #Rules,1,-1 do
|
||||
rule = Rules[i]
|
||||
result = rule(s)
|
||||
if result then
|
||||
return result
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
)==";
|
||||
|
||||
void GenerateConfig() {
|
||||
struct Color {
|
||||
const char *name;
|
||||
@@ -257,6 +382,7 @@ void GenerateConfig() {
|
||||
For(gruvbox) sb.add(Fmt("local %s = %s", it.name, it.value));
|
||||
sb.add("Color = {}");
|
||||
For(colors) sb.add(Fmt("Color.%s = %s", it.name, it.value));
|
||||
sb.add(LuaScript);
|
||||
}
|
||||
sb.add(")==\";");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user