Skip to content

Commit 74c6373

Browse files
authored
add title parameter for progress bar hline (#275)
1 parent 692eb8e commit 74c6373

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/progress.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ Arguments:
252252
- `paused`: false when the bar is running but briefly paused (e.g. to update `jobs`)
253253
- `task`: references a `Task` for updating the progress bar in parallel
254254
- `renderstatus`: a `RenderStatus` instance
255+
- `title`: progress bar title
255256
- `extra_info`: a `Dict{String,<:Any}` to show extra information.
256257
"""
257258
mutable struct ProgressBar
@@ -271,6 +272,7 @@ mutable struct ProgressBar
271272
task::Union{Task,Nothing}
272273
renderstatus::Any
273274
extra_info::Dict{String,<:Any}
275+
title::String
274276
end
275277

276278
"""
@@ -300,6 +302,7 @@ function ProgressBar(;
300302
colors::Union{String,Vector{RGBColor}} = [RGBColor("(1, .05, .05)"), RGBColor("(.05, .05, 1)"), RGBColor("(.05, 1, .05)")],
301303
refresh_rate::Int = 60, # FPS of rendering
302304
extra_info::Dict{String,<:Any} = Dict{String,Any}(),
305+
title = "progress",
303306
)
304307
columns = columns isa Symbol ? get_columns(columns) : columns
305308

@@ -320,6 +323,7 @@ function ProgressBar(;
320323
nothing,
321324
RenderStatus(),
322325
extra_info,
326+
title,
323327
)
324328
end
325329

@@ -503,7 +507,7 @@ function render(pbar::ProgressBar, io = stdout)
503507

504508
pbar.renderstatus.rendered = true
505509
pbar.renderstatus.hline =
506-
string(hLine(pbar.width, "progress"; style = "blue dim")) * "\n"
510+
string(hLine(pbar.width, pbar.title; style = "blue dim")) * "\n"
507511
pbar.renderstatus.nlines = njobs
508512
pbar.renderstatus.maxnlines = njobs
509513

test/15_test_progress.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ end
6464
end
6565
end
6666

67+
@test_nothrow begin
68+
pbar3 = ProgressBar(; title = "Test")
69+
with(pbar3) do
70+
job = addjob!(pbar3; N = 10)
71+
for i in 1:10
72+
update!(job)
73+
sleep(0.001)
74+
end
75+
end
76+
end
77+
6778
@test_nothrow begin
6879
@track for i in 1:10
6980
sleep(0.001)

0 commit comments

Comments
 (0)