Skip to content
FutureBlitz

    Install

    Import std.term.widgets

    ProgressBar

    std.term.widgets

    class

    Public Class ProgressBar

    A bar of how much of a Total is done, on a line of its own, with a Label before it and its Parts after it, which it draws again in place as its Value changes, no more often than Interval but at its start and its end, on an interactive terminal; on another, it's drawn once, at its Finish. It goes to stderr, or to a Terminal given. What reads the clock also takes an Instant, so a test gives the time.

    Examples

    Local terminal = FakeTerminal(interactive: False)
    Local bar = ProgressBar(10, terminal)
    bar.Add(4)
    Expect(bar.Value == 4 && !bar.IsFinished)
    bar.Finish()
    Expect(bar.IsFinished)

    std/term/widgets.fb, line 477

    • Public Field Total: Int64 field #

      How many make the bar full.

    • Public Field Label: String field #

      What goes before the bar.

    • Public Field Width: Int field #

      The bar's columns, which give way to the rest where the terminal's line is narrower.

    • Public Field Parts: ProgressParts field #

      What follows the bar.

    • Public Field Characters: String field #

      The bar's characters: a full column first, an empty one last, and any between, for a column that's partly full, from the fullest down, as "█▉▊▋▌▍▎▏ " or "#>-" has them.

    • Public Field FilledStyle: Style field #

      How its full and its empty columns look.

    • Public Field EmptyStyle: Style field #

      How its empty columns look.

    • Public Field Interval: Duration field #

      The least time between two draws.

    • Public New(total: Int64) constructor #

      A bar of total on stderr, from now.

    • Public New(total: Int64, terminal: Terminal) constructor #

      A bar of total on terminal, from now.

    • Public New(total: Int64, terminal: Terminal, start: Instant) constructor #

      A bar of total on terminal, from start.

    • Public Property Value: Int64 property #

      How many are done.

    • Public Property IsFinished: Bool property #

      Whether Finish has drawn it for the last time.

    • Public Method Set(value: Int64) method #

      Sets how many are done, and draws it, if it's time to.

    • Public Method Set(value: Int64, now: Instant) method #

      Sets how many are done at now, and draws it, if it's time to.

    • Public Method Add(count: Int64 = 1) method #

      Adds count to how many are done, and draws it, if it's time to.

    • Public Method Add(count: Int64, now: Instant) method #

      Adds count to how many are done at now, and draws it, if it's time to.

    • Public Method PrintAbove(text: String) method #

      Writes text on a line of its own above the bar, which is drawn again below it.

    • Public Method PrintAbove(text: String, now: Instant) method #

      Writes text on a line of its own above the bar at now.

    • Public Method Finish() method #

      Draws it for the last time, as it is, and ends its line.

    • Public Method Finish(now: Instant) method #

      Draws it for the last time at now, and ends its line.

    • Public Method Render(now: Instant): String method #

      The line it draws at now, as its terminal shows colors, in its columns.

    Report an issue with this page or with FutureBlitz on GitHub.