GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Categories
  • Newsletter
  • Submit
  • Login
  • Awesome C++
  • CLI

This view

  • Original page
  • New address

GeezerVison is showing cpp.libhunt.com โ€” rang Alternatives - C++ CLI | LibHunt

  • Subscribe
  • Submit
  • Categories
  • About
  • Login

rang

A Minimal, Header only Modern c++ library for terminal goodies ๐Ÿ’„โœจ

agauniyal logo
agauniyal.github.io    Source Code    Changelog
Suggest Changes
Take the C++ Developer Survey - About 6 minutes on the tools, libraries and AI you use with C++. You get the results by email. Take the survey ยป
Popularity
6.0
Declining
Activity
6.2
-
Stars 1,594
Watchers 55
Forks 154
Last Commit 7 months ago

Code Quality Rank: L4
Programming language: C++
License: The Unlicense
Tags: CLI     Terminal     Colors    
Latest version: v3.3

rang alternatives and similar libraries

Based on the "CLI" category.
Alternatively, view rang alternatives based on common mentions on social networks and blogs.

  • Vcpkg

    9.7 10.0 rang VS Vcpkg
    C++ Library Manager for Windows, Linux, and MacOS
    microsoft logo
  • conan

    8.8 9.6 rang VS conan
    Conan - The open-source C and C++ package manager
    conan-io logo
  • SaaSHub - Software Alternatives and Reviews

    SaaSHub helps you find the best software and product alternatives
    Promo www.saashub.com
    SaaSHub Logo
  • jarro2783/cxxopts

    7.9 6.6 rang VS jarro2783/cxxopts
    Lightweight C++ command line option parser
    jarro2783 logo
  • CLI11

    7.8 8.8 rang VS CLI11
    CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.
    CLIUtils logo
  • gflags

    7.6 5.8 L2 rang VS gflags
    The gflags package contains a C++ library that implements commandline flags processing. It includes built-in support for standard types such as string and the ability to define flags in the source file in which they are used. Online documentation available at:
    gflags logo
  • indicators

    7.3 5.2 rang VS indicators
    Activity Indicators for Modern C++
    p-ranav logo
  • termbox

    6.4 0.0 L4 rang VS termbox
    Library for writing text-based user interfaces
    nsf logo
  • args

    6.1 8.5 L1 rang VS args
    A header-only C++ argument parser library. Supposed to be flexible and powerful, and attempts to be compatible with the functionality of the Python standard argparse library (though not necessarily the API).
    Taywee logo
  • Taywee/args

    6.1 8.5 L1 rang VS Taywee/args
    A header-only C++ argument parser library. Supposed to be flexible and powerful, and attempts to be compatible with the functionality of the Python standard argparse library (though not necessarily the API).
    Taywee logo
  • clipp

    5.7 0.0 rang VS clipp
    easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation
    muellan logo
  • Argh!

    5.6 2.4 rang VS Argh!
    Argh! A minimalist argument handler.
    adishavit logo
  • docopt.cpp

    5.4 0.0 L3 rang VS docopt.cpp
    C++11 port of docopt
    docopt logo
  • Ncurses

    4.5 1.2 rang VS Ncurses
    ncurses Git mirror
    mirror logo
  • Boost.Program_options

    3.4 3.8 L3 rang VS Boost.Program_options
    Boost.org program_options module
    boostorg logo
  • cifuzz

    3.3 6.8 rang VS cifuzz
    DISCONTINUED. cifuzz makes fuzz tests as easy as unit tests
    CodeIntelligenceTesting logo
  • GuiarStr

    1.2 8.2 rang VS GuiarStr
    A lightweight, dependency-free C library for UTF-8-safe and advanced string manipulation: trim, split, reverse, contains, count, and more.
    okba14 logo
  • TCLAP

    - rang VS TCLAP
    A mature, stable and feature-rich library for defining and accessing command line arguments in ANSI C++. [MIT]

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.

Do you think we are missing an alternative of rang or a related project?

Add another 'CLI' Library

Popular Comparisons

  • rang
    vs
    Ncurses
  • rang
    vs
    Boost.Program_options
  • rang
    vs
    Argh!
  • rang
    vs
    args
  • rang
    vs
    Taywee/args

README

rang Build Status Build status codecov Download

Colors for your Terminal.

rang-demo Windows Demo

rang-windows-demo

Example usage

#include "rang.hpp"

using namespace std;
using namespace rang;

int main()
{
    cout << "Plain old text"
         << style::bold << "Rang styled text!!"
         << style::reset << endl;
}

Dependencies

rang only depends on C++ standard library, unistd.h system header on unix and windows.h & io.h system headers on windows based systems. In other words, you don't need any 3rd party dependencies.

Installation

rang is a single header-only library. Put rang.hpp in the [include](include) folder directly into the project source tree or somewhere reachable from your project.

Or, if you use the conan package manager, follow these steps:

  1. Add a reference to rang to the requires section of your project's conanfile.txt file:

    [requires]
    rang/3.1.0@rang/stable
    
  2. Run conan's install command:

    conan install
    

How to use

Rang uses iostream objects - cout/clog/cerr to apply attributes to output text. Since rang aims to support both windows and unix like systems, it takes care of the os specific details and tries to provide a uniform interface. Due to incompatiblities b/w different OS versions, not all kinds of attributes are supported on every system so rang will try to skip the ones which might produce garbage(instead of pushing random ANSI escape codes on your streams). Detection of tty is also handled internally so you don't need to check if application user might redirect output to a file.

Need support for non-ansi terminals? Check out Termdb which supports virtually all terminals and their capablities.

Apart from setting text attributes, you can also ask rang to override its default behaviour through these methods -

void rang::setControlMode(rang::control);

where rang::control takes

  • control::Auto - Automatically detects whether terminal supports color or not(Default)
  • control::Off - Turn off colors completely
  • control::Force - Force colors even if terminal doesn't supports them or output is redirected to non-terminal
void rang::setWinTermMode(rang::winTerm);

where rang::winTerm takes

  • winTerm::Auto - Checks for newer windows and picks Ansi otherwise falls back to Native(Default)
  • winTerm::Native - This method is supported in all versions of windows but supports less attributes
  • winTerm::Ansi - This method is supported in newer versions of windows and supports rich variety of attributes

Supported attributes with their compatiblity are listed below -

Text Styles:

Code Linux/Win/Others Old Win
rang::style::bold yes yes
rang::style::dim yes no
rang::style::italic yes no
rang::style::underline yes no
rang::style::blink no no
rang::style::rblink no no
rang::style::reversed yes yes
rang::style::conceal maybe yes
rang::style::crossed yes no

Text Color:

Code Linux/Win/Others Old Win
rang::fg::black yes yes
rang::fg::red yes yes
rang::fg::green yes yes
rang::fg::yellow yes yes
rang::fg::blue yes yes
rang::fg::magenta yes yes
rang::fg::cyan yes yes
rang::fg::gray yes yes

Background Color:

Code Linux/Win/Others Old Win
rang::bg::black yes yes
rang::bg::red yes yes
rang::bg::green yes yes
rang::bg::yellow yes yes
rang::bg::blue yes yes
rang::bg::magenta yes yes
rang::bg::cyan yes yes
rang::bg::gray yes yes

Bright Foreground Color:

Code Linux/Win/Others Old Win
rang::fgB::black yes yes
rang::fgB::red yes yes
rang::fgB::green yes yes
rang::fgB::yellow yes yes
rang::fgB::blue yes yes
rang::fgB::magenta yes yes
rang::fgB::cyan yes yes
rang::fgB::gray yes yes

Bright Background Color:

Code Linux/Win/Others Old Win
rang::bgB::black yes yes
rang::bgB::red yes yes
rang::bgB::green yes yes
rang::bgB::yellow yes yes
rang::bgB::blue yes yes
rang::bgB::magenta yes yes
rang::bgB::cyan yes yes
rang::bgB::gray yes yes

Reset Styles/Colors:

Code Linux/Win/Others Old Win
rang::style::reset yes yes
rang::fg::reset yes yes
rang::bg::reset yes yes

My terminal is not detected/gets garbage output!

Check your env variable TERM's value. Then open an issue here and make sure to mention TERM's value along with your terminal name.

Redirecting cout/cerr/clog rdbuf?

Rang doesn't interfere if you try to redirect cout/cerr/clog to somewhere else and leaves the decision to the library user. Make sure you've read this conversation and check out the example code here.

Do not miss the trending, libraries, news and articles with our weekly report.

Awesome C++ is part of the LibHunt network. Terms. Privacy Policy.

(CC)
BY-SA
Spin The Wheel Of Names for a cryptographically secure random name picker.
Schedule a when to meet poll.
You are visitor 01402792 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.