{"id":18770101,"url":"https://github.com/andreacasalino/coloredstream","last_synced_at":"2026-04-29T19:33:57.847Z","repository":{"id":44055714,"uuid":"451093529","full_name":"andreacasalino/ColoredStream","owner":"andreacasalino","description":"c++ stringstream handling colors","archived":false,"fork":false,"pushed_at":"2023-12-19T17:33:09.000Z","size":117,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-15T22:45:00.236Z","etag":null,"topics":["color","colors","colour","colours","console","cout","cpp","ostream","print","stream","terminal","text"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreacasalino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2022-01-23T12:12:37.000Z","updated_at":"2023-12-18T14:34:51.000Z","dependencies_parsed_at":"2025-05-20T23:44:22.856Z","dependency_job_id":null,"html_url":"https://github.com/andreacasalino/ColoredStream","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andreacasalino/ColoredStream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FColoredStream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FColoredStream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FColoredStream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FColoredStream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreacasalino","download_url":"https://codeload.github.com/andreacasalino/ColoredStream/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreacasalino%2FColoredStream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32441223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T18:12:22.909Z","status":"ssl_error","status_checked_at":"2026-04-29T18:11:33.322Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["color","colors","colour","colours","console","cout","cpp","ostream","print","stream","terminal","text"],"created_at":"2024-11-07T19:18:07.853Z","updated_at":"2026-04-29T19:33:57.830Z","avatar_url":"https://github.com/andreacasalino.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"This small package is intended to allow printing **colored** text into **C++** console applications.\n\nBefore doing anything else, leave a **star** to this project ;).\n\nWhat you would see from the console using this package:\n\n![temp](pictures/Sample.png)\n\nIt is cross-platform and all the functionalities are contained in [**ColoredStream.h**](./src/ColoredStream/ColoredStream.h).\n\nThe ability to show a colored text is made possible by building and printing a **ColoredText** object.\n**ColoredText** extends **std::stringstream** adding the possibility to show colored text.\nSuch ability is enabled when passing a **ColoredText** instance to a **std::cout** or a **std::cerr** for printing something into the console. On the opposite, when passing a **ColoredText** instance to another kind of output stream, like for instance a **std::ofstream**, the object behaves like a normal **std::stringstream**, printing normal text.\n\nThree possible color prescriptions can be specified:\n - specify classical colors like **red** or **yellow**\n - specify a [8-bit color](https://en.wikipedia.org/wiki/ANSI_escape_code) code \n - specify a [R,G,B](https://en.wikipedia.org/wiki/ANSI_escape_code) triplet \n\nIt is also possible to apply a specific background color:\n![temp](pictures/part04.png)\n\nThe kind of color used for specifying the text (R,G,B triplet, 8-bit code, etc...) can be different from the one used for the background.\n\n## EXAMPLES\n\nStill haven't left a **star**? Do it now!! ;).\n\nUsing this package is straightforward: you just need to create a **ColoredText** object and then pass it to **std::cout** (or **std::cerr**) for printing it.\nSuppose for example you want to display a red colored 'hello world', all you need to do would be this:\n\n```cpp\n#include \u003cColoredStream/ColoredStream.h\u003e\nusing namespace colored_stream;\n\nstd::cout \u003c\u003c ColoredText{ClassicColor::RED, \"Hello world\"} \u003c\u003c std::endl;\n```\n\n![temp](pictures/part01.png)\n\nand that's it!\n\nYou may also want to create an empty **ColoredText** instance, whose content is created step by step, before printing it:\n\n```cpp\nColoredText colored_content(ClassicColor::RED);\ncolored_content \u003c\u003c \"Hello \";\ncolored_content \u003c\u003c \"World \";\ncolored_content \u003c\u003c \" :-)\";\n\nstd::cout \u003c\u003c colored_content \u003c\u003c std::endl;\n```\n\n![temp](pictures/part02.png)\n\n... or, you can pass a variadic number of inputs in order to build the object in place:\n\n```cpp\nstd::cout \u003c\u003c ColoredText{ClassicColor::BLUE, \"Hello \", \"World \", \" :-)\"}\n            \u003c\u003c std::endl;\n```\n\n![temp](pictures/part03.png)\n\nYou can also prescribe the background color and not only the text one:\n\n```cpp\nColoredText stream{\n    Settings{}.text(ClassicColor::RED).background(Uint8Color{11}),\n    \"Hello World\"};\nstd::cout \u003c\u003c stream \u003c\u003c std::endl;\n```\n\n![temp](pictures/part04.png)\n\nYou can also decide to bind a certain color to a certain concrete **std::ostream** so that everything that will be passed to that stream will be rendered with a certain color. Indeed, you can use **ColoredStream** for this:\n```cpp\nColoredStream stream{ClassicColor::MAGENTA, std::cerr};\nstream \u003c\u003c \"All this line was \"\n        \u003c\u003c \"passed to the same \"\n        \u003c\u003c \" ColoredStream\";\n\nstream \u003c\u003c \" ... also this from another line of code\" \u003c\u003c std::endl;\n```\n\n![temp](pictures/part05.png)\n\nThe created stream will be a wrapper of the concrete passed one. Every time something is passed to the wrapper, the prescription about the text and the background color is added and then the content is actually propagated to the concrete stream. \n\nCheck the [samples folder](./samples) for other examples.\n\n## CMAKE SUPPORT\n\nYou can fetch this package and link to the **ColoredStream** library, which will expose the position of [**ColoredStream.h**](./src/ColoredStream/ColoredStream.h):\n\n```cmake\ninclude(FetchContent)\nFetchContent_Declare(\ncolored_stream\nGIT_REPOSITORY https://github.com/andreacasalino/ColoredStream.git\nGIT_TAG        main\n)\nFetchContent_MakeAvailable(colored_stream)\n```\nand then link to the **ColoredStream** library:\n\n```cmake\ntarget_link_libraries(${TARGET_NAME}\n    ColoredStream\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreacasalino%2Fcoloredstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreacasalino%2Fcoloredstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreacasalino%2Fcoloredstream/lists"}