All Projects β†’ agauniyal β†’ Rang

agauniyal / Rang

Licence: unlicense
A Minimal, Header only Modern c++ library for terminal goodies πŸ’„βœ¨

Programming Languages

cpp
1120 projects
cplusplus
227 projects
cpp11
221 projects
cpp17
186 projects
cpp14
131 projects

Projects that are alternatives of or similar to Rang

Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: ✭ 53 (-95.09%)
Mutual labels:  cli, terminal, command-line, console, color
Chalk
πŸ– Terminal string styling done right
Stars: ✭ 17,566 (+1526.48%)
Mutual labels:  cli, terminal, console, ansi, color
Cointop
A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies πŸš€
Stars: ✭ 2,912 (+169.63%)
Mutual labels:  cli, terminal, command-line, console
Ascii
πŸ‘Ύ ASCII Roulette :: ascii art video chat on the cli
Stars: ✭ 202 (-81.3%)
Mutual labels:  cli, terminal, command-line, console
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+161.2%)
Mutual labels:  cli, terminal, command-line, console
Pixterm
Draw images in your ANSI terminal with true color
Stars: ✭ 782 (-27.59%)
Mutual labels:  cli, terminal, ansi, color
Nnn
nΒ³ The unorthodox terminal file manager
Stars: ✭ 13,138 (+1116.48%)
Mutual labels:  cli, terminal, command-line, console
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: ✭ 2,623 (+142.87%)
Mutual labels:  cli, terminal, command-line, console
Window Size
Reliable way to to get the height and width of the terminal/console in a node.js environment.
Stars: ✭ 79 (-92.69%)
Mutual labels:  cli, terminal, command-line, console
Hues
Colored terminal text made easy for Python and happiness.
Stars: ✭ 345 (-68.06%)
Mutual labels:  cli, terminal, ansi, color
Colorette
Easily set the color and style of text in the terminal.
Stars: ✭ 1,047 (-3.06%)
Mutual labels:  cli, terminal, console, ansi
Box Cli Maker
Make Highly Customized Boxes for your CLI
Stars: ✭ 115 (-89.35%)
Mutual labels:  cli, terminal, console, color
Word Wrap
Wrap words to a specified length.
Stars: ✭ 107 (-90.09%)
Mutual labels:  cli, terminal, command-line, console
Mandown
man-page inspired Markdown viewer
Stars: ✭ 173 (-83.98%)
Mutual labels:  cli, terminal, command-line, console
Tooling
Advancing Node.js as a framework for writing great tools
Stars: ✭ 98 (-90.93%)
Mutual labels:  cli, terminal, command-line, console
Php Console Spinner
Colorful highly configurable spinner for php cli applications (suitable for async apps)
Stars: ✭ 225 (-79.17%)
Mutual labels:  cli, terminal, console, color
Wonders
🌈 Declarative JavaScript framework to build command-line applications.
Stars: ✭ 34 (-96.85%)
Mutual labels:  cli, terminal, command-line, console
Mordant
Full-featured text styling for Kotlin command-line applications
Stars: ✭ 382 (-64.63%)
Mutual labels:  terminal, console, ansi, color
Imgcat
It's like cat, but for images.
Stars: ✭ 577 (-46.57%)
Mutual labels:  cli, terminal, ansi, color
Chafa
πŸ“ΊπŸ—Ώ Terminal graphics for the 21st century.
Stars: ✭ 774 (-28.33%)
Mutual labels:  cli, terminal, ansi

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 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/[email protected]/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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].