summaryrefslogtreecommitdiffstats
path: root/runtime/tools
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-03-19 18:42:29 +0100
committerBram Moolenaar <Bram@vim.org>2016-03-19 18:42:29 +0100
commit3848e00e0177abdb31bc600234967863ec487233 (patch)
tree24e98aae0cf331b430e63f4dfb712dc161d2190d /runtime/tools
parentbfb96c047b79b2aab5fd57a2472871508819f3ef (diff)
patch 7.4.1604v7.4.1604
Problem: Although emoji characters are ambiguous width, best is to treat them as full width. Solution: Update the Unicode character tables. Add the 'emoji' options. (Yasuhiro Matsumoto)
Diffstat (limited to 'runtime/tools')
-rw-r--r--runtime/tools/unicode.vim27
1 files changed, 27 insertions, 0 deletions
diff --git a/runtime/tools/unicode.vim b/runtime/tools/unicode.vim
index d733fe867e..dfe9cef417 100644
--- a/runtime/tools/unicode.vim
+++ b/runtime/tools/unicode.vim
@@ -251,6 +251,27 @@ func! BuildWidthTable(pattern, tableName)
wincmd p
endfunc
+" Build the amoji width table in a new buffer.
+func! BuildEmojiTable(pattern, tableName)
+ let ranges = []
+ for line in map(filter(filter(getline(1, '$'), 'v:val=~"^[1-9]"'), 'v:val=~a:pattern'), 'matchstr(v:val,"^\\S\\+")')
+ let token = split(line, '\.\.')
+ if len(token) == 1
+ call add(token, token[0])
+ endif
+ call add(ranges, printf("\t{0x%04x, 0x%04x},", "0x".token[0], "0x".token[1]))
+ endfor
+
+ " New buffer to put the result in.
+ new
+ exe "file " . a:tableName
+ call setline(1, " static struct interval " . a:tableName . "[] =")
+ call setline(2, " {")
+ call append('$', ranges)
+ call setline('$', getline('$')[:-2]) " remove last comma
+ call setline(line('$') + 1, " };")
+ wincmd p
+endfunc
" Try to avoid hitting E36
set equalalways
@@ -290,3 +311,9 @@ call BuildWidthTable('[WF]', 'doublewidth')
" Build the ambiguous width table.
call BuildWidthTable('A', 'ambiguous')
+
+" Edit the emoji text file. Requires the netrw plugin.
+edit http://www.unicode.org/Public/emoji/3.0/emoji-data.txt
+
+" Build the emoji table. Ver. 1.0 - 6.0
+call BuildEmojiTable('; Emoji\s\+# [1-6]\.[0-9]', 'emoji')