|
5 | 5 |
|
6 | 6 | static int mosh_wcwidth( uint32_t c ) |
7 | 7 | { |
8 | | - // ZWJ is a combining character |
9 | | - if ( c == 0x0200D ) { |
10 | | - return 0; |
| 8 | + int width = widechar_wcwidth( c ); |
| 9 | + if ( width >= 0 ) { |
| 10 | + return width; |
11 | 11 | } |
12 | 12 |
|
| 13 | + /* https://github.com/ridiculousfish/widecharwidth/tree/master#c-usage */ |
| 14 | + switch ( width ) { |
| 15 | + case widechar_nonprint: |
| 16 | + return -1; |
| 17 | + case widechar_combining: |
| 18 | + return 0; |
| 19 | + case widechar_ambiguous: |
| 20 | + return 1; |
| 21 | + case widechar_private_use: |
| 22 | + return 1; |
| 23 | + case widechar_unassigned: |
| 24 | + return 1; |
| 25 | + case widechar_non_character: |
| 26 | + return -1; |
| 27 | + case widechar_widened_in_9: |
| 28 | + return 2; |
| 29 | + default: |
| 30 | + return -1; |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +static bool is_unicode_zwj( uint32_t c ) |
| 35 | +{ |
| 36 | + // ZWJ is a combining character |
| 37 | + return c == 0x0200D; |
| 38 | +} |
| 39 | + |
| 40 | +static bool is_unicode_wide_override( uint32_t c ) |
| 41 | +{ |
13 | 42 | // regional indicators are wide |
14 | 43 | switch ( c ) { |
15 | 44 | case 0x1F1E6: |
@@ -38,33 +67,9 @@ static int mosh_wcwidth( uint32_t c ) |
38 | 67 | case 0x1F1FD: |
39 | 68 | case 0x1F1FE: |
40 | 69 | case 0x1F1FF: |
41 | | - return 2; |
42 | | - } |
43 | | - |
44 | | - int width = widechar_wcwidth( c ); |
45 | | - if ( width >= 0 ) { |
46 | | - return width; |
47 | | - } |
48 | | - |
49 | | - /* https://github.com/ridiculousfish/widecharwidth/tree/master#c-usage */ |
50 | | - switch ( width ) { |
51 | | - case widechar_nonprint: |
52 | | - return -1; |
53 | | - case widechar_combining: |
54 | | - return 0; |
55 | | - case widechar_ambiguous: |
56 | | - return 1; |
57 | | - case widechar_private_use: |
58 | | - return 1; |
59 | | - case widechar_unassigned: |
60 | | - return 1; |
61 | | - case widechar_non_character: |
62 | | - return -1; |
63 | | - case widechar_widened_in_9: |
64 | | - return 2; |
65 | | - default: |
66 | | - return -1; |
| 70 | + return true; |
67 | 71 | } |
| 72 | + return false; |
68 | 73 | } |
69 | 74 |
|
70 | 75 | static bool is_unicode_modifier( wchar_t ch ) |
|
0 commit comments