summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.lua14
-rw-r--r--main.lua6
-rw-r--r--osd.lua63
3 files changed, 48 insertions, 35 deletions
diff --git a/config.lua b/config.lua
index 466d45a..0d56271 100644
--- a/config.lua
+++ b/config.lua
@@ -16,7 +16,7 @@ config.click_max_drift = 2
config.btn_timeout = 1
config.bg_alpha = '44'
-config.colours = {
+config.colour = {
title = '999999',
option = 'ffffff',
info = '666666',
@@ -43,6 +43,18 @@ config.colours = {
menu_btn_bg = '00cc00',
}
+config.icon = {
+ title = '»',
+ cursor = '›',
+ status = '🞸',
+ playing = '\xe2\x8f\xba',
+ active = '\xe2\x8f\xba',
+ favourite = '★',
+ missing = '!!!MISSING!!!',
+ sorted = '⇅',
+ menu_btn = '≡',
+}
+
local script_dir = mp.get_script_directory()
config.tmp_dir = os.getenv('XDG_RUNTIME_DIR') or '/tmp'
config.cache_dir = mp_utils.join_path(script_dir, 'cache')
diff --git a/main.lua b/main.lua
index 7b649ba..0ee88c7 100644
--- a/main.lua
+++ b/main.lua
@@ -678,7 +678,7 @@ local function add_info_field(dst, k, v, fmt)
-- continuation lines are 4 chars shorter and indented with 2 em spaces
for i, v in ipairs(util.wrap(str, 80, 76)) do
if i > 1 then
- v = '\226\128\131\226\128\131' .. v
+ v = '\xe2\x80\x83\xe2\x80\x83' .. v
end
dst[#dst+1] = {name = v}
end
@@ -928,7 +928,7 @@ end
local function start_search()
local menu = state:menu()
local title = 'Searching: <text_with_cursor>' ..
- ' <colours.info>(<num_matches>/<num_total>)'
+ ' <colour.info>(<num_matches>/<num_total>)'
if menu.type == 'search' then
-- resuming search, save previous state
@@ -957,7 +957,7 @@ local function end_search()
local menu = state:menu()
menu.search_active = false
menu.title = 'Search results: <text>' ..
- ' <colours.info>(<num_matches>/<num_total>)'
+ ' <colour.info>(<num_matches>/<num_total>)'
osd:dirty()
set_key_mapping('MENU')
end
diff --git a/osd.lua b/osd.lua
index 981d824..93f9f3f 100644
--- a/osd.lua
+++ b/osd.lua
@@ -8,16 +8,17 @@ local osd = {}
local mt = {}
mt.__index = mt
-local colours = {}
-for k, v in pairs(config.colours) do
+local colour = {}
+for k, v in pairs(config.colour) do
-- constructed backwards as ASS colour tags expect BGR but we configure
-- them as RGB
tag = '&}'
for byte in v:gmatch('..') do
tag = byte:upper() .. tag
end
- colours[k] = '{\\c&H' .. tag
+ colour[k] = '{\\c&H' .. tag
end
+local icon = config.icon
local bgra_file = mp_utils.join_path(
config.tmp_dir,
@@ -86,7 +87,7 @@ function mt:resize(w, h)
self.height = h
self.scale = h > 0 and h/720 or 1
- local sz = self.padding + self:measure_width('»') - 2
+ local sz = self.padding + self:measure_width(icon.title) - 2
local coords = {
x1 = 2,
y1 = self.padding + ((config.font_size - sz) / 2),
@@ -97,10 +98,10 @@ function mt:resize(w, h)
self.menu_btn_coords = coords
self.menu_btn.data =
'{\\pos(' .. coords.x1 .. ',' .. coords.y1 .. ')}' ..
- colours.menu_btn_bg .. draw_rect(0, 0, sz, sz) .. '\n' ..
+ colour.menu_btn_bg .. draw_rect(0, 0, sz, sz) .. '\n' ..
'{\\q2\\fs' .. sz .. '\\bord0\\an5\\pos(' ..
coords.x1 + sz/2 .. ',' .. coords.y1 + sz/2 ..')}' ..
- colours.menu_btn_fg .. '≡'
+ colour.menu_btn_fg .. icon.menu_btn
self.menu_btn:update()
end
@@ -141,9 +142,9 @@ function mt:status_line()
return ''
end
- local col = self.status_level == 'error' and colours.status_error or
- colours.status_info
- return col .. '🞸 {\\i1}' .. asscape(self.status_msg)
+ local col = self.status_level == 'error' and colour.status_error or
+ colour.status_info
+ return col .. icon.status .. ' {\\i1}' .. asscape(self.status_msg)
end
function mt:menu_lines(state)
@@ -153,7 +154,7 @@ end
function mt:menu_title(menu)
local str = asscape(menu.title)
- local col = menu.search_active and colours.selected or colours.title
+ local col = menu.search_active and colour.selected or colour.title
if menu.type == 'search' then
str = str:gsub('<text>', asscape(menu.search_text))
@@ -167,53 +168,53 @@ function mt:menu_title(menu)
menu.search_cursor)))
end
- str = str:gsub('<colours.info>', colours.info)
+ str = str:gsub('<colour.info>', colour.info)
str = str:gsub('<num_matches>', #menu.options)
str = str:gsub('<num_total>', #menu.search_options)
end
if menu.sorted then
- str = colours.icon_sorted .. '⇅ ' .. col .. str
+ str = colour.icon_sorted .. icon.sorted .. ' ' .. col .. str
end
- return col .. '» ' .. str
+ return col .. icon.title .. ' ' .. str
end
function mt:option_icons(opt, info)
local str = ''
if info.selected then
- str = colours.selected .. '› '
+ str = colour.selected .. icon.cursor .. ' '
end
if info.playing then
- str = str .. colours.icon_playing .. '\226\143\186 '
+ str = str .. colour.icon_playing .. icon.playing .. ' '
end
if info.favourited then
- str = str .. colours.icon_favourite .. '★ '
+ str = str .. colour.icon_favourite .. icon.favourite .. ' '
end
if opt.active then
- str = str .. colours.icon_active .. '\226\143\186 '
+ str = str .. colour.icon_active .. icon.active .. ' '
end
if opt.missing then
- str = str .. colours.icon_missing .. '!!!MISSING!!! '
+ str = str .. colour.icon_missing .. icon.missing .. ' '
end
return str
end
function mt:option_text(opt, info)
local str = opt.name
- local col = colours.option
+ local col = colour.option
if info.selected then
- col = info.empty and colours.selected_empty or colours.selected
+ col = info.empty and colour.selected_empty or colour.selected
elseif info.empty then
- col = colours.group_empty
+ col = colour.group_empty
elseif opt.type == 'group' then
- col = colours.group
+ col = colour.group
end
if opt.matches then
local buf = ''
- local hl_col = info.empty and colours.search_hl_empty or
- colours.search_hl
+ local hl_col = info.empty and colour.search_hl_empty or
+ colour.search_hl
local n = 0
for _, match in ipairs(opt.matches) do
@@ -233,7 +234,7 @@ function mt:option_text(opt, info)
end
if opt.info and #opt.info > 0 then
- str = str .. colours.info .. ' (' .. asscape(opt.info) .. ')'
+ str = str .. colour.info .. ' (' .. asscape(opt.info) .. ')'
end
return str
@@ -244,8 +245,8 @@ function mt:option_path(opt, info)
return ''
end
- local str = info.empty and colours.search_path_empty or
- colours.search_path
+ local str = info.empty and colour.search_path_empty or
+ colour.search_path
for i = #opt.path, 1, -1 do
str = str .. ' « ' .. asscape(opt.path[i].name)
end
@@ -449,10 +450,10 @@ function mt:render_bg()
local sb = self.out.scrollbar
if sb then
local hover = self.mstate and self.mstate.target == 'scrollbar'
- local fg = hover and colours.scrollbar_fg_hover or
- colours.scrollbar_fg
- local bg = hover and colours.scrollbar_bg_hover or
- colours.scrollbar_bg
+ local fg = hover and colour.scrollbar_fg_hover or
+ colour.scrollbar_fg
+ local bg = hover and colour.scrollbar_bg_hover or
+ colour.scrollbar_bg
self.bg.data = self.bg.data .. '\n' ..
-- bg