mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-10-31 18:48:11 +08:00 
			
		
		
		
	Fix unsigned/signed comparison issues. (#103)
Seen here: https://github.com/VedantParanjape/simpPRU/runs/2613171696
This commit is contained in:
		| @@ -12,7 +12,9 @@ std::wstring to_wstring(T s) { | ||||
|   return to_wstring(std::to_string(s)); | ||||
| } | ||||
|  | ||||
| int wchar_width(char32_t); | ||||
| int wchar_width(wchar_t); | ||||
| int wchar_width_cjk(char32_t); | ||||
| int wchar_width_cjk(wchar_t); | ||||
| int wstring_width(const std::wstring&); | ||||
| int wstring_width_cjk(const std::wstring&); | ||||
|   | ||||
| @@ -67,12 +67,12 @@ namespace ftxui { | ||||
|  | ||||
| namespace { | ||||
| struct interval { | ||||
|   int first; | ||||
|   int last; | ||||
|   char32_t first; | ||||
|   char32_t last; | ||||
| }; | ||||
|  | ||||
| /* auxiliary function for binary search in interval table */ | ||||
| int bisearch(wchar_t ucs, const struct interval* table, int max) { | ||||
| int bisearch(char32_t ucs, const struct interval* table, int max) { | ||||
|   int min = 0; | ||||
|   int mid; | ||||
|  | ||||
| @@ -120,11 +120,11 @@ int bisearch(wchar_t ucs, const struct interval* table, int max) { | ||||
|  *      ISO 8859-1 and WGL4 characters, Unicode control characters, | ||||
|  *      etc.) have a column width of 1. | ||||
|  * | ||||
|  * This implementation assumes that wchar_t characters are encoded | ||||
|  * This implementation assumes that char32_t characters are encoded | ||||
|  * in ISO 10646. | ||||
|  */ | ||||
|  | ||||
| int wchar_width(wchar_t ucs) { | ||||
| int wchar_width(char32_t ucs) { | ||||
|   /* sorted list of non-overlapping intervals of non-spacing characters */ | ||||
|   /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */ | ||||
|   static const struct interval combining[] = { | ||||
| @@ -214,7 +214,7 @@ int wchar_width(wchar_t ucs) { | ||||
|  * the traditional terminal character-width behaviour. It is not | ||||
|  * otherwise recommended for general use. | ||||
|  */ | ||||
| int wchar_width_cjk(wchar_t ucs) { | ||||
| int wchar_width_cjk(char32_t ucs) { | ||||
|   /* sorted list of non-overlapping intervals of East Asian Ambiguous | ||||
|    * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */ | ||||
|   static const struct interval ambiguous[] = { | ||||
| @@ -278,6 +278,14 @@ int wchar_width_cjk(wchar_t ucs) { | ||||
|   return wchar_width(ucs); | ||||
| } | ||||
|  | ||||
| int wchar_width(wchar_t ucs) { | ||||
|   return wchar_width(char32_t(ucs)); | ||||
| } | ||||
|  | ||||
| int wchar_width_cjk(wchar_t ucs) { | ||||
|   return wchar_width_cjk(char32_t(ucs)); | ||||
| } | ||||
|  | ||||
| int wstring_width(const std::wstring& text) { | ||||
|   int width = 0; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Arthur Sonzogni
					Arthur Sonzogni