SkillAgentSearch skills...

Osmanip

A cross-platform library for output stream manipulation using ANSI escape sequences.

Install / Use

/learn @JustWhit3/Osmanip
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<p align="center"><img src="https://github.com/JustWhit3/osmanip/blob/main/img/logo.svg" height=220></p> <h3 align="center">A library used to manipulate the output stream of a program using ANSI escape sequences. </h3> <p align="center"> <img title="v4.5" alt="v4.5" src="https://img.shields.io/badge/version-v4.5-informational?style=flat-square"> <img title="MIT License" alt="license" src="https://img.shields.io/badge/license-MIT-informational?style=flat-square"> <img title="C++17" alt="C++17" src="https://img.shields.io/badge/c++-17-informational?style=flat-square"><br/> <img title="Code size" alt="code size" src="https://img.shields.io/github/languages/code-size/JustWhit3/osmanip?color=red"> <img title="Repo size" alt="repo size" src="https://img.shields.io/github/repo-size/JustWhit3/osmanip?color=red"> <img title="Lines of code" alt="total lines" src="https://img.shields.io/tokei/lines/github/JustWhit3/osmanip?color=red"></br> <img title="codeq" alt="codeq" src="https://github.com/JustWhit3/osmanip/actions/workflows/codeql-analysis.yml/badge.svg"> <img title="doc" alt="doc" src="https://github.com/JustWhit3/osmanip/actions/workflows/DocGenerator.yml/badge.svg"> </p>

Table of contents

Introduction

osmanip is a C++ library containing useful tools to manipulate ANSI escape sequences and customize the output stream of your programs. Within this tools you can add colors and styles to the printed strings, change cursor location on the terminal and manage other tools like progress bars and terminal graphics. Using this features may be very useful to adorn your general output stream log or to perform cursor operations.

This is a fully type- and thread-safe library with automatic memory management, with only indispensable dependencies.

It can be installed from source or via vcpkg. See this section for further details.

If you want to mention this software in one of your project / articles, please cite it.

If you use this library please tell me so I can add you to the list of know projects which use this library.

If you want to contribute to the repository, please read this file before. If you have ideas to propose write a post into the discussion section.

Code documentation is generated using Doxygen and can be accessed here. An extra wiki is also provided and contains how-to guides and many examples.

Colors and styles manipulators examples:

<img src="https://github.com/JustWhit3/osmanip/blob/main/img/csmanip_intro.gif" width = "450">

Progress bars examples:

<img src="https://github.com/JustWhit3/osmanip/blob/main/img/progressbars_intro.gif" width = "450">

2D terminal-graphics examples:

<img src="https://github.com/JustWhit3/osmanip/blob/main/img/2Dgraphics_intro.gif" width = "450">

The software is and will stay free, but if you want to support me with a donation it would be really appreciated!

<a href="https://www.buymeacoffee.com/JustWhit33" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

Architectures support

Operating systems

  • Linux
    • Ubuntu (tested)
  • Windows (release 10 or higher)
    • Cygwin64 (tested)
    • MSYS2 (tested)
    • MinGW (tested)
    • WSL (tested)
    • Powershell (tested)
  • MacOS

Compilers

  • gcc:
    • C++17: 9/10/11/12
    • C++20: 10/11/12
  • clang:
    • C++17: 6/7/8/9/10/11/12/13/14/15
    • C++20: 9/10/11/12/13/14/15
  • MSVC:
    • C++17: 19 (only this one tested)
    • C++20: // (not tested yet)

List of features

ANSI escape sequences manipulators

#include <iostream>
#include <osmanip/manipulators/colsty.hpp>

// Print a red string
std::cout << osm::feat( osm::col, "red" ) << "This string is red!" << osm::feat( osm::rst, "color" );

// Print a bold string
std::cout << osm::feat( osm::sty, "red" ) << "This string is bold!" << osm::feat( osm::rst, "bd/ft" );
#include <iostream>
#include <osmanip/manipulators/cursor.hpp>

// Move the cursor right by 2 spaces
std::cout << osm::feat( osm::crs, "right", 2 ) << "Cursor moved!";
#include <iostream>
#include <osmanip/manipulators/cursor.hpp>

// Output a bell sound
std::cout << osm::feat( osm::tcs, "bell" );
#include <iostream>
#include <osmanip/manipulators/printer.hpp>

osm::Decorator my_shell;

// Change std::cout predefined style and color
my_shell.setColor( "green", std::cout );
my_shell.setStyle( "underlined", std::cout );

my_shell( std::cout ) << "The stdout stream has been changed using the Decorator class!" << "\n";

// Change std::cerr predefined style and color
my_shell.setColor( "red", std::cerr );
my_shell.setStyle( "bold italics", std::cerr ); // NOTE: added 2 styles

my_shell( std::cerr ) << "The stderr stream has been changed using the Decorator class!" << "\n";

More examples and how-to guides can be found here.

Why choosing this library for ANSI escape sequences manipulation:

  • All the functions used to manipulate these sequences are very easy to use and don't require complex code signatures.
  • All the most common ANSI sequences can be manipulated.
  • Using the Decorator class you can set the style of an output stream at the beginning of your program and keep it unchanged until the end.

Progress bars

#include <iostream>
#include <osmanip/progressbar/progressbar.hpp>
#include <osmanip/utility/options.hpp>

osm::ProgressBar<int> percentage_bar;

percentage_bar.setMin( 5 );
percentage_bar.setMax ( 46 );
percentage_bar.setStyle( "indicator", "%" );

std::cout << "This is a normal percentage bar: " << "\n";
osm::OPTION( osm::CURSOR::OFF ); // Hide cursor for better output rendering
 for ( int i = percentage_bar.getMin(); i < percentage_bar.getMax(); i++ )
  {
   percentage_bar.update( i );
   //Do some operations...
  }
osm::OPTION( osm::CURSOR::ON );
<img src="https://github.com/JustWhit3/osmanip/blob/main/img/normal_percentage.gif" width="400">
#include <iostream>
#include <osmanip/progressbar/progressbar.hpp>
#include <osmanip/utility/options.hpp>

osm::ProgressBar<int> loading_bar( 3, 25 );

loading_bar.setStyle( "loader", "#" );
loading_bar.setBrackets( "{", "}" );
loading_bar.setMessage( "processing..." );

std::cout << "This is a loading bar: with message: " << "\n";
osm::OPTION( osm::CURSOR::OFF ); // Hide cursor for better output rendering
for ( int i = loading_bar.getMin(); i < loading_bar.getMax(); i++ )
 {
  loading_bar.update( i );
  //Do some operations...
 }
osm::OPTION( osm::CURSOR::ON );
<img src="https://github.com/JustWhit3/osmanip/blob/main/img/normal_loading.gif" width="400">
#include <iostream

Related Skills

View on GitHub
GitHub Stars221
CategoryDevelopment
Updated8d ago
Forks10

Languages

C++

Security Score

100/100

Audited on Mar 25, 2026

No findings