Last active
March 3, 2021 09:10
-
-
Save Bktero/fb0beea33f07799713e37b8e62f8245b to your computer and use it in GitHub Desktop.
[C++] Colored text in console with library Rang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.17) | |
project(hello_rang) | |
set(CMAKE_CXX_STANDARD 11) | |
# Get library from Github | |
include(FetchContent) | |
FetchContent_Declare(rang GIT_REPOSITORY https://github.com/agauniyal/rang.git GIT_TAG v3.1.0) | |
FetchContent_MakeAvailable(rang) | |
# Create executable | |
add_executable(hello_rang main.cpp) | |
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${rang_SOURCE_DIR}/include) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rang.hpp" | |
int main() { | |
std::cout << rang::style::italic << rang::bg::green << rang::fg::red << "hello, "; | |
std::cout << rang::style::underline << rang::bgB::green << rang::fgB::red << "colored world"; | |
std::cout << rang::style::reset << rang::bg::reset << rang::fg::reset << '\n'; | |
} |
Author
Bktero
commented
Feb 16, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment