Add support for full RGB colors.

FTXUI supported only the 16 colors palette.
This patch adds support for the 256 palette and the TrueColor(8×8×8)
mode.

This was made by kerdelos@ and fixes issue:
https://github.com/ArthurSonzogni/FTXUI/issues/45

Co-authored-by: Damien D <kerdelos@gmail.com>
Co-authored-by: Arthur Sonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
Damien D
2020-09-02 11:32:22 +02:00
committed by Arthur Sonzogni
parent 49941b6403
commit dc8c090753
10 changed files with 846 additions and 38 deletions

View File

@@ -85,11 +85,8 @@ void UpdatePixelStyle(std::wstringstream& ss, Pixel& previous, Pixel& next) {
if (next.foreground_color != previous.foreground_color ||
next.background_color != previous.background_color) {
ss << L"\x1B[" +
to_wstring(std::to_string((uint8_t)next.foreground_color)) + L"m";
ss << L"\x1B[" +
to_wstring(std::to_string(10 + (uint8_t)next.background_color)) +
L"m";
ss << L"\x1B[" + next.foreground_color.Print(false) + L"m";
ss << L"\x1B[" + next.background_color.Print(true) + L"m";
}
previous = next;
@@ -105,7 +102,7 @@ Dimension Dimension::Fixed(int v) {
}
/// The minimal dimension that will fit the given element.
/// @see Fixed
/// @see Fixed
/// @see Full
Dimension Dimension::Fit(Element& e) {
e->ComputeRequirement();
@@ -115,7 +112,7 @@ Dimension Dimension::Fit(Element& e) {
}
/// Use the terminal dimensions.
/// @see Fixed
/// @see Fixed
/// @see Fit
Dimension Dimension::Full() {
Terminal::Dimensions size = Terminal::Size();