{"id":13494007,"url":"https://github.com/ikalnytskyi/termcolor","last_synced_at":"2025-05-16T03:02:51.653Z","repository":{"id":12808568,"uuid":"15483474","full_name":"ikalnytskyi/termcolor","owner":"ikalnytskyi","description":"Termcolor is a header-only C++ library for printing colored messages to the terminal. Written just for fun with a help of the Force.","archived":false,"fork":false,"pushed_at":"2024-08-08T19:58:47.000Z","size":275,"stargazers_count":866,"open_issues_count":10,"forks_count":132,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-05-09T07:06:29.623Z","etag":null,"topics":["c-plus-plus","colors","console","fancy","linux","macos","terminal","windows"],"latest_commit_sha":null,"homepage":"https://termcolor.readthedocs.io/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ikalnytskyi.png","metadata":{"files":{"readme":"README.rst","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},"funding":{"ko_fi":"ikalnytskyi","custom":"https://send.monobank.ua/2GWDRDwGZ8"}},"created_at":"2013-12-27T23:02:23.000Z","updated_at":"2025-05-05T19:28:38.000Z","dependencies_parsed_at":"2022-07-12T15:04:49.097Z","dependency_job_id":"a68a7648-6e85-4019-bed3-231ab483ff3d","html_url":"https://github.com/ikalnytskyi/termcolor","commit_stats":{"total_commits":64,"total_committers":16,"mean_commits":4.0,"dds":0.390625,"last_synced_commit":"b3cb0f365f8435588df7a6b12a82b2ac5fc1fe95"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikalnytskyi%2Ftermcolor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikalnytskyi%2Ftermcolor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikalnytskyi%2Ftermcolor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikalnytskyi%2Ftermcolor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikalnytskyi","download_url":"https://codeload.github.com/ikalnytskyi/termcolor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254459081,"owners_count":22074604,"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":["c-plus-plus","colors","console","fancy","linux","macos","terminal","windows"],"created_at":"2024-07-31T19:01:20.854Z","updated_at":"2025-05-16T03:02:46.603Z","avatar_url":"https://github.com/ikalnytskyi.png","language":"C++","readme":"Termcolor\n=========\n\n.. image:: docs/_static/example.png\n   :alt: termcolor in action\n   :align: left\n\n.. -*- inclusion-marker-for-sphinx-docs -*-\n\nTermcolor_ is a header-only C++ library for printing colored messages to the\nterminal. Written just for fun with a help of `the Force`_. Termcolor uses\n`ANSI color formatting`_, so you can use it on every system that is used such\nterminals (most \\*nix systems, including Linux and Mac OS).\n\n.. note::\n\n   On Windows, `Windows API`_ is used instead of escape codes but some\n   limitations are applied (not everything is supported). That's why it's\n   recommended to enter `virtual terminal processing`_ mode and set\n   ``TERMCOLOR_USE_ANSI_ESCAPE_SEQUENCES`` macro to trick termcolor to use\n   ANSI color codes.\n\n   .. _virtual terminal processing: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences\n\nIt's licensed under the BSD (3-clause) License. That basically means: do\nwhatever you want as long as copyright sticks around.\n\n.. _Termcolor: https://github.com/ikalnytskyi/termcolor\n.. _the Force: https://starwars.wikia.com/wiki/The_Force\n.. _ANSI color formatting: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors\n.. _Windows API: https://docs.microsoft.com/en-us/windows/console/setconsoletextattribute\n\n\nInstallation\n------------\n\n* Add ``termcolor.hpp`` (grab it from ``include/termcolor/termcolor.hpp``) to\n  the project and use stream manipulators from the ``termcolor`` namespace.\n\n* You can also use vcpkg_ to install the library:\n\n  .. code:: sh\n\n     $ vcpkg install termcolor\n\n  .. _vcpkg: https://github.com/microsoft/vcpkg\n\n* Or if you are on macOS, you can use Homebrew_ for that purpose:\n\n  .. code:: sh\n\n     $ brew install termcolor\n\n  .. _Homebrew: https://brew.sh/\n\n* For up-to-date information about existing packages, refer to the the following\n  picture:\n\n  .. image:: https://repology.org/badge/vertical-allrepos/termcolor.svg\n     :target: https://repology.org/project/termcolor/versions\n     :alt: Packaging Status\n\n\nHow to use?\n-----------\n\nIt's very easy to use. The idea is built upon C++ stream manipulators.\nTypical «Hello World» application looks like this:\n\n.. code:: c++\n\n    #include \u003ciostream\u003e\n    #include \u003ctermcolor/termcolor.hpp\u003e\n\n    int main(int /*argc*/, char** /*argv*/)\n    {\n        std::cout \u003c\u003c termcolor::red \u003c\u003c \"Hello, \";                   // 16 colors\n        std::cout \u003c\u003c termcolor::color\u003c100\u003e \u003c\u003c \"Colorful \";          // 256 colors\n        std::cout \u003c\u003c termcolor::color\u003c211, 54, 130\u003e \u003c\u003c \"World!\";    // true colors\n        std::cout \u003c\u003c std::endl;\n        return 0;\n    }\n\nThe application above prints a string using different colors. There is one\ncaveat though. You must not forget to reset colors, otherwise they will be\napplied to other prints as well.\n\n.. code:: c++\n\n    std::cout \u003c\u003c termcolor::red \u003c\u003c \"Hello, Colorful World!\" \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"I'm RED too!\" \u003c\u003c std::endl;\n\nCorrect version of the code above should look like this:\n\n.. code:: c++\n\n    std::cout \u003c\u003c termcolor::red \u003c\u003c \"Hello, Colorful World!\" \u003c\u003c termcolor::reset \u003c\u003c std::endl;\n    std::cout \u003c\u003c termcolor::reset \u003c\u003c \"Here I'm!\" \u003c\u003c std::endl;\n\nBy default, Termcolor ignores any colors for non-tty streams (e.g.\n``std::stringstream``), so the following snippet\n\n.. code:: c++\n\n    std::stringstream ss;\n    ss \u003c\u003c termcolor::red \u003c\u003c \"unicorn\";\n    std::cout \u003c\u003c ss.str();\n\nwill print «unicorn» using default color, not red. In order to change this\nbehaviour one can use ``termcolor::colorize`` manipulator that enforce colors\nno matter what.\n\n\nWhat manipulators are supported?\n--------------------------------\n\nThe manipulators are divided into four groups:\n\n* *foreground*, which changes text color;\n* *background*, which changes text background color;\n* *attributes*, which changes some text style (bold, underline, etc);\n* *control*, which changes termcolor's behaviour.\n\nAlso, there are color manipulators for `16 colors`_, `256 colors`_ and\n`true colors`_ palettes.\n\n.. note::\n\n   While ``termcolor`` supports true color, it's required for the terminal\n   emulator you use to run your software to support true color too. So please\n   ensure it's supported before filing an issue.\n\n.. _16 colors: https://en.wikipedia.org/wiki/Color_depth#4-bit_color\n.. _256 colors: https://en.wikipedia.org/wiki/Color_depth#8-bit_color\n.. _true colors: https://en.wikipedia.org/wiki/Color_depth#True_color_(24-bit)\n\n\nForeground manipulators\n.......................\n\n16 colors\n`````````\n\n#. ``termcolor::grey``\n#. ``termcolor::red``\n#. ``termcolor::green``\n#. ``termcolor::yellow``\n#. ``termcolor::blue``\n#. ``termcolor::magenta``\n#. ``termcolor::cyan``\n#. ``termcolor::white``\n#. ``termcolor::bright_grey``\n#. ``termcolor::bright_red``\n#. ``termcolor::bright_green``\n#. ``termcolor::bright_yellow``\n#. ``termcolor::bright_blue``\n#. ``termcolor::bright_magenta``\n#. ``termcolor::bright_cyan``\n#. ``termcolor::bright_white``\n\n256 colors\n``````````\n\n#. ``termcolor::color\u003c256_COLOR_CODE\u003e``\n\ntrue colors\n```````````\n\n#. ``termcolor::color\u003cRED, GREEN, BLUE\u003e``\n\n\nBackground manipulators\n.......................\n\n16 colors\n`````````\n\n#. ``termcolor::on_grey``\n#. ``termcolor::on_red``\n#. ``termcolor::on_green``\n#. ``termcolor::on_yellow``\n#. ``termcolor::on_blue``\n#. ``termcolor::on_magenta``\n#. ``termcolor::on_cyan``\n#. ``termcolor::on_white``\n#. ``termcolor::on_bright_grey``\n#. ``termcolor::on_bright_red``\n#. ``termcolor::on_bright_green``\n#. ``termcolor::on_bright_yellow``\n#. ``termcolor::on_bright_blue``\n#. ``termcolor::on_bright_magenta``\n#. ``termcolor::on_bright_cyan``\n#. ``termcolor::on_bright_white``\n\n256 colors\n``````````\n\n#. ``termcolor::on_color\u003c256_COLOR_CODE\u003e``\n\n\ntrue colors\n```````````\n\n#. ``termcolor::on_color\u003cRED, GREEN, BLUE\u003e``\n\n\nAttribute manipulators\n......................\n\n(Windows API does not support these manipulators except for ``underline``)\n\n#. ``termcolor::bold``\n#. ``termcolor::dark``\n#. ``termcolor::italic``\n#. ``termcolor::underline``\n#. ``termcolor::blink``\n#. ``termcolor::reverse``\n#. ``termcolor::concealed``\n#. ``termcolor::crossed``\n\nControl manipulators\n....................\n\n(Windows API does not support these manipulators)\n\n#. ``termcolor::colorize``\n#. ``termcolor::nocolorize``\n\n\nCaveats\n-------\n\n#. On Windows, due to internal usage of ``\u003cwindows.h\u003e``, global namespace could\n   be polluted with `min`/`max` macros. If such effect is desireable, please\n   consider using ``#define NOMINMAX`` before ``#include \u003ctermcolor.hpp\u003e``.\n\n","funding_links":["https://ko-fi.com/ikalnytskyi","https://send.monobank.ua/2GWDRDwGZ8"],"categories":["C++","Terminal Utilities","C/C++ ⚙️"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikalnytskyi%2Ftermcolor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikalnytskyi%2Ftermcolor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikalnytskyi%2Ftermcolor/lists"}