| 
									
										
										
										
											2019-06-24 23:39:37 +02:00
										 |  |  | #ifndef FTXUI_SCREEN_STRING_HPP
 | 
					
						
							|  |  |  | #define FTXUI_SCREEN_STRING_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-07 11:03:54 +01:00
										 |  |  | #include <stddef.h>  // for size_t
 | 
					
						
							|  |  |  | #include <string>    // for string, wstring, to_string
 | 
					
						
							|  |  |  | #include <vector>    // for vector
 | 
					
						
							| 
									
										
										
										
											2018-09-18 08:48:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-09 14:53:56 +02:00
										 |  |  | namespace ftxui { | 
					
						
							| 
									
										
										
										
											2018-09-18 08:48:40 +02:00
										 |  |  | std::string to_string(const std::wstring& s); | 
					
						
							|  |  |  | std::wstring to_wstring(const std::string& s); | 
					
						
							| 
									
										
										
										
											2019-01-06 16:10:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-23 21:26:00 +01:00
										 |  |  | template <typename T> | 
					
						
							| 
									
										
										
										
											2019-01-06 16:10:57 +01:00
										 |  |  | std::wstring to_wstring(T s) { | 
					
						
							|  |  |  |   return to_wstring(std::to_string(s)); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-06-24 23:39:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-08 23:25:20 +02:00
										 |  |  | int string_width(const std::string&); | 
					
						
							| 
									
										
										
										
											2021-12-12 21:31:54 +01:00
										 |  |  | // Split the string into a its glyphs. An empty one is inserted ater fullwidth
 | 
					
						
							|  |  |  | // ones.
 | 
					
						
							| 
									
										
										
										
											2021-08-08 23:25:20 +02:00
										 |  |  | std::vector<std::string> Utf8ToGlyphs(const std::string& input); | 
					
						
							| 
									
										
										
										
											2021-12-12 21:31:54 +01:00
										 |  |  | // If |input| was an array of glyphs, this returns the number of char to eat
 | 
					
						
							|  |  |  | // before reaching the glyph at index |glyph_index|.
 | 
					
						
							|  |  |  | int GlyphPosition(const std::string& input, | 
					
						
							|  |  |  |                   size_t glyph_index, | 
					
						
							|  |  |  |                   size_t start = 0); | 
					
						
							|  |  |  | // Returns the number of glyphs in |input|.
 | 
					
						
							|  |  |  | int GlyphCount(const std::string& input); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-06 21:16:55 +02:00
										 |  |  | // Properties from:
 | 
					
						
							|  |  |  | // https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/WordBreakProperty.txt
 | 
					
						
							|  |  |  | enum class WordBreakProperty { | 
					
						
							|  |  |  |   ALetter, | 
					
						
							|  |  |  |   CR, | 
					
						
							|  |  |  |   Double_Quote, | 
					
						
							|  |  |  |   Extend, | 
					
						
							|  |  |  |   ExtendNumLet, | 
					
						
							|  |  |  |   Format, | 
					
						
							|  |  |  |   Hebrew_Letter, | 
					
						
							|  |  |  |   Katakana, | 
					
						
							|  |  |  |   LF, | 
					
						
							|  |  |  |   MidLetter, | 
					
						
							|  |  |  |   MidNum, | 
					
						
							|  |  |  |   MidNumLet, | 
					
						
							|  |  |  |   Newline, | 
					
						
							|  |  |  |   Numeric, | 
					
						
							|  |  |  |   Regional_Indicator, | 
					
						
							|  |  |  |   Single_Quote, | 
					
						
							|  |  |  |   WSegSpace, | 
					
						
							|  |  |  |   ZWJ, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | std::vector<WordBreakProperty> Utf8ToWordBreakProperty( | 
					
						
							|  |  |  |     const std::string& input); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool IsWordBreakingCharacter(const std::string& input, size_t glyph_index); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-12 21:31:54 +01:00
										 |  |  | // Map every cells drawn by |input| to their corresponding Glyphs. Half-size
 | 
					
						
							|  |  |  | // Glyphs takes one cell, full-size Glyphs take two cells.
 | 
					
						
							|  |  |  | std::vector<int> CellToGlyphIndex(const std::string& input); | 
					
						
							| 
									
										
										
										
											2021-05-14 21:43:35 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-09 14:53:56 +02:00
										 |  |  | }  // namespace ftxui
 | 
					
						
							| 
									
										
										
										
											2019-06-24 23:39:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-09 00:27:37 +02:00
										 |  |  | #include "ftxui/screen/deprecated.hpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-24 23:39:37 +02:00
										 |  |  | #endif /* end of include guard: FTXUI_SCREEN_STRING_HPP */
 | 
					
						
							| 
									
										
										
										
											2020-08-16 00:24:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Copyright 2020 Arthur Sonzogni. All rights reserved.
 | 
					
						
							|  |  |  | // Use of this source code is governed by the MIT license that can be found in
 | 
					
						
							|  |  |  | // the LICENSE file.
 |