Support full-width characters (CJK)

+ 3 tests.

The goal is to fix:
https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
This commit is contained in:
ArthurSonzogni
2019-06-24 23:39:37 +02:00
parent 9c1913de51
commit eb6baaceea
8 changed files with 358 additions and 16 deletions

View File

@@ -104,9 +104,12 @@ std::string Screen::ToString() {
for (int y = 0; y < dimy_; ++y) {
if (y != 0)
ss << '\n';
for (int x = 0; x < dimx_; ++x) {
UpdatePixelStyle(ss, previous_pixel, pixels_[y][x]);
ss << pixels_[y][x].character;
for (int x = 0; x < dimx_;) {
auto& pixel = pixels_[y][x];
wchar_t c = pixel.character;
UpdatePixelStyle(ss, previous_pixel, pixel);
ss << c;
x += wchar_width(c);
}
}