Skip to content

Commit

Permalink
Merge commit 'ad7cf1a40e16f5698c04a6e31f16a854edac026c'
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Wozniski committed Dec 22, 2009
2 parents bd77920 + ad7cf1a commit 7d3a90d
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions runtimes/colorchart/plugin/colorchart.vim
Expand Up @@ -304,8 +304,8 @@ function! s:SetupColorChartImpl()
call append(line('$'), '')
call append(line('$'), printf('Color %-5s%s', c . ': ', i))
call append(line('$'), '')
call append(line('$'), 'Black on color ' .c. ' White on color ' .c. '')
call append(line('$'), 'Color ' .c. ' on black Color ' .c. ' on white')
call append(line('$'), 'Black on color ' .c. ' White on color ' .c. ' Normal on color ' .c. '')
call append(line('$'), 'Color ' .c. ' on black Color ' .c. ' on white Color ' .c. ' on normal')

let skip = ' skipwhite skipempty skipnl'

Expand All @@ -321,20 +321,23 @@ function! s:SetupColorChartImpl()
exe printf('syn match colorchart%d /__/ nextgroup=colorchart%d %s', color1, color2, skip)
endwhile

for i in range(&t_Co)
exe printf('syn match colorchart%d_on_0 /\<Color %d on black\>\&.\{1,18\}/', i, i)
exe printf('syn match colorchart%d_on_15 /\<Color %d on white\>\&.\{1,18\}/', i, i)
exe printf('syn match colorchart0_on_%d /\<Black on color %d\>\&.\{1,18\}/', i, i)
exe printf('syn match colorchart15_on_%d /\<White on color %d\>\&.\{1,18\}/', i, i)
endfor

for i in range(&t_Co)
exe printf('hi colorchart%d ctermbg=%d ctermfg=%d', i, i, i)
exe printf('hi colorchart%d_on_0 ctermfg=%d ctermbg=0 ', i, i)
exe printf('hi colorchart%d_on_15 ctermfg=%d ctermbg=15', i, i)
exe printf('hi colorchart0_on_%d ctermbg=%d ctermfg=0 ', i, i)
exe printf('hi colorchart15_on_%d ctermbg=%d ctermfg=15', i, i)
endfor

syn match colorchart_color_on_0 /\<Color \d\+ on black\>\&.\{1,18\}/
syn match colorchart_color_on_15 /\<Color \d\+ on white\>\&.\{1,18\}/
syn match colorchart_color_on_256 /\<Color \d\+ on normal\>\&.\{1,19\}/
syn match colorchart0_on_color /\<Black on color \d\+\>\&.\{1,18\}/
syn match colorchart15_on_color /\<White on color \d\+\>\&.\{1,18\}/
syn match colorchart256_on_color /\<Normal on color \d\+\>\&.\{1,19\}/

exe printf('hi colorchart_color_on_0 ctermfg=%d ctermbg=0', c)
exe printf('hi colorchart_color_on_15 ctermfg=%d ctermbg=15', c)
exe printf('hi colorchart_color_on_256 ctermfg=%d ctermbg=bg', c)
exe printf('hi colorchart0_on_color ctermbg=%d ctermfg=0', c)
exe printf('hi colorchart15_on_color ctermbg=%d ctermfg=15', c)
exe printf('hi colorchart256_on_color ctermbg=%d ctermfg=fg', c)
endfunction

" Calls SetupColorChartImpl, while handling saving and restoring options and
Expand Down Expand Up @@ -376,7 +379,7 @@ function! ColorChart()
file Color\ Chart
endif

setlocal nolist buftype=nofile bufhidden=wipe noswapfile tabstop=1 iskeyword+=[,] matchpairs=
setlocal nolist buftype=nofile bufhidden=wipe noswapfile tabstop=1 iskeyword+=[,] matchpairs= nocursorline nocursorcolumn

call s:SetupColorChart()

Expand All @@ -390,6 +393,7 @@ function! ColorChart()
nnoremap <buffer> <silent> + :call <SID>ChangeChart(1)<CR>
autocmd CursorMoved,CursorMovedI <buffer> call <SID>UpdatePreview()
autocmd ColorScheme <buffer> call <SID>SetupColorChart()
endfunction

" Update the preview based on the cursor's movement, assuming that it has
Expand Down Expand Up @@ -479,9 +483,18 @@ function! s:UpdatePreview()
let text = substitute(text, 'Color \d\+:.*', info, '')
let text = substitute(text, 'on color \zs\(\d\+\&.\{1,3}\)\ze', printf('%-3s', color), 'g')
let text = substitute(text, 'Color \d\+ on \(black\|white\)\&.\{1,18}', '\=printf("%-18s", "Color " . color . " on " . submatch(1))', 'g')
let text = substitute(text, 'Color \d\+ on \(normal\)\&.\{1,19}', '\=printf("%-19s", "Color " . color . " on " . submatch(1))', 'g')

call setline(line, text)
endfor

exe printf('hi colorchart_color_on_0 ctermfg=%d ctermbg=0', color)
exe printf('hi colorchart_color_on_15 ctermfg=%d ctermbg=15', color)
exe printf('hi colorchart_color_on_256 ctermfg=%d ctermbg=bg', color)
exe printf('hi colorchart0_on_color ctermbg=%d ctermfg=0', color)
exe printf('hi colorchart15_on_color ctermbg=%d ctermfg=15', color)
exe printf('hi colorchart256_on_color ctermbg=%d ctermfg=fg', color)

setlocal nomodifiable nomodified
endfunction

Expand Down

0 comments on commit 7d3a90d

Please sign in to comment.