{"id":13418359,"url":"https://github.com/agauniyal/rang","last_synced_at":"2025-05-15T15:06:10.055Z","repository":{"id":40984901,"uuid":"52766460","full_name":"agauniyal/rang","owner":"agauniyal","description":"A Minimal, Header only Modern c++ library for terminal goodies 💄✨","archived":false,"fork":false,"pushed_at":"2024-07-23T07:26:16.000Z","size":266,"stargazers_count":1528,"open_issues_count":25,"forks_count":151,"subscribers_count":60,"default_branch":"master","last_synced_at":"2025-04-11T22:38:12.325Z","etag":null,"topics":["ansi","cli","color","command-line","console","cplusplus","cpp","cpp-library","cpp11","cpp14","cpp17","rang","terminal"],"latest_commit_sha":null,"homepage":"https://agauniyal.github.io/rang/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agauniyal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-29T05:31:20.000Z","updated_at":"2025-04-09T19:23:55.000Z","dependencies_parsed_at":"2024-12-05T07:02:24.695Z","dependency_job_id":"39d5b11f-cbbc-444e-b63b-e270854e3700","html_url":"https://github.com/agauniyal/rang","commit_stats":{"total_commits":123,"total_committers":17,"mean_commits":7.235294117647059,"dds":0.4390243902439024,"last_synced_commit":"22345aa4c468db3bd4a0e64a47722aad3518cc81"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agauniyal%2Frang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agauniyal%2Frang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agauniyal%2Frang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agauniyal%2Frang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agauniyal","download_url":"https://codeload.github.com/agauniyal/rang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi","cli","color","command-line","console","cplusplus","cpp","cpp-library","cpp11","cpp14","cpp17","rang","terminal"],"created_at":"2024-07-30T22:01:01.400Z","updated_at":"2025-05-15T15:06:10.030Z","avatar_url":"https://github.com/agauniyal.png","language":"C++","funding_links":[],"categories":["C++","TODO scan for Android support in followings","C++ (225)","Terminal Utilities","Libraries","Table of Contents"],"sub_categories":["Misc"],"readme":"# rang [![Build Status](https://travis-ci.org/agauniyal/rang.svg?branch=master)](https://travis-ci.org/agauniyal/rang) [![Build status](https://ci.appveyor.com/api/projects/status/jqpdoelli38h2a7w?svg=true)](https://ci.appveyor.com/project/agauniyal/rang) [![codecov](https://codecov.io/gh/agauniyal/rang/branch/master/graph/badge.svg)](https://codecov.io/gh/agauniyal/rang) [ ![Download](https://api.bintray.com/packages/agauniyal/rang/rang%3Arang/images/download.svg) ](https://bintray.com/agauniyal/rang/rang%3Arang/_latestVersion)\n\n##### Colors for your Terminal.\n\n![rang-demo](https://cloud.githubusercontent.com/assets/7630575/13501282/0bd00074-e18c-11e5-9848-5bd1f20566d9.gif)\n\u003cdetails\u003e\n \u003csummary\u003eWindows Demo\u003c/summary\u003e\n\n![rang-windows-demo](https://cloud.githubusercontent.com/assets/11349690/19836886/8134975e-9ebe-11e6-9ee4-c4657784ff3b.gif)\n\u003c/details\u003e\n\n\nExample usage\n-------------\n\n```c++\n#include \"rang.hpp\"\n\nusing namespace std;\nusing namespace rang;\n\nint main()\n{\n    cout \u003c\u003c \"Plain old text\"\n         \u003c\u003c style::bold \u003c\u003c \"Rang styled text!!\"\n         \u003c\u003c style::reset \u003c\u003c endl;\n}\n```\n\nDependencies\n------------\n*rang* only depends on [C++ standard library](http://en.cppreference.com/w/cpp/header), `unistd.h` system header on unix and `windows.h` \u0026 `io.h` system headers on windows based systems. In other words, you don't need any 3rd party dependencies.\n\n\nInstallation\n------------\n\n*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.\n\nOr, if you use the [conan package manager](https://www.conan.io/), follow these steps:\n\n1. Add a reference to *rang* to the *requires* section of your project's `conanfile.txt` file:\n\n        [requires]\n        rang/3.1.0@rang/stable\n\n2. Run conan's install command:\n\n        conan install\n\n\n## How to use\n\n*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.\n\n\u003e **Need support for non-ansi terminals? Check out [Termdb](https://github.com/agauniyal/termdb) which supports virtually all terminals and their capablities.**\n\nApart from setting text attributes, you can also ask rang to override its default behaviour through these methods -\n```cpp\nvoid rang::setControlMode(rang::control);\n```\nwhere `rang::control` takes\n - `control::Auto` - Automatically detects whether terminal supports color or not(**Default**)\n - `control::Off` - Turn off colors completely\n - `control::Force` - Force colors even if terminal doesn't supports them or output is redirected to non-terminal\n\n```cpp\nvoid rang::setWinTermMode(rang::winTerm);\n```\nwhere `rang::winTerm` takes\n - `winTerm::Auto` - Checks for newer windows and picks Ansi otherwise falls back to Native(**Default**)\n - `winTerm::Native` - This method is supported in all versions of windows but supports less attributes\n - `winTerm::Ansi` - This method is supported in newer versions of windows and supports rich variety of attributes\n\n\nSupported attributes with their compatiblity are listed below -\n\n**Text Styles**:\n\n| Code | Linux/Win/Others | Old Win\n| ---- | --------- | ------ |\n| `rang::style::bold`      | yes   | yes   |\n| `rang::style::dim`       | yes   | no    |\n| `rang::style::italic`    | yes   | no    |\n| `rang::style::underline` | yes   | no    |\n| `rang::style::blink`     | no    | no    |\n| `rang::style::rblink`    | no    | no    |\n| `rang::style::reversed`  | yes   | yes   |\n| `rang::style::conceal`   | maybe | yes   |\n| `rang::style::crossed`   | yes   | no    |\n\n**Text Color**:\n\n| Code | Linux/Win/Others | Old Win\n| ---- | --------- | ------ |\n| `rang::fg::black`     | yes | yes |\n| `rang::fg::red`       | yes | yes |\n| `rang::fg::green`     | yes | yes |\n| `rang::fg::yellow`    | yes | yes |\n| `rang::fg::blue`      | yes | yes |\n| `rang::fg::magenta`   | yes | yes |\n| `rang::fg::cyan`      | yes | yes |\n| `rang::fg::gray`      | yes | yes |\n\n**Background Color**:\n\n| Code | Linux/Win/Others | Old Win\n| ---- | --------- | ------ |\n| `rang::bg::black`     | yes | yes |\n| `rang::bg::red`       | yes | yes |\n| `rang::bg::green`     | yes | yes |\n| `rang::bg::yellow`    | yes | yes |\n| `rang::bg::blue`      | yes | yes |\n| `rang::bg::magenta`   | yes | yes |\n| `rang::bg::cyan`      | yes | yes |\n| `rang::bg::gray`      | yes | yes |\n\n**Bright Foreground Color**:\n\n| Code | Linux/Win/Others | Old Win\n| ---- | --------- | ------ |\n| `rang::fgB::black`     | yes | yes |\n| `rang::fgB::red`       | yes | yes |\n| `rang::fgB::green`     | yes | yes |\n| `rang::fgB::yellow`    | yes | yes |\n| `rang::fgB::blue`      | yes | yes |\n| `rang::fgB::magenta`   | yes | yes |\n| `rang::fgB::cyan`      | yes | yes |\n| `rang::fgB::gray`      | yes | yes |\n\n**Bright Background Color**:\n\n| Code | Linux/Win/Others | Old Win\n| ---- | --------- | ------ |\n| `rang::bgB::black`     | yes | yes |\n| `rang::bgB::red`       | yes | yes |\n| `rang::bgB::green`     | yes | yes |\n| `rang::bgB::yellow`    | yes | yes |\n| `rang::bgB::blue`      | yes | yes |\n| `rang::bgB::magenta`   | yes | yes |\n| `rang::bgB::cyan`      | yes | yes |\n| `rang::bgB::gray`      | yes | yes |\n\n**Reset Styles/Colors**:\n\n| Code | Linux/Win/Others | Old Win\n| ---- | --------- | ------ |\n| `rang::style::reset`  | yes   | yes |\n| `rang::fg::reset`     | yes   | yes |\n| `rang::bg::reset`     | yes   | yes |\n\n-----\n## My terminal is not detected/gets garbage output!\n\nCheck your env variable `TERM`'s value. Then open an issue [here](https://github.com/agauniyal/rang/issues/new) and make sure to mention `TERM`'s value along with your terminal name.\n\n## Redirecting `cout`/`cerr`/`clog` rdbuf?\n\nRang 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](https://github.com/agauniyal/rang/pull/77#issuecomment-360991652) and check out the example code [here](https://gist.github.com/kingseva/a918ec66079a9475f19642ec31276a21).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagauniyal%2Frang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagauniyal%2Frang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagauniyal%2Frang/lists"}