Small tweaks, mouse handling and speeny block
This commit is contained in:
parent
dd42590052
commit
eece2153e4
|
@ -148,8 +148,8 @@ S+Tab : Prev. screen
|
||||||
> : Previous track
|
> : Previous track
|
||||||
f : Seek forward
|
f : Seek forward
|
||||||
b : Seek backward
|
b : Seek backward
|
||||||
\x11 - : Lower volume
|
\x1b - : Lower volume
|
||||||
\x10 + : Higher volume
|
\x1a + : Higher volume
|
||||||
|
|
||||||
# List screen:
|
# List screen:
|
||||||
--
|
--
|
||||||
|
@ -157,7 +157,9 @@ S+Tab : Prev. screen
|
||||||
Ctrl+l : Center
|
Ctrl+l : Center
|
||||||
l : Jump to current
|
l : Jump to current
|
||||||
|
|
||||||
]]):gsub("\\x11", "\x11"):gsub("\\x10", "\x10"):gmatch("[^\n]+") do
|
]]):gsub("\\x(..)", function(m)
|
||||||
|
return string.char(tonumber(m, 16))
|
||||||
|
end):gmatch("[^\n]+") do
|
||||||
table.insert(help, line)
|
table.insert(help, line)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -241,20 +243,25 @@ local mplayer = {
|
||||||
end,
|
end,
|
||||||
handleKey = function(self, key, repeating)
|
handleKey = function(self, key, repeating)
|
||||||
local shiftHeld = self.heldKeys[keys.leftShift] ~= nil or self.heldKeys[keys.rightShift] ~= nil
|
local shiftHeld = self.heldKeys[keys.leftShift] ~= nil or self.heldKeys[keys.rightShift] ~= nil
|
||||||
|
local ctrlHeld = self.heldKeys[keys.leftCtrl] ~= nil or self.heldKeys[keys.rightCtrl] ~= nil
|
||||||
|
|
||||||
if key == keys.down or key == keys.j then
|
if key == keys.down or key == keys.j then
|
||||||
self.screens[2].handleScroll(self, 1)
|
self.screens[2].handleScroll(self, 1, 1, 1)
|
||||||
elseif key == keys.up or key == keys.k then
|
elseif key == keys.up or key == keys.k then
|
||||||
self.screens[2].handleScroll(self, -1)
|
self.screens[2].handleScroll(self, -1, 1, 1)
|
||||||
elseif key == keys.pageDown then
|
elseif key == keys.pageDown then
|
||||||
self.screens[2].handleScroll(self, th - 3)
|
self.screens[2].handleScroll(self, th - 3, 1, 1)
|
||||||
elseif key == keys.pageUp then
|
elseif key == keys.pageUp then
|
||||||
self.screens[2].handleScroll(self, -(th - 3))
|
self.screens[2].handleScroll(self, -(th - 3), 1, 1)
|
||||||
elseif key == keys.h and shiftHeld then
|
elseif key == keys.h and shiftHeld then
|
||||||
self.screens[2].handleScroll(self, -#self.songs)
|
self.screens[2].handleScroll(self, -#self.songs, 1, 1)
|
||||||
elseif key == keys.l and shiftHeld then
|
elseif key == keys.l and shiftHeld then
|
||||||
self.screens[2].handleScroll(self, #self.songs)
|
self.screens[2].handleScroll(self, #self.songs, 1, 1)
|
||||||
elseif key == keys.l then
|
elseif key == keys.l then
|
||||||
self.screens[2].cursor = self.currentSong or 1
|
self.screens[2].cursor = self.currentSong or 1
|
||||||
|
if ctrlHeld then
|
||||||
|
self.screens[2].scroll = self.screens[2].scroll - math.floor((th - 3) / 2)
|
||||||
|
end
|
||||||
self.screens[2].handleScroll(self, 0, 1, 1)
|
self.screens[2].handleScroll(self, 0, 1, 1)
|
||||||
elseif key == keys.enter then
|
elseif key == keys.enter then
|
||||||
drive.seek(-drive.getSize())
|
drive.seek(-drive.getSize())
|
||||||
|
@ -272,8 +279,22 @@ local mplayer = {
|
||||||
if self.screens[2].cursor > maxi then
|
if self.screens[2].cursor > maxi then
|
||||||
self.screens[2].scroll = self.screens[2].cursor - (th - 3)
|
self.screens[2].scroll = self.screens[2].cursor - (th - 3)
|
||||||
end
|
end
|
||||||
|
if self.screens[2].scroll < 0 then
|
||||||
|
self.screens[2].scroll = 0
|
||||||
|
end
|
||||||
|
if self.screens[2].scroll > #self.songs - (th - 3) then
|
||||||
|
self.screens[2].scroll = #self.songs - (th - 3)
|
||||||
|
end
|
||||||
self.screens[2].textScroll = 0
|
self.screens[2].textScroll = 0
|
||||||
end,
|
end,
|
||||||
|
handleClick = function(self, x, y)
|
||||||
|
local i = self.screens[2].scroll + y - 1
|
||||||
|
if i == self.screens[2].cursor then
|
||||||
|
self.screens[2].handleKey(self, keys.enter, false)
|
||||||
|
elseif i <= #self.songs then
|
||||||
|
self.screens[2].cursor = i
|
||||||
|
end
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title = "Settings",
|
title = "Settings",
|
||||||
|
@ -320,6 +341,13 @@ term.setBackgroundColor(mplayer.colors.bg)
|
||||||
term.setTextColor(mplayer.colors.fg)
|
term.setTextColor(mplayer.colors.fg)
|
||||||
term.clear()
|
term.clear()
|
||||||
|
|
||||||
|
|
||||||
|
local spinner = {
|
||||||
|
"\x81", "\x83", "\x82",
|
||||||
|
"\x8a", "\x88", "\x8c",
|
||||||
|
"\x84", "\x85"
|
||||||
|
}
|
||||||
|
|
||||||
parallel.waitForAny(
|
parallel.waitForAny(
|
||||||
function()
|
function()
|
||||||
while true do
|
while true do
|
||||||
|
@ -352,7 +380,8 @@ function()
|
||||||
local timeString = string.format("[%s:%s]", time2str(time), time2str(duration))
|
local timeString = string.format("[%s:%s]", time2str(time), time2str(duration))
|
||||||
if drive.getState() == "PLAYING" then
|
if drive.getState() == "PLAYING" then
|
||||||
term.setTextColor(mplayer.colors.status)
|
term.setTextColor(mplayer.colors.status)
|
||||||
term.write("Playing: ") -- 9 characters
|
local speen = spinner[(math.floor(drive.getPosition() / 600) % #spinner) + 1]
|
||||||
|
term.write(speen .. " Playing: ") -- 11 characters
|
||||||
|
|
||||||
-- Progressbar
|
-- Progressbar
|
||||||
local lw = math.floor(tw * time / duration)
|
local lw = math.floor(tw * time / duration)
|
||||||
|
@ -360,13 +389,13 @@ function()
|
||||||
term.setTextColor(mplayer.colors.current)
|
term.setTextColor(mplayer.colors.current)
|
||||||
term.clearLine()
|
term.clearLine()
|
||||||
term.write(string.rep("=", lw))
|
term.write(string.rep("=", lw))
|
||||||
term.write(">")
|
term.write("\x10")
|
||||||
term.setTextColor(mplayer.colors.cursor)
|
term.setTextColor(mplayer.colors.cursor)
|
||||||
term.write(string.rep("-", tw - lw - 1))
|
term.write(string.rep("\xad", tw - lw - 1))
|
||||||
|
|
||||||
-- Statusline text
|
-- Statusline text
|
||||||
term.setCursorPos(10, th)
|
term.setCursorPos(12, th)
|
||||||
local w = tw - #timeString - 10 -- "Playing: " plus extra space
|
local w = tw - #timeString - 12 -- "Playing: " plus extra space
|
||||||
|
|
||||||
term.setTextColor(mplayer.colors.current)
|
term.setTextColor(mplayer.colors.current)
|
||||||
if #title <= w then
|
if #title <= w then
|
||||||
|
@ -406,6 +435,16 @@ function()
|
||||||
drive.seek(3000)
|
drive.seek(3000)
|
||||||
elseif ev == "key" and evd[1] == keys.b then
|
elseif ev == "key" and evd[1] == keys.b then
|
||||||
drive.seek(-3000)
|
drive.seek(-3000)
|
||||||
|
elseif ev == "key" and evd[1] == keys.s then
|
||||||
|
drive.stop()
|
||||||
|
drive.seek(-drive.getSize())
|
||||||
|
drive.seek(6000)
|
||||||
|
elseif ev == "key" and (evd[1] == keys.p or evd[1] == keys.space) then
|
||||||
|
if drive.getState() ~= "STOPPED" then
|
||||||
|
drive.stop()
|
||||||
|
else
|
||||||
|
drive.play()
|
||||||
|
end
|
||||||
elseif ev == "key" and evd[1] == keys.tab then
|
elseif ev == "key" and evd[1] == keys.tab then
|
||||||
local dir = ((mplayer.heldKeys[keys.leftShift] ~= nil) or (mplayer.heldKeys[keys.rightShift] ~= nil)) and -1 or 1
|
local dir = ((mplayer.heldKeys[keys.leftShift] ~= nil) or (mplayer.heldKeys[keys.rightShift] ~= nil)) and -1 or 1
|
||||||
mplayer.currentScreen = ((mplayer.currentScreen - 1 + #mplayer.screens + dir)) % #mplayer.screens + 1
|
mplayer.currentScreen = ((mplayer.currentScreen - 1 + #mplayer.screens + dir)) % #mplayer.screens + 1
|
||||||
|
@ -435,6 +474,11 @@ function()
|
||||||
end
|
end
|
||||||
cx = cx + #caption
|
cx = cx + #caption
|
||||||
end
|
end
|
||||||
|
elseif ev == "mouse_click" or ev == "mouse_drag" then
|
||||||
|
if mplayer.screens[mplayer.currentScreen].handleClick then
|
||||||
|
local butt, x, y = table.unpack(evd)
|
||||||
|
mplayer.screens[mplayer.currentScreen].handleClick(mplayer, x, y)
|
||||||
|
end
|
||||||
elseif ev == "term_resize" then
|
elseif ev == "term_resize" then
|
||||||
tw, th = term.getSize()
|
tw, th = term.getSize()
|
||||||
elseif ev == "tape_removed" then
|
elseif ev == "tape_removed" then
|
||||||
|
|
Loading…
Reference in New Issue