diff --git a/README.md b/README.md index 0d560fe..b1761cb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,33 @@ -# cansic - C ANSI colors collection +# cansic - ANSI text formatting escape sequences in C +## Usage + +`#include` the `.h` file and use pre-defined constants + + +## Example + +```c +#include "cansic.h" +#include + +int main(void) { + const char* text = "This is a text"; + printf("%s%s%s\n", CANSIC_BOLD, text, CANSIC_END); + printf("%s%s%s\n", CANSIC_ITALIC, text, CANSIC_END); + printf("%s%s%s\n", CANSIC_UNDERLINE, text, CANSIC_END); + printf("%s%s%s\n", CANSIC_RAPIDBLINK, text, CANSIC_END); + printf("%s\n", CANSIC_BOLD CANSIC_UNDERLINE CANSIC_SLOWBLINK "String literals are more elegant" CANSIC_END); + + printf("%s%s%s\n", CANSIC_FG_RGB(90, 50, 200), text, CANSIC_END); + printf("%s%s%s\n", CANSIC_BG_RGB(255, 55, 55), text, CANSIC_END); + + return 0; +} ``` -``` \ No newline at end of file + +It is your responsibility to check whether the interface supports this ANSI format or not + +## License + +MIT \ No newline at end of file diff --git a/cansic.h b/cansic.h index 34e3d24..5f165a6 100644 --- a/cansic.h +++ b/cansic.h @@ -10,8 +10,8 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef CANSICC_H -#define CANSICC_H +#ifndef CANSIC_H +#define CANSIC_H #define CANSIC_ESC "\033[" #define CANSIC_END "\033[0m"