{"id":20090471,"url":"https://github.com/64/cansid","last_synced_at":"2025-05-06T03:30:43.740Z","repository":{"id":106826540,"uuid":"100734652","full_name":"64/cansid","owner":"64","description":"A minimal ANSI escape sequence parser, written in C.","archived":false,"fork":false,"pushed_at":"2018-01-28T16:31:31.000Z","size":9,"stargazers_count":24,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T07:51:22.479Z","etag":null,"topics":["ansi-codes","ansi-colors","ansi-escape-codes","c","parser"],"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/64.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2017-08-18T17:18:11.000Z","updated_at":"2025-01-29T11:45:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"8397aa8c-20e7-4c6e-805c-740e9a74136a","html_url":"https://github.com/64/cansid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64%2Fcansid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64%2Fcansid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64%2Fcansid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64%2Fcansid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/64","download_url":"https://codeload.github.com/64/cansid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252616035,"owners_count":21776906,"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-codes","ansi-colors","ansi-escape-codes","c","parser"],"created_at":"2024-11-13T16:24:37.391Z","updated_at":"2025-05-06T03:30:43.730Z","avatar_url":"https://github.com/64.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CANSID (C ANSI Driver)\n\nThis repository contains a simple C ANSI escape sequence parser. It is intended for use in my own hobby operating system, but can be adapted for different uses.\n\n## Usage\n\nFirst, call the function `cansid_init(void)` which returns a `struct cansid_state`:\n```c\nstruct cansid_state state = cansid_init();\n```\nThen, whenever you receive a char that you want to run through the parser, hand it to `cansid_process(struct cansid_state *, char)`. This returns a `struct color_char`.\n```c\nchar c = 'x'; // Whatever you want to parse\nstruct color_char ch = cansid_process(\u0026state, c);\n```\nThe returned struct indicates how you should print the character. It contains two fields: `style`, and `ascii`. The `style` field is arranged in [this format](http://wiki.osdev.org/Text_UI#Colours). The `ascii` field is simply the character which should be printed. If `ascii` is the NUL byte (i.e `0x00` or `\\0`), then the character should not be outputted to the screen (and therefore the `style` field should be ignored too).\n\n## Building\n\nTo add CANSID to your repository, simply place the files `cansid.c` and `cansid.h` in the appropriate locations. There are no dependencies and can even be compiled in a freestanding environment.\n\n## Tests\n\nRunning tests can be done with `make test`.\n\n## Contributing\n\nFeel free to open an issue or a pull request if you would like to contribute or ask a question.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F64%2Fcansid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F64%2Fcansid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F64%2Fcansid/lists"}