/bartender

Customizable progress indicators for V terminal applications.

Primary LanguageVMIT LicenseMIT

bartender

Customizable bars for v term apps.

smooth

Getting started

Install via v cli

  • From source

    v install --git https://github.com/tobealive/bartender
    
    import bartender
  • As vpm module

    v install tobealive.bartender
    
    import tobealive.bartender

Usage examples

  • Simple bars

    // Defaul bar
    mut b := Bar{}
    for _ in 0 .. b.iters {
     	b.progress()
    }
    
    // Customized bar
    mut b2 := Bar{
    	width: 60
    	runes: BarRunes{
    		progress: `#`
     		indicator: `❯`
    		remaining: `-`
    	}
    	pre: '|'
    	post: Affix{
    		pending: '| Loading...'
    		finished: '| Done!'
    	}
    }
    for _ in 0 .. b2.iters {
     	b2.progress()
    }
  • Smooth bar themes

    mut b := SmoothBar{
    	theme: Theme.pull // Default = Theme.push
    }
    for _ in 0 .. b.iters {
    	b.progress()
    }
    
    b2 = SmoothBar{
    	theme: ThemeVariant{.pull, .drain}
    }
    for _ in 0 .. b2.iters {
    	b2.progress()
    }
    
    // Customized smooth bar
    mut b3 := SmoothBar{
    	theme: Theme.split
    	width: 80
    	pre: '│'
    	post: fn (b SmoothBar) (string, string) {
    		return '│ Saving... ${b.pct()}% ${term.blue(b.eta(20))}', '│ Saved!'
    	}
    }
    b3.colorize(.cyan)
    for _ in 0 .. b3.iters {
    	b3.progress()
    }
  • Bar Reader for io operations.

    // 500 MB of sample content.
    content := '1234567890'.repeat(50 * 1024 * 1024)
    
    mut r := bar_reader(Bar{}, content.bytes())
    mut f := os.create('testfile')!
    io.cp(mut r, mut f)!

Run examples

Extended and executable examples can be found in the sample files.

v run examples/<file>.v

Showcase

Simple bar  Toggle visibility...

simple

Color and style customizations.  Toggle visibility...

colors

Smooth bars.  Toggle visibility...

download

Disclaimer

Until a stable version 1.0 is available, new features will be introduced, existing ones may change, or breaking changes may occur in minor(0.<minor>.*) versions.

Outlook

Below are some of the things to look forward to.

  • Reader Interface
  • Multiline (Smooth Bar Split Themes are not supported yet)
  • Time Remaining
  • Dynamic adjustment on term resize for all variants (basic width detection works)
  • Extend visuals & customizability

Anowledgements