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