mirror of
https://github.com/itchyny/lightline.vim.git
synced 2025-11-12 05:23:51 -05:00
refactor papercolor colorscheme
This commit is contained in:
@@ -2,208 +2,207 @@
|
||||
" Filename: autoload/lightline/colorscheme/PaperColor.vim
|
||||
" Author: TKNGUE
|
||||
" License: MIT License
|
||||
" Last Change: 2015-07-27 06:01
|
||||
" Last Change: 2015/07/28 07:12:52.
|
||||
" =============================================================================
|
||||
function! s:grey_number(x)
|
||||
if &t_Co == 88
|
||||
if a:x < 23
|
||||
return 0
|
||||
elseif a:x < 69
|
||||
return 1
|
||||
elseif a:x < 103
|
||||
return 2
|
||||
elseif a:x < 127
|
||||
return 3
|
||||
elseif a:x < 150
|
||||
return 4
|
||||
elseif a:x < 173
|
||||
return 5
|
||||
elseif a:x < 196
|
||||
return 6
|
||||
elseif a:x < 219
|
||||
return 7
|
||||
elseif a:x < 243
|
||||
return 8
|
||||
else
|
||||
return 9
|
||||
endif
|
||||
|
||||
function! s:grey_number(x)
|
||||
if &t_Co == 88
|
||||
if a:x < 23
|
||||
return 0
|
||||
elseif a:x < 69
|
||||
return 1
|
||||
elseif a:x < 103
|
||||
return 2
|
||||
elseif a:x < 127
|
||||
return 3
|
||||
elseif a:x < 150
|
||||
return 4
|
||||
elseif a:x < 173
|
||||
return 5
|
||||
elseif a:x < 196
|
||||
return 6
|
||||
elseif a:x < 219
|
||||
return 7
|
||||
elseif a:x < 243
|
||||
return 8
|
||||
else
|
||||
if a:x < 14
|
||||
return 0
|
||||
return 9
|
||||
endif
|
||||
else
|
||||
if a:x < 14
|
||||
return 0
|
||||
else
|
||||
let n = (a:x - 8) / 10
|
||||
let m = (a:x - 8) % 10
|
||||
if m < 5
|
||||
return n
|
||||
else
|
||||
let n = (a:x - 8) / 10
|
||||
let m = (a:x - 8) % 10
|
||||
if m < 5
|
||||
return n
|
||||
else
|
||||
return n + 1
|
||||
endif
|
||||
return n + 1
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns the actual grey level represented by the grey index
|
||||
function! s:grey_level(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 0
|
||||
elseif a:n == 1
|
||||
return 46
|
||||
elseif a:n == 2
|
||||
return 92
|
||||
elseif a:n == 3
|
||||
return 115
|
||||
elseif a:n == 4
|
||||
return 139
|
||||
elseif a:n == 5
|
||||
return 162
|
||||
elseif a:n == 6
|
||||
return 185
|
||||
elseif a:n == 7
|
||||
return 208
|
||||
elseif a:n == 8
|
||||
return 231
|
||||
else
|
||||
return 255
|
||||
endif
|
||||
" Returns the actual grey level represented by the grey index
|
||||
function! s:grey_level(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 0
|
||||
elseif a:n == 1
|
||||
return 46
|
||||
elseif a:n == 2
|
||||
return 92
|
||||
elseif a:n == 3
|
||||
return 115
|
||||
elseif a:n == 4
|
||||
return 139
|
||||
elseif a:n == 5
|
||||
return 162
|
||||
elseif a:n == 6
|
||||
return 185
|
||||
elseif a:n == 7
|
||||
return 208
|
||||
elseif a:n == 8
|
||||
return 231
|
||||
else
|
||||
if a:n == 0
|
||||
return 0
|
||||
return 255
|
||||
endif
|
||||
else
|
||||
if a:n == 0
|
||||
return 0
|
||||
else
|
||||
return 8 + (a:n * 10)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns the palette index for the given grey index
|
||||
function! s:grey_color(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 16
|
||||
elseif a:n == 9
|
||||
return 79
|
||||
else
|
||||
return 79 + a:n
|
||||
endif
|
||||
else
|
||||
if a:n == 0
|
||||
return 16
|
||||
elseif a:n == 25
|
||||
return 231
|
||||
else
|
||||
return 231 + a:n
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns an approximate color index for the given color level
|
||||
function! s:rgb_number(x)
|
||||
if &t_Co == 88
|
||||
if a:x < 69
|
||||
return 0
|
||||
elseif a:x < 172
|
||||
return 1
|
||||
elseif a:x < 230
|
||||
return 2
|
||||
else
|
||||
return 3
|
||||
endif
|
||||
else
|
||||
if a:x < 75
|
||||
return 0
|
||||
else
|
||||
let n = (a:x - 55) / 40
|
||||
let m = (a:x - 55) % 40
|
||||
if m < 20
|
||||
return n
|
||||
else
|
||||
return 8 + (a:n * 10)
|
||||
return n + 1
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns the palette index for the given grey index
|
||||
function! s:grey_color(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 16
|
||||
elseif a:n == 9
|
||||
return 79
|
||||
else
|
||||
return 79 + a:n
|
||||
endif
|
||||
" Returns the actual color level for the given color index
|
||||
function! s:rgb_level(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 0
|
||||
elseif a:n == 1
|
||||
return 139
|
||||
elseif a:n == 2
|
||||
return 205
|
||||
else
|
||||
if a:n == 0
|
||||
return 16
|
||||
elseif a:n == 25
|
||||
return 231
|
||||
else
|
||||
return 231 + a:n
|
||||
endif
|
||||
return 255
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns an approximate color index for the given color level
|
||||
function! s:rgb_number(x)
|
||||
if &t_Co == 88
|
||||
if a:x < 69
|
||||
return 0
|
||||
elseif a:x < 172
|
||||
return 1
|
||||
elseif a:x < 230
|
||||
return 2
|
||||
else
|
||||
return 3
|
||||
endif
|
||||
else
|
||||
if a:n == 0
|
||||
return 0
|
||||
else
|
||||
if a:x < 75
|
||||
return 0
|
||||
else
|
||||
let n = (a:x - 55) / 40
|
||||
let m = (a:x - 55) % 40
|
||||
if m < 20
|
||||
return n
|
||||
else
|
||||
return n + 1
|
||||
endif
|
||||
endif
|
||||
return 55 + (a:n * 40)
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns the actual color level for the given color index
|
||||
function! s:rgb_level(n)
|
||||
if &t_Co == 88
|
||||
if a:n == 0
|
||||
return 0
|
||||
elseif a:n == 1
|
||||
return 139
|
||||
elseif a:n == 2
|
||||
return 205
|
||||
else
|
||||
return 255
|
||||
endif
|
||||
" Returns the palette index for the given R/G/B color indices
|
||||
function! s:rgb_color(x, y, z)
|
||||
if &t_Co == 88
|
||||
return 16 + (a:x * 16) + (a:y * 4) + a:z
|
||||
else
|
||||
return 16 + (a:x * 36) + (a:y * 6) + a:z
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns the palette index to approximate the given R/G/B color levels
|
||||
function! s:color(r, g, b)
|
||||
" Get the closest grey
|
||||
let gx = s:grey_number(a:r)
|
||||
let gy = s:grey_number(a:g)
|
||||
let gz = s:grey_number(a:b)
|
||||
|
||||
" Get the closest color
|
||||
let x = s:rgb_number(a:r)
|
||||
let y = s:rgb_number(a:g)
|
||||
let z = s:rgb_number(a:b)
|
||||
|
||||
if gx == gy && gy == gz
|
||||
" There are two possibilities
|
||||
let dgr = s:grey_level(gx) - a:r
|
||||
let dgg = s:grey_level(gy) - a:g
|
||||
let dgb = s:grey_level(gz) - a:b
|
||||
let dgrey = (dgr * dgr) + (dgg * dgg) + (dgb * dgb)
|
||||
let dr = s:rgb_level(gx) - a:r
|
||||
let dg = s:rgb_level(gy) - a:g
|
||||
let db = s:rgb_level(gz) - a:b
|
||||
let drgb = (dr * dr) + (dg * dg) + (db * db)
|
||||
if dgrey < drgb
|
||||
" Use the grey
|
||||
return s:grey_color(gx)
|
||||
else
|
||||
if a:n == 0
|
||||
return 0
|
||||
else
|
||||
return 55 + (a:n * 40)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns the palette index for the given R/G/B color indices
|
||||
function! s:rgb_color(x, y, z)
|
||||
if &t_Co == 88
|
||||
return 16 + (a:x * 16) + (a:y * 4) + a:z
|
||||
else
|
||||
return 16 + (a:x * 36) + (a:y * 6) + a:z
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns the palette index to approximate the given R/G/B color levels
|
||||
function! s:color(r, g, b)
|
||||
" Get the closest grey
|
||||
let gx = s:grey_number(a:r)
|
||||
let gy = s:grey_number(a:g)
|
||||
let gz = s:grey_number(a:b)
|
||||
|
||||
" Get the closest color
|
||||
let x = s:rgb_number(a:r)
|
||||
let y = s:rgb_number(a:g)
|
||||
let z = s:rgb_number(a:b)
|
||||
|
||||
if gx == gy && gy == gz
|
||||
" There are two possibilities
|
||||
let dgr = s:grey_level(gx) - a:r
|
||||
let dgg = s:grey_level(gy) - a:g
|
||||
let dgb = s:grey_level(gz) - a:b
|
||||
let dgrey = (dgr * dgr) + (dgg * dgg) + (dgb * dgb)
|
||||
let dr = s:rgb_level(gx) - a:r
|
||||
let dg = s:rgb_level(gy) - a:g
|
||||
let db = s:rgb_level(gz) - a:b
|
||||
let drgb = (dr * dr) + (dg * dg) + (db * db)
|
||||
if dgrey < drgb
|
||||
" Use the grey
|
||||
return s:grey_color(gx)
|
||||
else
|
||||
" Use the color
|
||||
return s:rgb_color(x, y, z)
|
||||
endif
|
||||
else
|
||||
" Only one possibility
|
||||
" Use the color
|
||||
return s:rgb_color(x, y, z)
|
||||
endif
|
||||
endfunction
|
||||
else
|
||||
" Only one possibility
|
||||
return s:rgb_color(x, y, z)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns the palette index to approximate the '#rrggbb' hex string
|
||||
function! s:rgb(rgb)
|
||||
let r = ("0x" . strpart(a:rgb, 1, 2)) + 0
|
||||
let g = ("0x" . strpart(a:rgb, 3, 2)) + 0
|
||||
let b = ("0x" . strpart(a:rgb, 5, 2)) + 0
|
||||
" Returns the palette index to approximate the '#rrggbb' hex string
|
||||
function! s:rgb(rgb)
|
||||
let r = ("0x" . strpart(a:rgb, 1, 2)) + 0
|
||||
let g = ("0x" . strpart(a:rgb, 3, 2)) + 0
|
||||
let b = ("0x" . strpart(a:rgb, 5, 2)) + 0
|
||||
return s:color(r, g, b)
|
||||
endfunction
|
||||
|
||||
return s:color(r, g, b)
|
||||
endfunction
|
||||
function! lightline#colorscheme#PaperColor#color(color)
|
||||
return [a:color, s:rgb(a:color)]
|
||||
endfunction
|
||||
|
||||
function! lightline#colorscheme#PaperColor#X(color)
|
||||
return [a:color, s:rgb(a:color)]
|
||||
endfunction
|
||||
|
||||
if &background ==# 'light'
|
||||
let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_light#palette
|
||||
else
|
||||
let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_dark#palette
|
||||
endif
|
||||
|
||||
|
||||
@@ -5,41 +5,41 @@
|
||||
" Last Change: 2015-07-27 06:01
|
||||
" =============================================================================
|
||||
|
||||
let s:red = lightline#colorscheme#PaperColor#color_set("#df0000")
|
||||
let s:green = lightline#colorscheme#PaperColor#color_set("#008700")
|
||||
let s:blue = lightline#colorscheme#PaperColor#color_set("#00afaf")
|
||||
let s:red = lightline#colorscheme#PaperColor#color("#df0000")
|
||||
let s:green = lightline#colorscheme#PaperColor#color("#008700")
|
||||
let s:blue = lightline#colorscheme#PaperColor#color("#00afaf")
|
||||
|
||||
let s:pink = lightline#colorscheme#PaperColor#color_set("#afdf00")
|
||||
let s:olive = lightline#colorscheme#PaperColor#color_set("#dfaf5f")
|
||||
let s:navy = lightline#colorscheme#PaperColor#color_set("#df875f")
|
||||
let s:pink = lightline#colorscheme#PaperColor#color("#afdf00")
|
||||
let s:olive = lightline#colorscheme#PaperColor#color("#dfaf5f")
|
||||
let s:navy = lightline#colorscheme#PaperColor#color("#df875f")
|
||||
|
||||
let s:orange = lightline#colorscheme#PaperColor#color_set("#d75f00")
|
||||
let s:purple = lightline#colorscheme#PaperColor#color_set("#8959a8")
|
||||
let s:aqua = lightline#colorscheme#PaperColor#color_set("#3e999f")
|
||||
let s:orange = lightline#colorscheme#PaperColor#color("#d75f00")
|
||||
let s:purple = lightline#colorscheme#PaperColor#color("#8959a8")
|
||||
let s:aqua = lightline#colorscheme#PaperColor#color("#3e999f")
|
||||
|
||||
" Basics:
|
||||
let s:foreground = lightline#colorscheme#PaperColor#color_set("#d0d0d0")
|
||||
let s:background = lightline#colorscheme#PaperColor#color_set("#444444")
|
||||
let s:window = lightline#colorscheme#PaperColor#color_set("#efefef")
|
||||
let s:status = lightline#colorscheme#PaperColor#color_set("#c6c6c6")
|
||||
let s:error = lightline#colorscheme#PaperColor#color_set("#5f0000")
|
||||
let s:foreground = lightline#colorscheme#PaperColor#color("#d0d0d0")
|
||||
let s:background = lightline#colorscheme#PaperColor#color("#444444")
|
||||
let s:window = lightline#colorscheme#PaperColor#color("#efefef")
|
||||
let s:status = lightline#colorscheme#PaperColor#color("#c6c6c6")
|
||||
let s:error = lightline#colorscheme#PaperColor#color("#5f0000")
|
||||
|
||||
" Tabline:
|
||||
let s:tabline_bg = lightline#colorscheme#PaperColor#color_set("#3a3a3a")
|
||||
let s:tabline_active_fg = lightline#colorscheme#PaperColor#color_set("#1c1c1c")
|
||||
let s:tabline_active_bg = lightline#colorscheme#PaperColor#color_set("#00afaf")
|
||||
let s:tabline_inactive_fg = lightline#colorscheme#PaperColor#color_set("#c6c6c6")
|
||||
let s:tabline_inactive_bg = lightline#colorscheme#PaperColor#color_set("#585858")
|
||||
let s:tabline_bg = lightline#colorscheme#PaperColor#color("#3a3a3a")
|
||||
let s:tabline_active_fg = lightline#colorscheme#PaperColor#color("#1c1c1c")
|
||||
let s:tabline_active_bg = lightline#colorscheme#PaperColor#color("#00afaf")
|
||||
let s:tabline_inactive_fg = lightline#colorscheme#PaperColor#color("#c6c6c6")
|
||||
let s:tabline_inactive_bg = lightline#colorscheme#PaperColor#color("#585858")
|
||||
|
||||
" Statusline:
|
||||
let s:statusline_active_fg = lightline#colorscheme#PaperColor#color_set("#1c1c1c")
|
||||
let s:statusline_active_bg = lightline#colorscheme#PaperColor#color_set("#5f8787")
|
||||
let s:statusline_inactive_fg = lightline#colorscheme#PaperColor#color_set("#c6c6c6")
|
||||
let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#color_set("#444444")
|
||||
let s:statusline_active_fg = lightline#colorscheme#PaperColor#color("#1c1c1c")
|
||||
let s:statusline_active_bg = lightline#colorscheme#PaperColor#color("#5f8787")
|
||||
let s:statusline_inactive_fg = lightline#colorscheme#PaperColor#color("#c6c6c6")
|
||||
let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#color("#444444")
|
||||
|
||||
" Visual:
|
||||
let s:visual_fg = lightline#colorscheme#PaperColor#color_set("#000000")
|
||||
let s:visual_bg = lightline#colorscheme#PaperColor#color_set("#8787af")
|
||||
let s:visual_fg = lightline#colorscheme#PaperColor#color("#000000")
|
||||
let s:visual_bg = lightline#colorscheme#PaperColor#color("#8787af")
|
||||
|
||||
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
|
||||
let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ]
|
||||
|
||||
@@ -2,25 +2,26 @@
|
||||
" Filename: autoload/lightline/colorscheme/PaperColor_light.vim
|
||||
" Author: TKNGUE
|
||||
" License: MIT License
|
||||
" Last Change: 2015-07-27 06:010
|
||||
" Last Change: 2015/07/28 07:12:26.
|
||||
" =============================================================================
|
||||
let s:red = lightline#colorscheme#PaperColor#color_set("#df0000") "Include/Exception
|
||||
let s:green = lightline#colorscheme#PaperColor#color_set("#008700") "Boolean/Special
|
||||
let s:blue = lightline#colorscheme#PaperColor#color_set("#4271ae") "Keyword
|
||||
let s:pink = lightline#colorscheme#PaperColor#color_set("#d7005f") "Type
|
||||
let s:olive = lightline#colorscheme#PaperColor#color_set("#718c00") "String
|
||||
let s:navy = lightline#colorscheme#PaperColor#color_set("#005f87") "StorageClass
|
||||
let s:orange = lightline#colorscheme#PaperColor#color_set("#d75f00") "Number
|
||||
let s:purple = lightline#colorscheme#PaperColor#color_set("#8959a8") "Repeat/Conditional
|
||||
let s:aqua = lightline#colorscheme#PaperColor#color_set("#3e999f") "Operator/Delimiter
|
||||
|
||||
let s:red = lightline#colorscheme#PaperColor#color("#df0000") "Include/Exception
|
||||
let s:green = lightline#colorscheme#PaperColor#color("#008700") "Boolean/Special
|
||||
let s:blue = lightline#colorscheme#PaperColor#color("#4271ae") "Keyword
|
||||
let s:pink = lightline#colorscheme#PaperColor#color("#d7005f") "Type
|
||||
let s:olive = lightline#colorscheme#PaperColor#color("#718c00") "String
|
||||
let s:navy = lightline#colorscheme#PaperColor#color("#005f87") "StorageClass
|
||||
let s:orange = lightline#colorscheme#PaperColor#color("#d75f00") "Number
|
||||
let s:purple = lightline#colorscheme#PaperColor#color("#8959a8") "Repeat/Conditional
|
||||
let s:aqua = lightline#colorscheme#PaperColor#color("#3e999f") "Operator/Delimiter
|
||||
|
||||
|
||||
" Basics:
|
||||
let s:foreground = lightline#colorscheme#PaperColor#color_set("#4d4d4c")
|
||||
let s:background = lightline#colorscheme#PaperColor#color_set("#F5F5F5")
|
||||
let s:window = lightline#colorscheme#PaperColor#color_set("#efefef")
|
||||
let s:foreground = lightline#colorscheme#PaperColor#color("#4d4d4c")
|
||||
let s:background = lightline#colorscheme#PaperColor#color("#F5F5F5")
|
||||
let s:window = lightline#colorscheme#PaperColor#color("#efefef")
|
||||
let s:status = s:aqua
|
||||
let s:error = lightline#colorscheme#PaperColor#color_set("#ffafdf")
|
||||
let s:error = lightline#colorscheme#PaperColor#color("#ffafdf")
|
||||
|
||||
" Tabline:
|
||||
let s:tabline_bg = s:navy
|
||||
@@ -33,7 +34,7 @@ let s:tabline_inactive_bg = s:aqua
|
||||
let s:statusline_active_fg = s:window
|
||||
let s:statusline_active_bg = s:navy
|
||||
let s:statusline_inactive_fg = s:foreground
|
||||
let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#color_set("#dadada")
|
||||
let s:statusline_inactive_bg = lightline#colorscheme#PaperColor#color("#dadada")
|
||||
|
||||
" Visual:
|
||||
let s:visual_fg = s:background
|
||||
|
||||
Reference in New Issue
Block a user