262 lines
7.9 KiB
C++
262 lines
7.9 KiB
C++
String BaseLuaConfig = R"==(
|
|
local GruvboxDark0Hard = 0x1d2021ff
|
|
local GruvboxDark0 = 0x282828ff
|
|
local GruvboxDark0Soft = 0x32302fff
|
|
local GruvboxDark1 = 0x3c3836ff
|
|
local GruvboxDark2 = 0x504945ff
|
|
local GruvboxDark3 = 0x665c54ff
|
|
local GruvboxDark4 = 0x7c6f64ff
|
|
local GruvboxGray245 = 0x928374ff
|
|
local GruvboxGray244 = 0x928374ff
|
|
local GruvboxLight0Hard = 0xf9f5d7ff
|
|
local GruvboxLight0 = 0xfbf1c7ff
|
|
local GruvboxLight0Soft = 0xf2e5bcff
|
|
local GruvboxLight1 = 0xebdbb2ff
|
|
local GruvboxLight2 = 0xd5c4a1ff
|
|
local GruvboxLight3 = 0xbdae93ff
|
|
local GruvboxLight4 = 0xa89984ff
|
|
local GruvboxBrightRed = 0xfb4934ff
|
|
local GruvboxBrightGreen = 0xb8bb26ff
|
|
local GruvboxBrightYellow = 0xfabd2fff
|
|
local GruvboxBrightBlue = 0x83a598ff
|
|
local GruvboxBrightPurple = 0xd3869bff
|
|
local GruvboxBrightAqua = 0x8ec07cff
|
|
local GruvboxBrightOrange = 0xfe8019ff
|
|
local GruvboxNeutralRed = 0xcc241dff
|
|
local GruvboxNeutralGreen = 0x98971aff
|
|
local GruvboxNeutralYellow = 0xd79921ff
|
|
local GruvboxNeutralBlue = 0x458588ff
|
|
local GruvboxNeutralPurple = 0xb16286ff
|
|
local GruvboxNeutralAqua = 0x689d6aff
|
|
local GruvboxNeutralOrange = 0xd65d0eff
|
|
local GruvboxFadedRed = 0x9d0006ff
|
|
local GruvboxFadedGreen = 0x79740eff
|
|
local GruvboxFadedYellow = 0xb57614ff
|
|
local GruvboxFadedBlue = 0x076678ff
|
|
local GruvboxFadedPurple = 0x8f3f71ff
|
|
local GruvboxFadedAqua = 0x427b58ff
|
|
local GruvboxFadedOrange = 0xaf3a03ff
|
|
Color = {}
|
|
Color.Text = GruvboxDark0Hard
|
|
Color.LoadTextHighlight = 0x0000000F
|
|
Color.Background = GruvboxLight0Hard
|
|
Color.InactiveWindow = 0x0000000F
|
|
Color.TextLineNumbers = GruvboxDark4
|
|
Color.LineHighlight = GruvboxLight0Soft
|
|
Color.MainCaret = GruvboxDark0Hard
|
|
Color.SubCaret = GruvboxGray245
|
|
Color.Selection = GruvboxLight1
|
|
Color.WhitespaceDuringSelection = GruvboxLight4
|
|
Color.FuzzySearchLineHighlight = GruvboxDark0
|
|
Color.ScrollbarBackground = GruvboxLight2
|
|
Color.ScrollbarScroller = GruvboxLight1
|
|
Color.ScrollbarScrollerSelected = GruvboxLight0Hard
|
|
Color.TitleBarText = GruvboxDark2
|
|
Color.TitleBarBackground = GruvboxLight1
|
|
Color.TitleBarSelection = GruvboxLight3
|
|
Style = {}
|
|
Style.DrawLineNumbers = 1
|
|
Style.DrawScrollbar = 1
|
|
Style.IndentSize = 4
|
|
Style.TrimWhitespaceOnSave = 1
|
|
Style.FontSize = 12
|
|
Style.FontFilter = 0
|
|
Style.Font = "C:/Windows/Fonts/consola.ttf"
|
|
|
|
-- @todo: should we rewrite linux paths to windows on windows and vice-versa?
|
|
|
|
function ExtractLineAndColumn(s)
|
|
local line = 1
|
|
local col = 1
|
|
|
|
-- 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 -1, -1, s
|
|
end
|
|
|
|
function BufferNameExists(name)
|
|
buffers = GetBufferList()
|
|
for i = 1,#buffers do
|
|
buff = buffers[i]
|
|
if buff == name then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
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 = GetWorkingDir().."/"..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
|
|
|
|
if BufferNameExists(s) then
|
|
return s
|
|
end
|
|
|
|
-- other_random_filename
|
|
buffer_dir = GetCurrentBufferDir()
|
|
if buffer_dir:len() == 0 then
|
|
return s
|
|
else
|
|
return buffer_dir..'/'..s
|
|
end
|
|
end
|
|
|
|
line, col, _s = ExtractLineAndColumn(_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)
|
|
include_paths = {
|
|
"C:/Work/text_editor/src",
|
|
"C:/Work/text_editor/src/text_editor",
|
|
}
|
|
for i = 1,#include_paths do
|
|
file_path = include_paths[i] .. '/' .. s
|
|
if FileExists(file_path) then
|
|
return {kind = "text", file_path = file_path, line = line, col = col}
|
|
end
|
|
end
|
|
|
|
return nil
|
|
end
|
|
|
|
function MatchGitCommit(s)
|
|
local i, j = string.find(s, "^commit ")
|
|
print(tostring(i))
|
|
if i then
|
|
local command = "git --no-pager show "..s
|
|
return {kind = "exec", cmd = command, working_dir = GetCurrentBufferDir()}
|
|
end
|
|
return nil
|
|
end
|
|
|
|
Rules = {
|
|
GenericTextFileRule,
|
|
MatchAgainstIncludes,
|
|
MatchGitCommit,
|
|
}
|
|
|
|
|
|
function ApplyRules(s)
|
|
for i = #Rules,1,-1 do
|
|
rule = Rules[i]
|
|
result = rule(s)
|
|
if result then
|
|
return result
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
|
|
)==";
|
|
void ReloadStyle() {
|
|
ColorText = GetColor("Text", ColorText);
|
|
ColorLoadTextHighlight = GetColor("LoadTextHighlight", ColorLoadTextHighlight);
|
|
ColorBackground = GetColor("Background", ColorBackground);
|
|
ColorInactiveWindow = GetColor("InactiveWindow", ColorInactiveWindow);
|
|
ColorTextLineNumbers = GetColor("TextLineNumbers", ColorTextLineNumbers);
|
|
ColorLineHighlight = GetColor("LineHighlight", ColorLineHighlight);
|
|
ColorMainCaret = GetColor("MainCaret", ColorMainCaret);
|
|
ColorSubCaret = GetColor("SubCaret", ColorSubCaret);
|
|
ColorSelection = GetColor("Selection", ColorSelection);
|
|
ColorWhitespaceDuringSelection = GetColor("WhitespaceDuringSelection", ColorWhitespaceDuringSelection);
|
|
ColorFuzzySearchLineHighlight = GetColor("FuzzySearchLineHighlight", ColorFuzzySearchLineHighlight);
|
|
ColorScrollbarBackground = GetColor("ScrollbarBackground", ColorScrollbarBackground);
|
|
ColorScrollbarScroller = GetColor("ScrollbarScroller", ColorScrollbarScroller);
|
|
ColorScrollbarScrollerSelected = GetColor("ScrollbarScrollerSelected", ColorScrollbarScrollerSelected);
|
|
ColorTitleBarText = GetColor("TitleBarText", ColorTitleBarText);
|
|
ColorTitleBarBackground = GetColor("TitleBarBackground", ColorTitleBarBackground);
|
|
ColorTitleBarSelection = GetColor("TitleBarSelection", ColorTitleBarSelection);
|
|
StyleDrawLineNumbers = GetStyleInt("DrawLineNumbers", StyleDrawLineNumbers);
|
|
StyleDrawScrollbar = GetStyleInt("DrawScrollbar", StyleDrawScrollbar);
|
|
StyleIndentSize = GetStyleInt("IndentSize", StyleIndentSize);
|
|
StyleTrimWhitespaceOnSave = GetStyleInt("TrimWhitespaceOnSave", StyleTrimWhitespaceOnSave);
|
|
StyleFontSize = GetStyleInt("FontSize", StyleFontSize);
|
|
StyleFontFilter = GetStyleInt("FontFilter", StyleFontFilter);
|
|
StyleFont = GetStyleString("Font", StyleFont);
|
|
} |