From caa7faf6e1b86fe43daa9e68d88ba3b971a9271e Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Mon, 10 Oct 2016 14:15:38 -0400 Subject: [PATCH] added check for fortune uft-8 encoding Added check so unicode box characters are only used when the encoding of vim is set to uft-8. Otherwise, the default ascii characters are used --- autoload/startify/fortune.vim | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/autoload/startify/fortune.vim b/autoload/startify/fortune.vim index e506dbb..0063ff0 100644 --- a/autoload/startify/fortune.vim +++ b/autoload/startify/fortune.vim @@ -119,12 +119,27 @@ endfunction " Function: s:draw_box {{{1 function! s:draw_box(lines) abort let longest_line = max(map(copy(a:lines), 'len(v:val)')) - let top = '╭'. repeat('─', longest_line + 2) .'╮' - let bottom = '╰'. repeat('─', longest_line + 2) .'╯' + if &encoding == 'utf-8' + let top_left_corner = '╭' + let top_right_corner = '╮' + let bottom_left_corner = '╰' + let bottom_right_corner = '╯' + let side = '│' + let top_bottom_side = '─' + else + let top_left_corner = '*' + let top_right_corner = '*' + let bottom_left_corner = '*' + let bottom_right_corner = '*' + let side = '|' + let top_bottom_side = '-' + endif + let top = top_left_corner . repeat(top_bottom_side, longest_line + 2) . top_right_corner + 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 lines += ['│ '. l . repeat(' ', offset) .' │'] + let lines += [side . ' '. l . repeat(' ', offset) .' ' . side] endfor let lines += [bottom] return lines