add header and update print function

This commit is contained in:
ksyasuda 2023-08-03 20:35:48 -07:00
parent f9ac4b6d18
commit 28c3855370
2 changed files with 37 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 861 KiB

After

Width:  |  Height:  |  Size: 703 KiB

View File

@ -39,16 +39,29 @@ local options = {
clipboard_command = "xclip -o", clipboard_command = "xclip -o",
display_limit = 6, display_limit = 6,
cursor_icon = "🠺", cursor_icon = "🠺",
font_size = 24, font_size = 12,
font_name = "JetBrains Mono" font_name = "JetBrains Mono"
} }
local colors = { local colors = {
error = "676EFF", error = "676EFF",
text = "BFBFBF", selected = "F993BD",
selected_color = "F993BD", hover_selected = "FAA9CA",
cursor = "FDE98B", cursor = "FDE98B",
reset = "{\\c&BFBFBF&}" header = "8CFAF1",
hover = "F2F8F8",
text = "BFBFBF"
}
local style = {
error = "{\\c&" .. colors.error .. "&}",
selected = "{\\c&" .. colors.selected .. "&}",
hover_selected = "{\\c&" .. colors.hover_selected .. "&}",
cursor = "{\\c&" .. colors.cursor .. "&}",
reset = "{\\c&" .. colors.text .. "&}",
header = "{\\c&" .. colors.header .. "&}",
hover = "{\\c&" .. colors.hover .. "&}",
font = "{\\fn" .. options.font_name .. "\\fs" .. options.font_size .. "}"
} }
mp.options.read_options(options, "mpv-youtube-queue") mp.options.read_options(options, "mpv-youtube-queue")
@ -195,27 +208,35 @@ function YouTubeQueue.print_queue(duration)
local current_index = index local current_index = index
if not duration then duration = 3 end if not duration then duration = 3 end
if #video_queue > 0 then if #video_queue > 0 then
local message = ""
local start_index = math.max(1, selected_index - display_limit / 2) local start_index = math.max(1, selected_index - display_limit / 2)
local end_index = local end_index =
math.min(#video_queue, start_index + display_limit - 1) math.min(#video_queue, start_index + display_limit - 1)
display_offset = start_index - 1 display_offset = start_index - 1
local message =
styleOn .. style.header .. "{\\fn" .. options.font_name .. "\\fs" ..
options.font_size * 2 .. "}" .. "MPV-YOUTUBE-QUEUE" ..
style.reset .. style.font .. "\n"
for i = start_index, end_index do for i = start_index, end_index do
local prefix = (i == selected_index) and styleOn .. "{\\c&" .. local prefix = (i == selected_index) and style.cursor ..
colors.cursor .. "&}" .. options.cursor_icon .. options.cursor_icon .. " " .. style.reset or
" " .. colors.reset .. styleOff or " " " "
if i == current_index then if i == current_index and i == selected_index then
message = message .. prefix .. styleOn .. "{\\b1\\c&" .. message =
colors.selected_color .. "&}" .. i .. ". " .. message .. prefix .. style.hover_selected .. i .. ". " ..
video_queue[i].name .. "{\\b0}" .. colors.reset .. video_queue[i].name .. style.reset .. "\n"
styleOff .. "\n" elseif i == current_index then
message = message .. prefix .. style.selected .. i .. ". " ..
video_queue[i].name .. style.reset .. "\n"
elseif i == selected_index then
message = message .. prefix .. style.hover .. i .. ". " ..
video_queue[i].name .. style.reset .. "\n"
else else
message = message .. prefix .. styleOn .. colors.reset .. message = message .. prefix .. style.reset .. i .. ". " ..
styleOff .. i .. ". " .. video_queue[i].name .. video_queue[i].name .. style.reset .. "\n"
"\n"
end end
end end
message = message .. styleOff
mp.osd_message(message, duration) mp.osd_message(message, duration)
else else
print_osd_message("No videos in the queue or history.", duration, print_osd_message("No videos in the queue or history.", duration,