Giter Club home page Giter Club logo

cansid's Introduction

CANSID (C ANSI Driver)

This 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.

Usage

First, call the function cansid_init(void) which returns a struct cansid_state:

struct cansid_state state = cansid_init();

Then, 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.

char c = 'x'; // Whatever you want to parse
struct color_char ch = cansid_process(&state, c);

The returned struct indicates how you should print the character. It contains two fields: style, and ascii. The style field is arranged in this format. 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).

Building

To 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.

Tests

Running tests can be done with make test.

Contributing

Feel free to open an issue or a pull request if you would like to contribute or ask a question.

cansid's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.