Created
March 20, 2016 13:21
-
-
Save mattn/cf8c6de760a33dbc3a28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/mbyte.c b/src/mbyte.c | |
index 313db76..b51c27d 100644 | |
--- a/src/mbyte.c | |
+++ b/src/mbyte.c | |
@@ -179,6 +179,156 @@ static char utf8len_tab_zero[256] = | |
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0, | |
}; | |
+#ifdef FEAT_MBYTE | |
+struct interval | |
+{ | |
+ long first; | |
+ long last; | |
+}; | |
+ | |
+/* Sorted list of non-overlapping intervals of Emoji characters, | |
+ * based on http://unicode.org/emoji/charts/emoji-list.html */ | |
+static struct interval emoji_tab[] = | |
+{ | |
+ {0x203c, 0x203c}, | |
+ {0x2049, 0x2049}, | |
+ {0x2122, 0x2122}, | |
+ {0x2139, 0x2139}, | |
+ {0x2194, 0x2199}, | |
+ {0x21a9, 0x21aa}, | |
+ {0x231a, 0x231b}, | |
+ {0x2328, 0x2328}, | |
+ {0x23cf, 0x23cf}, | |
+ {0x23e9, 0x23f3}, | |
+ {0x24c2, 0x24c2}, | |
+ {0x25aa, 0x25ab}, | |
+ {0x25b6, 0x25b6}, | |
+ {0x25c0, 0x25c0}, | |
+ {0x25fb, 0x25fe}, | |
+ {0x2600, 0x2604}, | |
+ {0x260e, 0x260e}, | |
+ {0x2611, 0x2611}, | |
+ {0x2614, 0x2615}, | |
+ {0x2618, 0x2618}, | |
+ {0x261d, 0x261d}, | |
+ {0x2620, 0x2620}, | |
+ {0x2622, 0x2623}, | |
+ {0x2626, 0x2626}, | |
+ {0x262a, 0x262a}, | |
+ {0x262e, 0x262f}, | |
+ {0x2638, 0x263a}, | |
+ {0x2648, 0x2653}, | |
+ {0x2660, 0x2660}, | |
+ {0x2663, 0x2663}, | |
+ {0x2665, 0x2666}, | |
+ {0x2668, 0x2668}, | |
+ {0x267b, 0x267b}, | |
+ {0x267f, 0x267f}, | |
+ {0x2692, 0x2694}, | |
+ {0x2696, 0x2697}, | |
+ {0x2699, 0x2699}, | |
+ {0x269b, 0x269c}, | |
+ {0x26a0, 0x26a1}, | |
+ {0x26aa, 0x26ab}, | |
+ {0x26b0, 0x26b1}, | |
+ {0x26bd, 0x26be}, | |
+ {0x26c4, 0x26c5}, | |
+ {0x26c8, 0x26c8}, | |
+ {0x26ce, 0x26ce}, | |
+ {0x26cf, 0x26cf}, | |
+ {0x26d1, 0x26d1}, | |
+ {0x26d3, 0x26d4}, | |
+ {0x26e9, 0x26ea}, | |
+ {0x26f0, 0x26f5}, | |
+ {0x26f7, 0x26fa}, | |
+ {0x26fd, 0x26fd}, | |
+ {0x2702, 0x2702}, | |
+ {0x2705, 0x2705}, | |
+ {0x2708, 0x2709}, | |
+ {0x270a, 0x270b}, | |
+ {0x270c, 0x270d}, | |
+ {0x270f, 0x270f}, | |
+ {0x2712, 0x2712}, | |
+ {0x2714, 0x2714}, | |
+ {0x2716, 0x2716}, | |
+ {0x271d, 0x271d}, | |
+ {0x2721, 0x2721}, | |
+ {0x2728, 0x2728}, | |
+ {0x2733, 0x2734}, | |
+ {0x2744, 0x2744}, | |
+ {0x2747, 0x2747}, | |
+ {0x274c, 0x274c}, | |
+ {0x274e, 0x274e}, | |
+ {0x2753, 0x2755}, | |
+ {0x2757, 0x2757}, | |
+ {0x2763, 0x2764}, | |
+ {0x2795, 0x2797}, | |
+ {0x27a1, 0x27a1}, | |
+ {0x27b0, 0x27b0}, | |
+ {0x27bf, 0x27bf}, | |
+ {0x2934, 0x2935}, | |
+ {0x2b05, 0x2b07}, | |
+ {0x2b1b, 0x2b1c}, | |
+ {0x2b50, 0x2b50}, | |
+ {0x2b55, 0x2b55}, | |
+ {0x3030, 0x3030}, | |
+ {0x303d, 0x303d}, | |
+ {0x3297, 0x3297}, | |
+ {0x3299, 0x3299}, | |
+ {0x1f004, 0x1f004}, | |
+ {0x1f0cf, 0x1f0cf}, | |
+ {0x1f170, 0x1f171}, | |
+ {0x1f17e, 0x1f17e}, | |
+ {0x1f17f, 0x1f17f}, | |
+ {0x1f18e, 0x1f18e}, | |
+ {0x1f191, 0x1f19a}, | |
+ {0x1f1e6, 0x1f1ff}, | |
+ {0x1f201, 0x1f202}, | |
+ {0x1f21a, 0x1f21a}, | |
+ {0x1f22f, 0x1f22f}, | |
+ {0x1f232, 0x1f23a}, | |
+ {0x1f250, 0x1f251}, | |
+ {0x1f300, 0x1f320}, | |
+ {0x1f330, 0x1f335}, | |
+ {0x1f337, 0x1f37c}, | |
+ {0x1f380, 0x1f393}, | |
+ {0x1f3a0, 0x1f3c4}, | |
+ {0x1f3c6, 0x1f3ca}, | |
+ {0x1f3e0, 0x1f3f0}, | |
+ {0x1f400, 0x1f43e}, | |
+ {0x1f440, 0x1f440}, | |
+ {0x1f442, 0x1f4f7}, | |
+ {0x1f4f9, 0x1f4fc}, | |
+ {0x1f500, 0x1f53d}, | |
+ {0x1f550, 0x1f567}, | |
+ {0x1f5fb, 0x1f5ff}, | |
+ {0x1f600, 0x1f600}, | |
+ {0x1f601, 0x1f610}, | |
+ {0x1f611, 0x1f611}, | |
+ {0x1f612, 0x1f614}, | |
+ {0x1f615, 0x1f615}, | |
+ {0x1f616, 0x1f616}, | |
+ {0x1f617, 0x1f617}, | |
+ {0x1f618, 0x1f618}, | |
+ {0x1f619, 0x1f619}, | |
+ {0x1f61a, 0x1f61a}, | |
+ {0x1f61b, 0x1f61b}, | |
+ {0x1f61c, 0x1f61e}, | |
+ {0x1f61f, 0x1f61f}, | |
+ {0x1f620, 0x1f625}, | |
+ {0x1f626, 0x1f627}, | |
+ {0x1f628, 0x1f62b}, | |
+ {0x1f62c, 0x1f62c}, | |
+ {0x1f62d, 0x1f62d}, | |
+ {0x1f62e, 0x1f62f}, | |
+ {0x1f630, 0x1f633}, | |
+ {0x1f634, 0x1f634}, | |
+ {0x1f635, 0x1f640}, | |
+ {0x1f645, 0x1f64f}, | |
+ {0x1f680, 0x1f6c5} | |
+}; | |
+#endif | |
+ | |
/* | |
* XIM often causes trouble. Define XIM_DEBUG to get a log of XIM callbacks | |
* in the "xim.log" file. | |
@@ -1176,11 +1326,6 @@ dbcs_ptr2len_len(char_u *p, int size) | |
return len; | |
} | |
-struct interval | |
-{ | |
- long first; | |
- long last; | |
-}; | |
static int intable(struct interval *table, size_t size, int c); | |
/* | |
@@ -1436,148 +1581,6 @@ utf_char2cells(int c) | |
{0x100000, 0x10fffd} | |
}; | |
- /* Sorted list of non-overlapping intervals of Emoji characters, | |
- * based on http://unicode.org/emoji/charts/emoji-list.html */ | |
- static struct interval emoji[] = | |
- { | |
- {0x203c, 0x203c}, | |
- {0x2049, 0x2049}, | |
- {0x2122, 0x2122}, | |
- {0x2139, 0x2139}, | |
- {0x2194, 0x2199}, | |
- {0x21a9, 0x21aa}, | |
- {0x231a, 0x231b}, | |
- {0x2328, 0x2328}, | |
- {0x23cf, 0x23cf}, | |
- {0x23e9, 0x23f3}, | |
- {0x24c2, 0x24c2}, | |
- {0x25aa, 0x25ab}, | |
- {0x25b6, 0x25b6}, | |
- {0x25c0, 0x25c0}, | |
- {0x25fb, 0x25fe}, | |
- {0x2600, 0x2604}, | |
- {0x260e, 0x260e}, | |
- {0x2611, 0x2611}, | |
- {0x2614, 0x2615}, | |
- {0x2618, 0x2618}, | |
- {0x261d, 0x261d}, | |
- {0x2620, 0x2620}, | |
- {0x2622, 0x2623}, | |
- {0x2626, 0x2626}, | |
- {0x262a, 0x262a}, | |
- {0x262e, 0x262f}, | |
- {0x2638, 0x263a}, | |
- {0x2648, 0x2653}, | |
- {0x2660, 0x2660}, | |
- {0x2663, 0x2663}, | |
- {0x2665, 0x2666}, | |
- {0x2668, 0x2668}, | |
- {0x267b, 0x267b}, | |
- {0x267f, 0x267f}, | |
- {0x2692, 0x2694}, | |
- {0x2696, 0x2697}, | |
- {0x2699, 0x2699}, | |
- {0x269b, 0x269c}, | |
- {0x26a0, 0x26a1}, | |
- {0x26aa, 0x26ab}, | |
- {0x26b0, 0x26b1}, | |
- {0x26bd, 0x26be}, | |
- {0x26c4, 0x26c5}, | |
- {0x26c8, 0x26c8}, | |
- {0x26ce, 0x26ce}, | |
- {0x26cf, 0x26cf}, | |
- {0x26d1, 0x26d1}, | |
- {0x26d3, 0x26d4}, | |
- {0x26e9, 0x26ea}, | |
- {0x26f0, 0x26f5}, | |
- {0x26f7, 0x26fa}, | |
- {0x26fd, 0x26fd}, | |
- {0x2702, 0x2702}, | |
- {0x2705, 0x2705}, | |
- {0x2708, 0x2709}, | |
- {0x270a, 0x270b}, | |
- {0x270c, 0x270d}, | |
- {0x270f, 0x270f}, | |
- {0x2712, 0x2712}, | |
- {0x2714, 0x2714}, | |
- {0x2716, 0x2716}, | |
- {0x271d, 0x271d}, | |
- {0x2721, 0x2721}, | |
- {0x2728, 0x2728}, | |
- {0x2733, 0x2734}, | |
- {0x2744, 0x2744}, | |
- {0x2747, 0x2747}, | |
- {0x274c, 0x274c}, | |
- {0x274e, 0x274e}, | |
- {0x2753, 0x2755}, | |
- {0x2757, 0x2757}, | |
- {0x2763, 0x2764}, | |
- {0x2795, 0x2797}, | |
- {0x27a1, 0x27a1}, | |
- {0x27b0, 0x27b0}, | |
- {0x27bf, 0x27bf}, | |
- {0x2934, 0x2935}, | |
- {0x2b05, 0x2b07}, | |
- {0x2b1b, 0x2b1c}, | |
- {0x2b50, 0x2b50}, | |
- {0x2b55, 0x2b55}, | |
- {0x3030, 0x3030}, | |
- {0x303d, 0x303d}, | |
- {0x3297, 0x3297}, | |
- {0x3299, 0x3299}, | |
- {0x1f004, 0x1f004}, | |
- {0x1f0cf, 0x1f0cf}, | |
- {0x1f170, 0x1f171}, | |
- {0x1f17e, 0x1f17e}, | |
- {0x1f17f, 0x1f17f}, | |
- {0x1f18e, 0x1f18e}, | |
- {0x1f191, 0x1f19a}, | |
- {0x1f1e6, 0x1f1ff}, | |
- {0x1f201, 0x1f202}, | |
- {0x1f21a, 0x1f21a}, | |
- {0x1f22f, 0x1f22f}, | |
- {0x1f232, 0x1f23a}, | |
- {0x1f250, 0x1f251}, | |
- {0x1f300, 0x1f320}, | |
- {0x1f330, 0x1f335}, | |
- {0x1f337, 0x1f37c}, | |
- {0x1f380, 0x1f393}, | |
- {0x1f3a0, 0x1f3c4}, | |
- {0x1f3c6, 0x1f3ca}, | |
- {0x1f3e0, 0x1f3f0}, | |
- {0x1f400, 0x1f43e}, | |
- {0x1f440, 0x1f440}, | |
- {0x1f442, 0x1f4f7}, | |
- {0x1f4f9, 0x1f4fc}, | |
- {0x1f500, 0x1f53d}, | |
- {0x1f550, 0x1f567}, | |
- {0x1f5fb, 0x1f5ff}, | |
- {0x1f600, 0x1f600}, | |
- {0x1f601, 0x1f610}, | |
- {0x1f611, 0x1f611}, | |
- {0x1f612, 0x1f614}, | |
- {0x1f615, 0x1f615}, | |
- {0x1f616, 0x1f616}, | |
- {0x1f617, 0x1f617}, | |
- {0x1f618, 0x1f618}, | |
- {0x1f619, 0x1f619}, | |
- {0x1f61a, 0x1f61a}, | |
- {0x1f61b, 0x1f61b}, | |
- {0x1f61c, 0x1f61e}, | |
- {0x1f61f, 0x1f61f}, | |
- {0x1f620, 0x1f625}, | |
- {0x1f626, 0x1f627}, | |
- {0x1f628, 0x1f62b}, | |
- {0x1f62c, 0x1f62c}, | |
- {0x1f62d, 0x1f62d}, | |
- {0x1f62e, 0x1f62f}, | |
- {0x1f630, 0x1f633}, | |
- {0x1f634, 0x1f634}, | |
- {0x1f635, 0x1f640}, | |
- {0x1f645, 0x1f64f}, | |
- {0x1f680, 0x1f6c5} | |
- }; | |
- | |
if (c >= 0x100) | |
{ | |
#ifdef USE_WCHAR_FUNCTIONS | |
@@ -1597,7 +1600,7 @@ utf_char2cells(int c) | |
if (intable(doublewidth, sizeof(doublewidth), c)) | |
return 2; | |
#endif | |
- if (p_emoji && intable(emoji, sizeof(emoji), c)) | |
+ if (p_emoji && intable(emoji_tab, sizeof(emoji_tab), c)) | |
return 2; | |
} | |
@@ -2701,6 +2704,10 @@ utf_class(int c) | |
return (int)classes[mid].class; | |
} | |
+ /* emoji */ | |
+ if (p_emoji && intable(emoji_tab, sizeof(emoji_tab), c)) | |
+ return 3; | |
+ | |
/* most other characters are "word" characters */ | |
return 2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment