Skip to content
Simple header only library to add a spinner / progress indicator to any terminal application.
C++ CMake
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
tests
.gitignore
CMakeLists.txt
LICENSE
README.org
spinnercpp.h

README.org

spinnercpp

spinnercpp is a simple header only library to add a spinner / progress indicator to any terminal application. spinnercpp is based on [https://github.com/briandowns/spinner]

Contributions welcome!

https://1.bp.blogspot.com/-dUjJ_XFIx8c/XZeajOvE7AI/AAAAAAAAF94/r7RJrJDfEs4ybrIPipTHgTFIUykfgUciwCLcBGAsYHQ/s1600/spinners.png

Features

  • Start
  • Stop
  • Restart
  • Update the spinner speed
  • Prefix or append text
  • Output final string on spinner/indicator completion

Examples

Simple use

#include "../../spinnercpp.h"

int main() {
  auto spin = std::make_unique<spinnercpp::spinner>();
  spin->start();
  std::this_thread::sleep_for(std::chrono::milliseconds(3000)); 
  
  return 0;
}

Stop

#include <iostream>
#include "../../spinnercpp.h"

using namespace std;

int main() {
  auto spin = std::make_unique<spinnercpp::spinner>();
  spin->start();
  std::this_thread::sleep_for(std::chrono::milliseconds(3000)); 
  spin->stop();

  cout << "Stop" << endl;
  
  return 0;
}

Update spin speed and restart the spinner

auto spin = std::make_unique<spinnercpp::spinner>(100ms);
spin->start();

Choose the spinner

To use the charset 10

auto spin = std::make_unique<spinnercpp::spinner>(100ms, 10); 
spin->start();

Preffix and Suffix

auto spin = std::make_unique<spinnercpp::spinner>(100ms, 10, "> ", " |"); 
spin->start();
You can’t perform that action at this time.