From db1b1625d67554f5dc008b972a5e2010ff16f001 Mon Sep 17 00:00:00 2001 From: Jatin Sharma Date: Wed, 31 Oct 2018 16:24:34 -0400 Subject: [PATCH 1/2] added prefix title to progressbar and adjusted width of progressbar accordingly --- init.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index fad5ae8..46f8a1a 100644 --- a/init.lua +++ b/init.lua @@ -237,9 +237,11 @@ do local times local indices local termLength = math.min(getTermLength(), 120) - function xlua.progress(current, goal) + function xlua.progress(current, goal, title) + -- sanity check + if title == nil then title = "" else title = tostring(title)..":" end -- defaults: - local barLength = termLength - 34 + local barLength = termLength - 34 - #title local smoothing = 100 local maxfps = 10 @@ -262,7 +264,7 @@ do if (not barDone) then previous = percent -- print bar - io.write(' [') + io.write(title .. ' [') for i=1,barLength do if (i < percent) then io.write('=') elseif (i == percent) then io.write('>') From d8bedbf617ae5663d32c95587c46efb71dc5c4e8 Mon Sep 17 00:00:00 2001 From: Jatin Sharma Date: Wed, 31 Oct 2018 17:26:32 -0400 Subject: [PATCH 2/2] changing name 'title' to 'prefix' for understandability. --- init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 46f8a1a..362dcab 100644 --- a/init.lua +++ b/init.lua @@ -237,11 +237,11 @@ do local times local indices local termLength = math.min(getTermLength(), 120) - function xlua.progress(current, goal, title) + function xlua.progress(current, goal, prefix) -- sanity check - if title == nil then title = "" else title = tostring(title)..":" end + if prefix == nil then prefix = "" else prefix = tostring(prefix)..":" end -- defaults: - local barLength = termLength - 34 - #title + local barLength = termLength - 34 - #prefix local smoothing = 100 local maxfps = 10 @@ -264,7 +264,7 @@ do if (not barDone) then previous = percent -- print bar - io.write(title .. ' [') + io.write(prefix .. ' [') for i=1,barLength do if (i < percent) then io.write('=') elseif (i == percent) then io.write('>')