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
|
local running = true
|
||||||
|
|
||||||
|
term.setBackgroundColor(colors.black)
|
||||||
term.clear()
|
term.clear()
|
||||||
local screen_w, screen_h = term.getSize()
|
local screen_w, screen_h = term.getSize()
|
||||||
local table_of_contents = {}
|
local table_of_contents = {}
|
||||||
|
@ -34,6 +35,7 @@ local function textProgress(p, c1, c2, fmt, ...)
|
||||||
local w2 = tw - w1
|
local w2 = tw - w1
|
||||||
|
|
||||||
local bg = term.getBackgroundColor()
|
local bg = term.getBackgroundColor()
|
||||||
|
|
||||||
term.setBackgroundColor(c1)
|
term.setBackgroundColor(c1)
|
||||||
term.write(str:sub(1, w1))
|
term.write(str:sub(1, w1))
|
||||||
local rem = w1 - #str
|
local rem = w1 - #str
|
||||||
|
@ -60,7 +62,6 @@ function()
|
||||||
local pos, size = drive.getPosition(), drive.getSize()
|
local pos, size = drive.getPosition(), drive.getSize()
|
||||||
for i = 1, math.min(screen_h - 2, 48) do
|
for i = 1, math.min(screen_h - 2, 48) do
|
||||||
term.setCursorPos(1, i)
|
term.setCursorPos(1, i)
|
||||||
term.clearLine()
|
|
||||||
local song = table_of_contents[i]
|
local song = table_of_contents[i]
|
||||||
if song then
|
if song then
|
||||||
local is_playing = pos >= song.offset and pos < song.ending
|
local is_playing = pos >= song.offset and pos < song.ending
|
||||||
|
@ -70,10 +71,12 @@ function()
|
||||||
textProgress(p, colors.lime, colors.lightGray, s)
|
textProgress(p, colors.lime, colors.lightGray, s)
|
||||||
else
|
else
|
||||||
term.setBackgroundColor(i % 2 == 0 and colors.gray or colors.black)
|
term.setBackgroundColor(i % 2 == 0 and colors.gray or colors.black)
|
||||||
|
term.clearLine()
|
||||||
term.write(s)
|
term.write(s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
term.setCursorPos(1, screen_h)
|
term.setCursorPos(1, screen_h)
|
||||||
textProgress(pos / size, colors.red, colors.gray, "%8d / %8d [%s]", pos, size, drive.getState())
|
textProgress(pos / size, colors.red, colors.gray, "%8d / %8d [%s]", pos, size, drive.getState())
|
||||||
end
|
end
|
||||||
|
@ -93,6 +96,7 @@ function()
|
||||||
drive.play()
|
drive.play()
|
||||||
end
|
end
|
||||||
elseif ev == "term_resize" then
|
elseif ev == "term_resize" then
|
||||||
|
term.setBackgroundColor(colors.black)
|
||||||
term.clear()
|
term.clear()
|
||||||
screen_w, screen_h = term.getSize()
|
screen_w, screen_h = term.getSize()
|
||||||
elseif ev == "tape_present" then
|
elseif ev == "tape_present" then
|
||||||
|
|
Loading…
Reference in New Issue