From 42063e027155625e28c2fc44ef5b8881ce25d576 Mon Sep 17 00:00:00 2001 From: hkc Date: Tue, 17 Oct 2023 16:16:02 +0300 Subject: [PATCH] Finally print them normally --- tape-playlist.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tape-playlist.lua b/tape-playlist.lua index 7b894b5..71f5be5 100644 --- a/tape-playlist.lua +++ b/tape-playlist.lua @@ -24,10 +24,18 @@ local function bytes2time(b) return string.format("%dm, %ds", math.floor(s / 60), s % 60) end +local screen_w, screen_h = term.getSize() parallel.waitForAll( function() while running do + for i = 1, math.min(screen_h, 48) do + term.setCursorPos(1, i) + local song = table_of_contents[i] + if song then + term.write(string.format("#%2d %9s %s", i, bytes2time(song.length), song.title)) + end + end os.sleep(0.1) end end, @@ -38,6 +46,8 @@ function() if ev == "mouse_click" then local x, y = table.unpack(evd, 1) + elseif ev == "term_resize" then + screen_w, screen_h = term.getSize() elseif ev == "tape_present" then table_of_contents = {} if evd[1] then @@ -47,9 +57,6 @@ function() local offset = read32() local length = read32() local title = drive.read(117) - if length > 0 then - print(string.format("%d: %d + %d %s", i, offset, length, title)) - end table.insert(table_of_contents, { title = length > 0 and title or nil, offset = offset,