Customizable bars for v term apps.
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
-
Simple bars
// Default 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.// Returns an `io.BufferedReader` that displays a progressing bar when used in a reader operation. pub fn (b Bar) reader(reader io.Reader, size u64) &io.BufferedReader
mut src_file := os.open(src_file_path)! mut dst_file := os.create(dst_file_path)! bar := bartender.Bar{} mut bar_reader := bar.reader(src_file, os.file_size(src_file_path)) io.cp(mut bar_reader, mut dst_file)!
Extended and executable examples can be found in the examples
directory.
v run examples/<file>.v
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.
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
- Waqar144/progressbar inspired the start of project.
- console-rs/indicatif serves as inspiration for further development.
- ArtemkaKun/v-project-basement served as a base for CI scripts and issue templates