Git Product home page Git Product logo

ansictrl's Introduction

ansictrl

A simple header-only library providing wrappers for ansi escape sequences.

How to use

Setup

  1. clone this repository

  2. include the header

    #include "ansictrl.h"
  3. (optional) use namespace

    using namespace ansi;

    You may even use ansi::term, but beware that this contains typenames such as color, direction, etc. Using ansi::term is not recommended.

Functions

All functionality is wrapped in free functions in the ansi::term namespace. The following examples assume using namespace ansi::term; and thus omit the ansi::term:: prefix to all types and names.

  • set_color(color foreground, color background) Sets the foreground and background color (type term::color). If you only want to set one of them, set the other one to term::color::DontChange. To reset the color all attributes have to be reset with clear_attributes().

  • set_cursor_pos(u32 line, u32 column) Sets the cursor's position to the line and column specified.

  • move_cursor(dir direction, u32 amount) Moves the cursor's position by amount, in the specified direction (type term::dir).

  • Attributes Apart from the color the following attributes can be enabled:

    • bold_on()
    • blink_on()
    • underscore_on()
    • reverse_on()
    • concealed_on() These can be disabled by clearing all attributes with clear_attributes().
  • Misc. functions These are documented better in ANSI documentation than I could do here:

    • clear_line()
    • clear_screen()
    • enable_line_wrapping()
    • disable_line_wrapping()
    • save_cursor_pos()
    • restore_cursor_pos()

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.