-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add light theme and configure with clprc.lua
- Loading branch information
Showing
8 changed files
with
177 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,6 @@ please create an issue or contact me directly at [email protected]. | |
2. musl (https://git.musl-libc.org/cgit/musl) | ||
3. Scintillua (https://github.com/orbitalquark/scintillua) | ||
4. optparse (https://github.com/skeeto/optparse) | ||
5. lua-term (https://github.com/hoelzro/lua-term) | ||
|
||
|
||
%% vis NOTICES AND INFORMATION BEGIN HERE | ||
========================================= | ||
|
@@ -318,30 +316,3 @@ For more information, please refer to <http://unlicense.org/> | |
|
||
========================================= | ||
END OF optparse NOTICES AND INFORMATION | ||
|
||
%% lua-term NOTICES AND INFORMATION BEGIN HERE | ||
========================================= | ||
|
||
Copyright (c) 2009 Rob Hoelz <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
========================================= | ||
END OF lua-term NOTICES AND INFORMATION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
clprc = {} | ||
clprc.custom_theme = "dark" | ||
return clprc |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
local style = {} | ||
local ansi_colors = {} | ||
local clprc = require('clprc') | ||
|
||
-- https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters | ||
local sgr_params = { | ||
reset = 0, | ||
clear = 0, | ||
default = 0, | ||
bright = 1, | ||
dim = 2, | ||
underscore = 4, | ||
blink = 5, | ||
reverse = 7, | ||
hidden = 8, | ||
|
||
-- TODO: get foreground values from external theme | ||
-- e.g. black = theme.black_sgr_number | ||
|
||
-- foreground | ||
black = 30, | ||
red = 31, | ||
green = 32, | ||
yellow = 33, | ||
blue = 34, | ||
magenta = 35, | ||
cyan = 36, | ||
white = 37, | ||
|
||
-- background | ||
onblack = 40, | ||
onred = 41, | ||
ongreen = 42, | ||
onyellow = 43, | ||
onblue = 44, | ||
onmagenta = 45, | ||
oncyan = 46, | ||
onwhite = 47, | ||
} | ||
|
||
-- converts a SGR parameter to an ANSI escape string | ||
-- https://en.wikipedia.org/wiki/ANSI_escape_code#Colors | ||
local function ansi_string(sgr_number) | ||
if(sgr_number > 47) then | ||
sgr_number = "38;5;" .. tostring(sgr_number) | ||
end | ||
return string.char(27) .. '[' .. tostring(sgr_number) .. 'm' | ||
end | ||
|
||
for sgr_name,sgr_number in pairs(sgr_params) do | ||
ansi_colors[sgr_name] = ansi_string(sgr_number) | ||
end | ||
|
||
-- TODO: get these values from external theme | ||
-- e.g. ['default'] = ansi_colors.default_color | ||
local dark_mode_syntax_highlight_style = { | ||
['default'] = ansi_colors.white, | ||
['nothing'] = '', | ||
['class'] = ansi_colors.yellow .. ansi_colors.bright, | ||
['comment'] = ansi_colors.blue .. ansi_colors.bright, | ||
['constant'] = ansi_colors.cyan .. ansi_colors.bright, | ||
['definition'] = ansi_colors.blue .. ansi_colors.bright, | ||
['error'] = ansi_colors.red .. ansi_colors.underscore, | ||
['function'] = ansi_colors.blue .. ansi_colors.bright, | ||
['keyword'] = ansi_colors.yellow .. ansi_colors.bright, | ||
['label'] = ansi_colors.green .. ansi_colors.bright, | ||
['number'] = ansi_colors.red .. ansi_colors.bright, | ||
['operator'] = ansi_colors.cyan .. ansi_colors.bright, | ||
['regex'] = ansi_colors.green .. ansi_colors.bright, | ||
['string'] = ansi_colors.red .. ansi_colors.bright, | ||
['preprocessor'] = ansi_colors.magenta .. ansi_colors.bright, | ||
['tag'] = ansi_colors.red .. ansi_colors.bright, | ||
['type'] = ansi_colors.green .. ansi_colors.bright, | ||
['variable'] = ansi_colors.blue .. ansi_colors.bright, | ||
['whitespace'] = '', | ||
['embedded'] = ansi_colors.magenta .. ansi_colors.bright, | ||
['identifier'] = ansi_colors.white, | ||
} | ||
|
||
local light_mode_syntax_highlight_style = { | ||
['default'] = ansi_colors.black, | ||
['nothing'] = '', | ||
['class'] = ansi_colors.magenta .. ansi_colors.bright, | ||
['comment'] = ansi_colors.blue .. ansi_colors.bright, | ||
['constant'] = ansi_colors.cyan .. ansi_colors.bright, | ||
['definition'] = ansi_colors.blue .. ansi_colors.bright, | ||
['error'] = ansi_colors.red .. ansi_colors.underscore, | ||
['function'] = ansi_colors.blue .. ansi_colors.bright, | ||
['keyword'] = ansi_colors.blue.. ansi_colors.bright, | ||
['label'] = ansi_colors.green .. ansi_colors.bright, | ||
['number'] = ansi_colors.red .. ansi_colors.bright, | ||
['operator'] = ansi_colors.black .. ansi_colors.bright, | ||
['regex'] = ansi_colors.green .. ansi_colors.bright, | ||
['string'] = ansi_colors.red .. ansi_colors.bright, | ||
['preprocessor'] = ansi_colors.magenta .. ansi_colors.bright, | ||
['tag'] = ansi_colors.red .. ansi_colors.bright, | ||
['type'] = ansi_colors.cyan .. ansi_colors.bright, | ||
['variable'] = ansi_colors.blue .. ansi_colors.bright, | ||
['whitespace'] = '', | ||
['embedded'] = ansi_colors.magenta .. ansi_colors.bright, | ||
['identifier'] = ansi_colors.black, | ||
} | ||
|
||
local line_highlight_style = { | ||
['default'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['nothing'] = '' .. ansi_colors.onwhite, | ||
['class'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['comment'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['constant'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['definition'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['error'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['function'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['keyword'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['label'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['number'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['operator'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['regex'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['string'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['preprocessor'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['tag'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['type'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['variable'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['whitespace'] = '' .. ansi_colors.onwhite, | ||
['embedded'] = ansi_colors.black .. ansi_colors.onwhite, | ||
['identifier'] = ansi_colors.black .. ansi_colors.onwhite, | ||
} | ||
|
||
style.reset_sequence = ansi_string(sgr_params.reset) | ||
style.line_highlight_style = line_highlight_style | ||
|
||
-- TODO: temporary hack, remove when external themes implemented | ||
if clprc ~= nil and clprc.custom_theme == "light" then | ||
style.syntax_highlight_style = light_mode_syntax_highlight_style | ||
else | ||
style.syntax_highlight_style = dark_mode_syntax_highlight_style | ||
end | ||
|
||
return style |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function copy_table(t) | ||
local t2 = {} | ||
for k, v in pairs(t) do | ||
t2[k] = v | ||
end | ||
return t2 | ||
end |
Oops, something went wrong.