mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-18 09:08:08 +08:00
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:
@@ -1,4 +1,5 @@
|
||||
#include "ftxui/dom/node.hpp"
|
||||
#include "ftxui/screen/string.hpp"
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
@@ -10,7 +11,7 @@ class Text : public Node {
|
||||
~Text() {}
|
||||
|
||||
void ComputeRequirement() override {
|
||||
requirement_.min.x = text_.size();
|
||||
requirement_.min.x = wstring_width(text_);
|
||||
requirement_.min.y = 1;
|
||||
}
|
||||
|
||||
@@ -22,7 +23,8 @@ class Text : public Node {
|
||||
for (wchar_t c : text_) {
|
||||
if (x > box_.x_max)
|
||||
return;
|
||||
screen.at(x++, y) = c;
|
||||
screen.at(x, y) = c;
|
||||
x += wchar_width(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user