forked from hkc/cc-stuff
Proper line clearing
This commit is contained in:
parent
caa1b5a84f
commit
426ad21103
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue