{"id":20181417,"url":"https://github.com/ac000/textus_coloris","last_synced_at":"2026-06-22T02:32:16.769Z","repository":{"id":66721209,"uuid":"396993747","full_name":"ac000/textus_coloris","owner":"ac000","description":"A simple \"library\" for doing colourised console output","archived":false,"fork":false,"pushed_at":"2022-12-12T15:17:26.000Z","size":23,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T06:30:34.016Z","etag":null,"topics":["c","color","colour","console","text"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ac000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"Contributing.md","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":"2021-08-16T22:20:26.000Z","updated_at":"2025-02-23T23:56:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"a5df0849-4603-42ca-892c-a8ade4eccc5a","html_url":"https://github.com/ac000/textus_coloris","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ac000/textus_coloris","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ac000%2Ftextus_coloris","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ac000%2Ftextus_coloris/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ac000%2Ftextus_coloris/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ac000%2Ftextus_coloris/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ac000","download_url":"https://codeload.github.com/ac000/textus_coloris/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ac000%2Ftextus_coloris/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34632562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["c","color","colour","console","text"],"created_at":"2024-11-14T02:35:26.234Z","updated_at":"2026-06-22T02:32:16.753Z","avatar_url":"https://github.com/ac000.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Textus Coloris\n\nSimple \"library\" for doing colourised console output.\n\n# API\n\n```C\nenum tc_coloris_mode {\n        TC_COLORIS_MODE_OFF,\n        TC_COLORIS_MODE_ON,\n        TC_COLORIS_MODE_AUTO,\n};\n```\n\nThere are five functions\n\n```C\nvoid tc_set_colors(const struct tc_coloris *colors, enum tc_coloris_mode mode);\n```\n\nThis is to set the colour map. *mode* can be one of *enum tc_coloris_mode*\nwhich produces the following behaviour\n\n```C\nTC_COLORIS_MODE_OFF\n```\n\nForces colour output off.\n\n```C\nTC_COLORIS_MODE_ON\n```\n\nForces colour output on, regardless of the [NO\\_COLOR](#no_color) setting.\n\n```C\nTC_COLORIS_MODE_AUTO\n```\n\nObey the NO\\_COLOR environment variable.\n\n\n```C\nint tc_print(FILE *fp, const char *fmt, ...);\nint tc_printv(FILE *fp, const char *fmt, va_list args);\n```\n\nThese print a colourised output to the given output stream. These are\nanalogous to the fprintf(3) \u0026 vfprintf(3) function.\n\n```C\nchar *tc_cstring(const char *fmt, ...);\nchar *tc_cstringv(const char *fmt, va_list args);\n```\n\nThese return a pointer to a colourised string. You should free(2) this\npointer, NULL will be returned on error. These are sort of analogous to the\nasprintf(3) \u0026 vasprintf(3) functions.\n\n# Use\n\nSeeing as this is really a bit too simple to make into an actual _DSO_, it is\ninstead presented as a header-only library.\n\nThis is contained under _header-only/_.\n\nThere is a simple test program to show basic usage. Essentially just copy\n_textus\\_coloris.h_ into your project and\n\n```C\n#define TEXTUS_COLORIS_IMPL\n#include \"textus_coloris.h\"\n```\n\nin **one** of your .c files. If you want to use these functions from any other\nsource files then just do\n\n```C\n#include \"textus_coloris.h\"\n```\n\nin them.\n\nDefine a colour map\n\n```C\nstatic const struct tc_coloris colors[] = {\n        { \"RED\",                \"\\e[38;5;160m\" },\n        { \"GREEN\",              \"\\e[38;5;40m\"  },\n        { \"BLUE\",               \"\\e[38;5;75m\"  },\n\n        { \"BOLD\",               \"\\e[1m\"        },\n        { \"RST\",                \"\\e[0m\"        },\n\n        {}\n};\n```\n\nthen set it with\n\n```C\ntc_set_colors(colors, TC_COLORIS_MODE_AUTO);\n```\n\nThen you can do stuff like\n\n```C\ntc_print(stdout, \"Hello World! #BOLD##GREEN#%s#RST#\\n\", \"Hello World!\");\n```\n\n## split-out\n\nThere is also a version with the core code split out into a _.c_ file. You\ncan just copy _textus\\_coloris.[ch]_ into your project and build the .c file\nas you do the rest. Then it's like the above but you don't\n_#define TEXTUS\\_COLORIS\\_IMPL_\n\nOtherwise the functionality is the same.\n\n## Examples\n\nThere are examples of usage under _header-only/_ \u0026 _split-out/_\n\n### Build\n\nOn Linux\n\n    $ make\n\nin either of the _header-only/_ \u0026 _split-out/_ directories.\n\nOn FreeBSD\n\n    $ gmake\n\nor if GCC isn't installed, it will build cleanly with clang\n\n    $ gmake CC=clang\n\n\n# NO_COLOR\n\nThis obeys the [NO\\_COLOR](https://no-color.org/) environment variable when\nusing _TC\\_COLORIS\\_MODE\\_AUTO_\n\n# Thread safety\n\nThis should be thread safe, the colour map pointer is stored in thread local\nstorage so you should be able to set per thread colour maps.\n\n# License\n\nThis licensed under under the MIT license.\n\nSee *LICENSE* in the repository root for details.\n\n# Contributing\n\nSee *CodingStyle.md* \u0026 *Contributing.md*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fac000%2Ftextus_coloris","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fac000%2Ftextus_coloris","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fac000%2Ftextus_coloris/lists"}