mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-11-04 21:48:15 +08:00 
			
		
		
		
	Support combining characters. (#121)
Modify the ftxui::Pixel. Instead of storing a wchar, store a std::wstring. Now a single pixel can store multiple codepoints. If a codepoint is of size <=0, it will be appended to the previous pixel. Only ftxui::text() is supported. ftxui::vtext support still needs to be added. This causes the following CPU and memory regression: - Memory: Pixel size increases by 200% (16 byte => 48byte). - CPU: Draw/Second decrease by 62.5% (16k draw/s => 6k draw/s on 80x80) Both regressions are acceptable. There are still two orders of magnitude (100x) before the levels where performance/memory concerns begins. This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/109
This commit is contained in:
		@@ -18,9 +18,16 @@ using Element = std::shared_ptr<Node>;
 | 
			
		||||
/// @brief A unicode character and its associated style.
 | 
			
		||||
/// @ingroup screen
 | 
			
		||||
struct Pixel {
 | 
			
		||||
  // The graphemes stored into the pixel. To support combining characters,
 | 
			
		||||
  // like: a⃦, this can potentially contains multiple codepoitns.
 | 
			
		||||
  // Required: character.size() >= 1;
 | 
			
		||||
  std::wstring character = L" ";
 | 
			
		||||
 | 
			
		||||
  // Colors:
 | 
			
		||||
  Color background_color = Color::Default;
 | 
			
		||||
  Color foreground_color = Color::Default;
 | 
			
		||||
  wchar_t character = U' ';
 | 
			
		||||
 | 
			
		||||
  // A bit field representing the style:
 | 
			
		||||
  bool blink : 1;
 | 
			
		||||
  bool bold : 1;
 | 
			
		||||
  bool dim : 1;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user