GithubHelp home page GithubHelp logo

hsuantinglu / pbar Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 244 KB

Low overhead C++ progress bar

License: GNU General Public License v3.0

CMake 12.23% C++ 87.77%
progress-bar progressbar cpp hacktoberfest

pbar's Introduction

pbar GitHub GitHub release (latest SemVer including pre-releases)

GitHub code size in bytes Codacy Badge

Low overhead C++ progress bar with a friendly interface

runtime-demo-GIF

Table of Contents

Quickstart

The pbar library is very easy to use, with a simple constructor ProgressBar(${description}, ${total}) and you're ready to go.

Updating the bar is as easy as the construction process, update(${number}) increases/decreases the bar to whatever number you want.

there are example codes in the examples/ directory, see Install for more information.

Simple example

#include "pbar.hpp"
using namespace pbar;

int main() {
    ProgressBar progressbar("outer", 10);
    for (int i = 0; i != 10; ++i) {
        progressbar.update();
    }
}

Nested progress bars

#include "pbar.hpp"
using namespace pbar;
constexpr int test_size1 = 10;
constexpr int test_size2 = 10000000;

int main() {
    ProgressBar progressbar1("outer", test_size1, true);
    for (int i = 0; i != test_size1; ++i) {
        ProgressBar progressbar2("inner", test_size2, true);
        for (int j = 0; j != test_size2; ++j) {
            progressbar2.update();
        }
        progressbar1.update();
    }
}

Install

CMake is the official build system.

Requirements

  • C++11 or higher
  • Ansi-Escape library for terminal render control
  • CMake 3.5 or higher
mkdir build; cd build/

# Config and build
cmake .. && make driver

# execute example
./examples/driver

pbar's People

Contributors

hsuantinglu avatar hsweif avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pbar's Issues

Support bar fractions with UTF-8

in short, use these

█
▉
▊
▋
▌
▍
▎
▏

to characterize small fractions of progress.

We can achieve this with the ICU library,
or with libraries like <locale> and <codecvt>.

The code points we're looking for is 0x2588 -0x258F

Update docs about the new operators

update example usage regarding the prefix increment/decrement and compound assignment operators

// Prefix increment/decrement
++()
--()

// Compound assignments
+=()
-=()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.