From 347cc668378482a66e2abddaf42afad0601d8b77 Mon Sep 17 00:00:00 2001 From: Matt Wozniski Date: Sun, 12 Jul 2009 17:15:48 -0400 Subject: [PATCH] Provide a command to re-run approximation manually --- doc/CSApprox.txt | 20 ++++++++++++++++++++ plugin/CSApprox.vim | 19 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/doc/CSApprox.txt b/doc/CSApprox.txt index d91bb62..c151593 100644 --- a/doc/CSApprox.txt +++ b/doc/CSApprox.txt @@ -80,6 +80,18 @@ NOTE: Although :CSApproxSnapshot can be used in both GVim and terminal Vim, running in a terminal than running in the GUI, and there's no way for terminal Vim to figure out what color would have been used in GVim. + *:CSApprox* +A command is also provided to run the approximation manually. This might be +useful if some colors were set outside of a colorscheme file, for instance. +By default, it will not change any colors unless no highlight group is set to +a color above 15, which is CSApprox's normal behavior. This probably isn't +useful in most use cases, though. On the other hand, if a ! is provided, +CSApprox will skip that test and update the cterm value for every highlight +group from the corresponding gui color. Syntax: +> + :CSApprox[!] +< + ============================================================================== 2. Requirements *csapprox-requirements* @@ -428,6 +440,14 @@ Transparently adapting schemes is slow. NOTE: As of CSApprox 3.50, the overhead is down to about 0.10 seconds on my test machine. +It isn't possible to approximate only a particular set of groups. + + Unfortunately, the :CSApprox command will always update all groups, even if + only a small set of groups has changed. A future improvement would be to + provide a function called, say, CSApprox(), that takes an optional list of + highlight groups (default: all) and only does approximation for those + groups. + ============================================================================== 6. Appendix - Terminals and Palettes *csapprox-terminal-list* diff --git a/plugin/CSApprox.vim b/plugin/CSApprox.vim index 96f2a20..2022412 100644 --- a/plugin/CSApprox.vim +++ b/plugin/CSApprox.vim @@ -590,8 +590,15 @@ endfunction " main function. This allows us to default to a message whenever any error, " even a recoverable one, occurs, meaning the user quickly finds out when " something's wrong, but makes it very easy for the user to make us silent. -function! s:CSApprox() +function! s:CSApprox(...) try + if a:0 == 1 && a:1 + if !exists('s:inhibit_hicolor_test') + let s:inhibit_hicolor_test = 0 + endif + let s:inhibit_hicolor_test += 1 + endif + let savelz = &lz set lz @@ -641,6 +648,13 @@ function! s:CSApprox() endif let &lz = savelz + + if a:0 == 1 && a:1 + let s:inhibit_hicolor_test -= 1 + if s:inhibit_hicolor_test == 0 + unlet s:inhibit_hicolor_test + endif + endif endtry endfunction @@ -860,6 +874,9 @@ endfunction command! -bang -nargs=1 -complete=file -bar CSApproxSnapshot \ call s:CSApproxSnapshot(, strlen("")) +" {>2} Manual updates +command -bang -bar CSApprox call s:CSApprox(strlen("")) + " {>1} Hooks " {>2} Autocmds