forked from Alepha/Alepha
Clean up some bugs in the console color code.
This commit is contained in:
@ -168,8 +168,11 @@ namespace Alepha::Hydrogen ::detail:: console
|
|||||||
const int r= boost::lexical_cast< int >( rgb.substr( 0, 1 ) );
|
const int r= boost::lexical_cast< int >( rgb.substr( 0, 1 ) );
|
||||||
const int g= boost::lexical_cast< int >( rgb.substr( 1, 1 ) );
|
const int g= boost::lexical_cast< int >( rgb.substr( 1, 1 ) );
|
||||||
const int b= boost::lexical_cast< int >( rgb.substr( 2, 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;
|
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 );
|
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() };
|
return { std::move( oss ).str() };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -237,7 +237,7 @@ namespace Alepha::Hydrogen ::detail:: console
|
|||||||
rgb_base= 16,
|
rgb_base= 16,
|
||||||
red_radix= 36,
|
red_radix= 36,
|
||||||
green_radix= 6,
|
green_radix= 6,
|
||||||
blue_radix= 0,
|
blue_radix= 1,
|
||||||
|
|
||||||
greyscale_base= 232, // Add N to this to get the greyscale offset.
|
greyscale_base= 232, // Add N to this to get the greyscale offset.
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user