termstyle 1.0.0-pre.3
An open-source C++ header file that enables developers to easily define and apply customizable style presets for terminal outputs such as warnings, infos, and errors.
Loading...
Searching...
No Matches
tests/col256.cpp

This is an example of how to use the Col256 struct.

#include "../include/termstyle.hpp"
namespace ts = termstyle;
int main()
{
std::vector<ts::PresetConfig> configs(256);
for (int i = 0; i < 256; i++)
{
ts::PresetConfig config = {
.prefix = {
.prestyles = {ts::Color(ts::Col256(ts::ColorMode::FOREGROUND, i))},
.text = "[Color #" + std::to_string(i) + "]",
.poststyles = {ts::Color(ts::Codes::RESTORE), ts::Color(ts::Col256(ts::ColorMode::BACKGROUND, i))}
}
};
ts::addPreset("color" + std::to_string(i), config);
}
for (int i = 0; i < 256; i++)
{
ts::print("color" + std::to_string(i), " ");
}
return 0;
}
void addPreset(std::string name, PresetConfig preset)
Adds a preset with the given name and configuration.
Definition termstyle.hpp:634
void print(std::string preset, std::string text="")
Definition termstyle.hpp:666
Namespace for the termstyle library.
Definition termstyle.hpp:116
Struct for storing 256-color codes.
Definition termstyle.hpp:258
Struct for storing different types of colors.
Definition termstyle.hpp:384
Struct for storing preset configurations.
Definition termstyle.hpp:512
StyleString prefix
Definition termstyle.hpp:514
std::vector< Color > prestyles
Definition termstyle.hpp:428