Osmanip
A cross-platform library for output stream manipulation using ANSI escape sequences.
Install / Use
/learn @JustWhit3/OsmanipREADME
Table of contents
- Introduction
- Architectures support
- List of features
- Install and use
- Todo
- List of known projects which use this library
- Credits
- Stargazers over time
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
- Color and style manipulation ( list of all available colors and styles here)
#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!";
- Terminal control sequences ( list of all the available terminal control sequences here)
#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
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
