Skip to content

Commit

Permalink
stand-alone color import helper + more schemes
Browse files Browse the repository at this point in the history
This just takes the json output from https://terminal.sexy
  • Loading branch information
letoram committed Mar 28, 2021
1 parent 0cc933c commit eb5a081
Show file tree
Hide file tree
Showing 12 changed files with 673 additions and 23 deletions.
34 changes: 17 additions & 17 deletions durden/devmaps/colorschemes/dracula.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ return {
{}, -- secondary (alternate base color)
{0x28, 0x2a, 0x36}, -- background
{0xf8, 0xf8, 0xf2, 0x28, 0x2a, 0x36}, -- text (foreground+background)
{0x97, 0x1a}, -- cursor (normal state)
{0x97, 0x1a, 0x00}, -- cursor (normal state)
{0xd7, 0x99, 0x21}, -- alt-cursor (scrollback/special state)
{0x44, 0x47, 0x5a}, -- highlight selection, active-word (foreground+background)
{}, -- label : prompts, data labels (foreground+background)
Expand All @@ -19,22 +19,22 @@ return {
{0xfb, 0xf1, 0xc7, 0x07, 0x66, 0x78}, -- ui : generic UI elements like menubar

-- terminal clients below --
{0x21, 0x22, 0x2c}, -- black
{0xff, 0x55, 0x55}, -- red
{0x50, 0xfa, 0x7b}, -- green
{0xf1, 0xfa, 0x8c}, -- yellow
{0xbd, 0x93, 0xf9}, -- blue
{0xff, 0x79, 0xc6}, -- magenta
{0x88, 0xe9, 0xfd}, -- cyan
{0xf8, 0xf8, 0xf2}, -- light-grey
{0x62, 0x72, 0xa4}, -- dark-grey
{0xff, 0x6e, 0x6e}, -- light-red
{0x69, 0xff, 0x94}, -- light-green
{0xff, 0xff, 0xa5}, -- light-yellow
{0xd6, 0xac, 0xff}, -- light-blue
{0xff, 0x92, 0xdf}, -- light-magenta
{0xa4, 0xff, 0xff}, -- light-cyan
{0xff, 0xff, 0xff}, -- white
{0x21, 0x22, 0x2c}, -- black 1
{0xff, 0x55, 0x55}, -- red 2
{0x50, 0xfa, 0x7b}, -- green 3
{0xf1, 0xfa, 0x8c}, -- yellow 4
{0xbd, 0x93, 0xf9}, -- blue 5
{0xff, 0x79, 0xc6}, -- magenta 6
{0x88, 0xe9, 0xfd}, -- cyan 7
{0xf8, 0xf8, 0xf2}, -- light-grey 8
{0x62, 0x72, 0xa4}, -- dark-grey 9
{0xff, 0x6e, 0x6e}, -- light-red 10
{0x69, 0xff, 0x94}, -- light-green 11
{0xff, 0xff, 0xa5}, -- light-yellow 12
{0xd6, 0xac, 0xff}, -- light-blue 13
{0xff, 0x92, 0xdf}, -- light-magenta 14
{0xa4, 0xff, 0xff}, -- light-cyan 15
{0xff, 0xff, 0xff}, -- white 16

{0xf8, 0xf8, 0xf2}, -- foreground
{0x28, 0x2a, 0x36}, -- background
Expand Down
2 changes: 1 addition & 1 deletion durden/devmaps/colorschemes/gruvbox-light.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ return {
{0xeb, 0xdb, 0xb2}, -- white

{0x3c, 0x38, 0x36}, -- foreground
{0xf9, 0xf5, 0xd7}, {0xf9, 0xf5, 0xd7}-- background
{0xf9, 0xf5, 0xd7} -- background
}
36 changes: 36 additions & 0 deletions durden/devmaps/colorschemes/solarized-light.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- scheme:
-- by:
return {
{88, 110, 117},
{}, -- secondary
{253, 246, 227},
{88, 110, 227, 253, 246, 227},
{88, 110, 117},
{}, -- alt-cursor
{}, -- highlight
{}, -- label
{}, -- warning
{}, -- error
{}, -- alert
{}, -- reference
{}, -- inactive
{}, -- ui
{0, 43, 54},
{220, 50, 47},
{133, 153, 0},
{181, 137, 0},
{38, 139, 210},
{108, 113, 196},
{42, 161, 152},
{147, 161, 161},
{101, 123, 131},
{220, 50, 47},
{133, 153, 0},
{181, 137, 0},
{38, 139, 210},
{108, 113, 196},
{42, 161, 152},
{253, 246, 227},
{88, 110, 117},
{253, 246, 227},
}
36 changes: 36 additions & 0 deletions durden/devmaps/colorschemes/solarized.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- scheme:
-- by:
return {
{147, 161, 161},
{}, -- secondary
{0, 43, 54},
{147, 161, 54, 0, 43, 54},
{147, 161, 161},
{}, -- alt-cursor
{}, -- highlight
{}, -- label
{}, -- warning
{}, -- error
{}, -- alert
{}, -- reference
{}, -- inactive
{}, -- ui
{0, 43, 54},
{220, 50, 47},
{133, 153, 0},
{181, 137, 0},
{38, 139, 210},
{108, 113, 196},
{42, 161, 152},
{147, 161, 161},
{101, 123, 131},
{220, 50, 47},
{133, 153, 0},
{181, 137, 0},
{38, 139, 210},
{108, 113, 196},
{42, 161, 152},
{253, 246, 227},
{147, 161, 161},
{0, 43, 54},
}
34 changes: 34 additions & 0 deletions durden/devmaps/colorschemes/srcery.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
return {
{252, 232, 195},
{}, -- secondary
{28, 27, 25},
{252, 232, 25, 28, 27, 25},
{251, 184, 41},
{4, 71, 214},
{}, -- highlight
{}, -- label
{}, -- warning
{}, -- error
{}, -- alert
{}, -- reference
{}, -- inactive
{}, -- ui
{28, 27, 25},
{239, 47, 39},
{81, 159, 80},
{251, 184, 41},
{44, 120, 191},
{224, 44, 109},
{10, 174, 179},
{208, 191, 161},
{145, 129, 117},
{247, 83, 65},
{152, 188, 55},
{254, 208, 110},
{104, 168, 228},
{255, 92, 143},
{83, 253, 233},
{252, 232, 195},
{252, 232, 195},
{28, 27, 25},
}
34 changes: 34 additions & 0 deletions durden/devmaps/colorschemes/twilight.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
return {
{167, 167, 167},
{30, 30, 30},
{}, -- background
{167, 167, 30, 30, 30, 30},
{}, -- cursor
{}, -- alt-cursor
{}, -- highlight
{}, -- label
{}, -- warning
{}, -- error
{}, -- alert
{}, -- reference
{}, -- inactive
{}, -- ui
{30, 30, 30},
{207, 106, 76},
{143, 157, 106},
{249, 238, 152},
{117, 135, 166},
{155, 133, 157},
{175, 196, 219},
{167, 167, 167},
{95, 90, 96},
{207, 106, 76},
{143, 157, 106},
{249, 238, 152},
{117, 135, 166},
{155, 133, 157},
{175, 196, 219},
{255, 255, 255},
{167, 167, 167},
{30, 30, 30},
}
15 changes: 11 additions & 4 deletions durden/extevh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,12 @@ function extevh_apply_atype(wnd, atype, source, stat)
if (atbl.init) then
atbl:init(wnd, source);
end
end

-- very rarely needed
for k,v in ipairs(wnd.handlers.register) do
v(wnd, stat.segkind, stat);
end
-- this is not overridable so we need to check if we should chain into the
-- dispatch for the type
defhtbl["preroll"] =
function(wnd, source, stat)
end

defhtbl["registered"] =
Expand Down Expand Up @@ -501,8 +502,14 @@ function(wnd, source, stat)
"registered:name=%s:kind=%s", wnd.name, stat.segkind));
end
extevh_apply_atype(wnd, stat.segkind, source, stat);

wnd:set_title(stat.title);
wnd:set_guid(stat.guid);

-- very rarely needed
for k,v in ipairs(wnd.handlers.register) do
v(wnd, stat.segkind, stat);
end
end

-- stateinf is used in the builtin/shared
Expand Down
3 changes: 2 additions & 1 deletion durden/menus/global/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ return {
},
{
name = "colorscheme",
label = "Scheme",
label = "Tui/Terminal Scheme",
kind = "value",
description = "Change the current and default set of colors used for terminal/tui clients",
set = function()
return suppl_colorschemes()
end,
Expand Down
1 change: 1 addition & 0 deletions durden/menus/global/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ return {
name = "colorscheme",
label = "Scheme",
kind = "value",
description = "Change the current and default set of colors used for terminal/tui clients",
set = function()
return suppl_colorschemes()
end,
Expand Down
2 changes: 2 additions & 0 deletions durden/suppl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,8 @@ function suppl_tgt_color(vid, cmap)
end
end
tbl = color_cache[cmap]
else
tbl = cmap
end

if not tbl then
Expand Down
99 changes: 99 additions & 0 deletions util/color_conv.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
-- This is a simple stand-alone script for converting json export output
-- from https://terminal.sexy into color-schemes that can be used as part
-- of target/video/color/schemes and global/settings/visual/colors/...

local json = dofile('./json.lua')

if not arg[1] or not arg[2] then
error("use: color-in.json color-out.lua")
end

file = io.open(arg[1])

local inp = file:read("*all")
local res = json.decode(inp)

local rt =
{
"{}, -- primary",
"{}, -- secondary",
"{}, -- background",
"{}, -- text",
"{}, -- cursor",
"{}, -- alt-cursor",
"{}, -- highlight",
"{}, -- label",
"{}, -- warning",
"{}, -- error",
"{}, -- alert",
"{}, -- reference",
"{}, -- inactive",
"{}, -- ui"
}

local term_i = 15
local function getcol(v)
local r = string.sub(v, 2, 3)
local g = string.sub(v, 4, 5)
local b = string.sub(v, 6, 7)
return {
tonumber(r, 16),
tonumber(g, 16),
tonumber(b, 16)
}
end

-- 1..16 + foreground and background
for k,v in pairs(res.color) do
local col = getcol(v)
table.insert(rt, string.format("{%d, %d, %d},", col[1], col[2], col[3]))
end

if res.foreground then
local col = getcol(res.foreground)
table.insert(rt, string.format("{%d, %d, %d},", col[1], col[2], col[3]))
rt[1] = rt[#rt]

if res.background then
local col2 = getcol(res.background)
table.insert(rt, string.format("{%d, %d, %d},", col2[1], col2[2], col2[3]))
rt[3] = rt[#rt]
rt[4] = string.format("{%d, %d, %d, %d, %d, %d},",
col[1], col[2], col2[3], col2[1], col2[2], col2[3])
end
end

if res.cursor then
local col = getcol(res.cursor)
rt[5] = string.format("{%d, %d, %d},", col[1], col[2], col[3])
rt[6] = string.format("{%d, %d, %d},", 255 - col[1], 255 - col[2], 255 - col[3])
else
rt[5] = rt[1]
end

-- auto-assign into labeled slots is worse, some base assumptions might be possible,
-- e.g. error tends to be terminal
--
-- 'red', warning terminal 'yellow', inactive 'dark-grey' and sanity check against
-- fg/bg values. but might as well do this somewhere else
--
-- label (8), warning (9), error (10), alert (11), ref (12), inactive (13), ui (14)
--
local out = io.output(arg[2])

if res.name then
out:write("-- scheme: " .. res.name .. "\n")
end

if res.author then
out:write("-- by: " .. res.author .. "\n")
end

out:write("return {\n")

for _,v in ipairs(rt) do
out:write(v .. "\n")
end

out:write("}")
out:close()
Loading

0 comments on commit eb5a081

Please sign in to comment.