Fix error message (#4)

This commit is contained in:
Junegunn Choi
2014-07-08 12:09:11 +09:00
parent f6ee73b43f
commit 5c164c916a

View File

@@ -30,11 +30,18 @@ let s:cpo_save = &cpo
set cpo&vim
let s:default_coeff = 0.5
let s:unsupported =
\ 'Unsupported color scheme. g:limelight_conceal_' .
\ (has('gui_running') ? 'gui' : 'cterm') . 'fg required.'
let s:invalid_coefficient = 'Invalid coefficient. Expected: 0.0 ~ 1.0'
function! s:unsupported()
let var = 'g:limelight_conceal_'.(has('gui_running') ? 'gui' : 'cterm').'fg'
if exists(var)
return 'Cannot calculate background color.'
else
return 'Unsupported color scheme. '.var.' fg required.'
endif
endfunction
function! s:limelight()
if !exists('w:limelight_prev')
let w:limelight_prev = [0, 0, 0, 0]
@@ -83,7 +90,7 @@ let s:gray_converter = {
function! s:gray_contiguous(col)
let val = get(s:gray_converter, a:col, a:col)
if val < 231 || val > 256
throw s:unsupported
throw s:unsupported()
endif
return val
endfunction
@@ -110,7 +117,7 @@ function! s:dim(coeff)
if a:coeff < 0 && exists('g:limelight_conceal_guifg')
let dim = g:limelight_conceal_guifg
elseif empty(fg) || empty(bg)
throw s:unsupported
throw s:unsupported()
else
let coeff = s:coeff(a:coeff)
let fg_rgb = s:hex2rgb(fg)
@@ -125,8 +132,8 @@ function! s:dim(coeff)
elseif &t_Co == 256
if a:coeff < 0 && exists('g:limelight_conceal_ctermfg')
let dim = g:limelight_conceal_ctermfg
elseif fg < -1 || bg < -1
throw s:unsupported
elseif fg <= -1 || bg <= -1
throw s:unsupported()
else
let coeff = s:coeff(a:coeff)
let fg = s:gray_contiguous(fg)