Fortune: handle multibyte characters

This commit is contained in:
Marco Hinz 2017-01-11 12:57:33 +01:00
parent 89bf0a5c24
commit f3044c7f52
No known key found for this signature in database
GPG key ID: 1C980A1B657B4A4F
2 changed files with 3 additions and 3 deletions

View file

@ -126,7 +126,7 @@ endfunction
" Function: s:draw_box {{{1
function! s:draw_box(lines) abort
let longest_line = max(map(copy(a:lines), 'len(v:val)'))
let longest_line = max(map(copy(a:lines), 'strwidth(v:val)'))
if &encoding == 'utf-8' && get(g:, 'startify_fortune_use_unicode')
let top_left_corner = '╭'
let top_right_corner = '╮'
@ -146,7 +146,7 @@ function! s:draw_box(lines) abort
let bottom = bottom_left_corner . repeat(top_bottom_side, longest_line + 2) . bottom_right_corner
let lines = [top]
for l in a:lines
let offset = longest_line - len(l)
let offset = longest_line - strwidth(l)
let lines += [side . ' '. l . repeat(' ', offset) .' ' . side]
endfor
let lines += [bottom]