From 426ad21103f9bfbd86994e3839ec9eeb239403f7 Mon Sep 17 00:00:00 2001 From: hkc Date: Tue, 17 Oct 2023 20:01:54 +0300 Subject: [PATCH] Proper line clearing --- tape-playlist.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tape-playlist.lua b/tape-playlist.lua index 32e028b..ae9b2b3 100644 --- a/tape-playlist.lua +++ b/tape-playlist.lua @@ -7,6 +7,7 @@ end local running = true +term.setBackgroundColor(colors.black) term.clear() local screen_w, screen_h = term.getSize() local table_of_contents = {} @@ -34,6 +35,7 @@ local function textProgress(p, c1, c2, fmt, ...) local w2 = tw - w1 local bg = term.getBackgroundColor() + term.setBackgroundColor(c1) term.write(str:sub(1, w1)) local rem = w1 - #str @@ -60,7 +62,6 @@ function() local pos, size = drive.getPosition(), drive.getSize() for i = 1, math.min(screen_h - 2, 48) do term.setCursorPos(1, i) - term.clearLine() local song = table_of_contents[i] if song then local is_playing = pos >= song.offset and pos < song.ending @@ -70,10 +71,12 @@ function() textProgress(p, colors.lime, colors.lightGray, s) else term.setBackgroundColor(i % 2 == 0 and colors.gray or colors.black) + term.clearLine() term.write(s) end end end + term.setCursorPos(1, screen_h) textProgress(pos / size, colors.red, colors.gray, "%8d / %8d [%s]", pos, size, drive.getState()) end @@ -93,6 +96,7 @@ function() drive.play() end elseif ev == "term_resize" then + term.setBackgroundColor(colors.black) term.clear() screen_w, screen_h = term.getSize() elseif ev == "tape_present" then