1
0
forked from Alepha/Alepha

Clean up some bugs in the console color code.

This commit is contained in:
2023-10-24 00:35:49 -04:00
parent 6aa302f791
commit 7cd33b9164
2 changed files with 5 additions and 2 deletions

View File

@ -168,8 +168,11 @@ namespace Alepha::Hydrogen ::detail:: console
const int r= boost::lexical_cast< int >( rgb.substr( 0, 1 ) );
const int g= boost::lexical_cast< int >( rgb.substr( 1, 1 ) );
const int b= boost::lexical_cast< int >( rgb.substr( 2, 1 ) );
if( r < 0 or r > 5 ) throw std::runtime_error( "ext:rgb requested red value `" + rgb.substr( 0, 1 ) + "` out of range [0,5]" );
if( g < 0 or g > 5 ) throw std::runtime_error( "ext:rgb requested green value `" + rgb.substr( 1, 1 ) + "` out of range [0,5]" );
if( b < 0 or b > 5 ) throw std::runtime_error( "ext:rgb requested blue value `" + rgb.substr( 2, 1 ) + "` out of range [0,5]" );
std::ostringstream oss;
oss << "3;5;";
oss << "38;5;";
oss << int( TextColor::rgb_base ) + r * int( TextColor::red_radix ) + g * int( TextColor::green_radix ) + b * int( TextColor::blue_radix );
return { std::move( oss ).str() };
}

View File

@ -237,7 +237,7 @@ namespace Alepha::Hydrogen ::detail:: console
rgb_base= 16,
red_radix= 36,
green_radix= 6,
blue_radix= 0,
blue_radix= 1,
greyscale_base= 232, // Add N to this to get the greyscale offset.
};