From 18de04bfc123e2aabc65de9b8cf976d3a5f2f294 Mon Sep 17 00:00:00 2001 From: hkc Date: Fri, 20 Oct 2023 04:05:28 +0300 Subject: [PATCH] Proper drive state handling --- mess/tmpc.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mess/tmpc.lua b/mess/tmpc.lua index 0e8c4d9..8ffa1b4 100644 --- a/mess/tmpc.lua +++ b/mess/tmpc.lua @@ -378,10 +378,19 @@ function() term.clearLine() local timeString = string.format("[%s:%s]", time2str(time), time2str(duration)) - if drive.getState() == "PLAYING" then + if drive.getState() ~= "STOPPED" then term.setTextColor(mplayer.colors.status) local speen = spinner[(math.floor(drive.getPosition() / 600) % #spinner) + 1] - term.write(speen .. " Playing: ") -- 11 characters + local action = "" + if drive.getState() == "PLAYING" then action = "Playing:" + elseif drive.getState() == "REWINDING" then action = "Rewinding" + elseif drive.getState() == "FORWARDING" then action = "Forwarding" + else + printError("Unknown drive state: "..tostring(drive.getState())) + return + end + action = speen .. " " .. action + term.write(action) -- Progressbar local lw = math.floor(tw * time / duration) @@ -394,8 +403,8 @@ function() term.write(string.rep("\xad", tw - lw - 1)) -- Statusline text - term.setCursorPos(12, th) - local w = tw - #timeString - 12 -- "Playing: " plus extra space + term.setCursorPos(#action + 2, th) + local w = tw - #timeString - #action - 2 -- "Playing: ", spinner plus spacing term.setTextColor(mplayer.colors.current) if #title <= w then