Coder Social home page Coder Social logo

artiom-astashonak / belformat Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 1.0 482 KB

Formatting tools for the terminal output in C

License: MIT License

Makefile 5.09% C 94.91%
c formatting output terminal library markdown syntax-highlighting ansi styling

belformat's Introduction

belformat

Belformat is a simple and convenient tool for styling and formatting output in C. Use a syntax similar to HTML and add originality to your project. Belformat operates around the standard output functions in C from stdio.h, as well as ANSI escape codes.

The library is written in the C programming language and does not require additional dependencies to function. You can use this tool as either a statically generated library or as a dynamic library depending on your needs.

The project is open to everyone, and anyone familiar with CONTRIBUTING.md can suggest their own changes to the repository to make Belformat better and more convenient.

Examples

If you prefer not to read all the detailed examples of the library usage below, compile a single example file and run it by executing:

$ make examples
$ ./exam

Formatting

Belformat provides all the standard formatting methods available to ANSI users with a simpler and more understandable syntax.

Bold

Use the <b> tag (for bold) before the start of the text block you want to make bold, and close the tag with </> at the end f the block to reset all styles added before it.

</> is universal for every single tag, as it appends clear sequence that deletes all styling. Bold text

Italic

To achieve italic text, use the <i> tag (for italic) and close it with </> at the very end, resulting in a similar outcome:

Italic text

Underlined

Underline text with the <u> tag (for underlined), which like all tags, must be closed with </> to remove its effect for all subsequent characters.

Underlined text

Strikethrough

To get strikethrough text, use the combination of <s> tag (for strikethrough) and </> as in previous cases.

Strikethrough text

Dim

Dim color is relative to the current text color and depends on your terminal settings. Use a combination of <d> tag (for dim) and </> to achieve the desired result.

Dim text

Reversed

Reversed color swaps the text color and the background color. Use <r> (for reversed) along with </>.

Reversed text

Blinking

This type may not be available for your terminal. Wrap the text in <l> (for blinking) and close it with </>.

Private

You can hide the output values using <p> (for private) and close it with </>.

Styling

In addition to formatting using standard ANSI, you can also style text using terminal-dependent colors. Available colors are: black, red, green, blue, yellow, magenta, cyan and white.

The general syntax for adding colors works as follows: <tag_name;foreground_color;background_color>. For example: Colors example

To add color exclusively without formatting, use the <c> (for color) tag.

If you wish to have your own colors, you can add them with HEX color notation like so: User colors

Utility

The project also has several utilities for logging output (bellog() function), information (belinfo() function), warnings (belwarn() function), and errors (belerror() function).

Utility functions

Compilation

Belformat assumes you have a C compiler (either GCC or clang) installed, as well as GNU make for building the library.

To generate a dynamic library, follow the instructions for your operating system below:

POSIX

$ make psx_belformat

Windows

$ make win_belformat

Otherwise, generate a static library with the following command:

$ make static_belformat

belformat's People

Contributors

detectivekaktus avatar

Stargazers

Vishvam S avatar Karim Elkhanoufi avatar  avatar E169 avatar  avatar Xavier G. avatar Clayton Kehoe avatar  avatar Tim avatar Hoorad Farrokh avatar CobbCoding avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sekerea

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.