Finish CSApprox 1.0 release

- Update "Last Changed", version number, and changelog

- Suggest installing larger vim packages as a workaround for no +gui

- Modify the way g:CSApprox_verbose_level works; now 'verbose' is set to
  the max of that variable and &verbose

- Fix a minor bug causing a complaint that not enough colors are
  available when changing colorschemes after a :gui

- Fix some comments
This commit is contained in:
Matt Wozniski 2008-10-05 01:13:03 -04:00
parent c0bd88e741
commit 5703a98365
2 changed files with 34 additions and 28 deletions

View File

@ -8,7 +8,7 @@
\___//___//_/ |_|/ .__// .__//_/ \___//_\_\ ~ \___//___//_/ |_|/ .__// .__//_/ \___//_\_\ ~
/_/ /_/ ~ /_/ /_/ ~
For Vim version 7.0 or newer For Vim version 7.0 or newer
Last changed 12 Sep 2008 Last changed 05 Oct 2008
By Matt Wozniski By Matt Wozniski
mjw@drexel.edu mjw@drexel.edu
@ -72,9 +72,13 @@ GUI support in their "gvim" binary, and not in their "vim" binary. You can
check if GUI support is available by doing: > check if GUI support is available by doing: >
:echo has('gui') :echo has('gui')
If you are in an environment where the "vim" binary does not include GUI If that prints 0, the first thing to try would be searching for a larger vim
support, but where a "gvim" binary is available, you can probably launch Vim package provided by your distribution, like "vim-enhanced" on RedHat/CentOS
with GUI support anyway using the |-v| flag in the shell: > or "vim" or "vim-gnome" on Debian/Ubuntu.
If you are unable to obtain a "vim" binary that includes GUI support, but
have a "gvim" binary available, you can probably launch Vim with GUI support
anyway by calling gvim with the |-v| flag in the shell: >
gvim -v gvim -v
If that does not work and no package with GUI support is available, you will If that does not work and no package with GUI support is available, you will
@ -92,7 +96,7 @@ either need for 't_Co' to be set to 88 or 256 in |vimrc|, or for $TERM to be
set to something that implies high color support. Possible choices include set to something that implies high color support. Possible choices include
"xterm-256color" for 256 color support and "rxvt-unicode" for 88 color "xterm-256color" for 256 color support and "rxvt-unicode" for 88 color
support. support.
*csapprox-palettes*
Also, there are three different 256 color cube palettes available and CSApprox Also, there are three different 256 color cube palettes available and CSApprox
has no way to tell which you're using unless $TERM is set to something that is has no way to tell which you're using unless $TERM is set to something that is
specific to the terminal, like "konsole" or "Eterm". Because of this, the specific to the terminal, like "konsole" or "Eterm". Because of this, the
@ -121,12 +125,13 @@ g:CSApprox_loaded *g:CSApprox_loaded*
If set in your |vimrc|, CSApprox is not loaded. If set in your |vimrc|, CSApprox is not loaded.
g:CSApprox_verbose_level *g:CSApprox_verbose_level* g:CSApprox_verbose_level *g:CSApprox_verbose_level*
While running, CSApprox sets 'verbose' to this value (default 1). This When CSApprox is run, the 'verbose' option will be temporarily raised to
allows CSApprox to default to warning whenever something might be wrong, the value held in this variable unless it is already greater. The default
but allows the user to disable this behavior if he wants. The most value is 1, which allows CSApprox to default to warning whenever something
important messages will be shown at verbosity level 1, some less important is wrong, even if it is recoverable, but allows the user to quiet us if he
ones will be shown at verbosity level 2. Internal errors and wants by changing this variable to 0. The most important messages will be
configuration errors are shown regardless of verbosity level. shown at verbosity level 1; some less important ones will be shown at
higher verbosity levels.
g:CSApprox_eterm *g:CSApprox_eterm* g:CSApprox_eterm *g:CSApprox_eterm*
If set, CSApprox will use the Eterm palette when 'term' is "xterm" or If set, CSApprox will use the Eterm palette when 'term' is "xterm" or
@ -342,6 +347,8 @@ kterm (as of version 6.2.0)
============================================================================== ==============================================================================
7. Changelog *csapprox-changelog* 7. Changelog *csapprox-changelog*
1.00 04 Oct 2008 First public release
0.90 14 Sep 2008 Initial beta release 0.90 14 Sep 2008 Initial beta release
============================================================================== ==============================================================================

View File

@ -1,7 +1,7 @@
" CSApprox: Approximate gvim colorschemes to suitable terminal colors " CSApprox: Make gvim-only colorschemes work transparently in terminal vim
" Maintainer: Matthew Wozniski (mjw@drexel.edu) " Maintainer: Matthew Wozniski (mjw@drexel.edu)
" Date: Sun, 14 Sep 2008 12:43:33 -0400 " Date: Sun, 05 Oct 2008 00:26:22 -0400
" Version: 0.90 " Version: 1.00
" History: :help csapprox-changelog " History: :help csapprox-changelog
" Whenever you change colorschemes using the :colorscheme command, this script " Whenever you change colorschemes using the :colorscheme command, this script
@ -563,15 +563,14 @@ endfunction
" {>2} Main function " {>2} Main function
" Wrapper around the actual implementation to make it easier to ensure that " Wrapper around the actual implementation to make it easier to ensure that
" all temporary settings are restored by the time we return, whether or not " all temporary settings are restored by the time we return, whether or not
" something was thrown. Additionally, sets the 'verbose' option to " something was thrown. Additionally, sets the 'verbose' option to the max of
" g:CSApprox_verbose_level (default 1) for the duration of the main function. " g:CSApprox_verbose_level (default 1) and &verbose for the duration of the
" This allows us to default to a message whenever any error, even " main function. This allows us to default to a message whenever any error,
" a recoverable one, occurs, meaning the user quickly finds out when " 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. " something's wrong, but makes it very easy for the user to make us silent.
function! s:CSApprox() function! s:CSApprox()
try try
let savelz = &lz let savelz = &lz
let savevbs = &vbs
set lz set lz
@ -596,9 +595,9 @@ function! s:CSApprox()
if !exists("g:CSApprox_verbose_level") if !exists("g:CSApprox_verbose_level")
let g:CSApprox_verbose_level = 1 let g:CSApprox_verbose_level = 1
endif endif
sil! let &verbose=g:CSApprox_verbose_level
call s:CSApproxImpl() " Set 'verbose' set to the maximum of &verbose and CSApprox_verbose_level
exe max([&vbs, g:CSApprox_verbose_level]) 'verbose call s:CSApproxImpl()'
finally finally
if exists("colors_name") if exists("colors_name")
let g:colors_name = colors_name let g:colors_name = colors_name
@ -610,7 +609,6 @@ function! s:CSApprox()
endif endif
let &lz = savelz let &lz = savelz
let &vbs = savevbs
endtry endtry
endfunction endfunction
@ -623,8 +621,9 @@ endfunction
function! s:CSApproxImpl() function! s:CSApproxImpl()
" Return if not running in an 88/256 color terminal " Return if not running in an 88/256 color terminal
if has('gui_running') || (&t_Co != 256 && &t_Co != 88) if has('gui_running') || (&t_Co != 256 && &t_Co != 88)
if &verbose && &t_Co != 256 && &t_Co != 88 if &verbose && !has('gui_running') && &t_Co != 256 && &t_Co != 88
echomsg "CSApprox skipped; terminal only has" &t_Co "colors, not 88/256" echomsg "CSApprox skipped; terminal only has" &t_Co "colors, not 88/256"
echomsg "Try checking :help csapprox-terminal for workarounds"
endif endif
return return
@ -675,15 +674,15 @@ function! s:CSApproxImpl()
endif endif
endfor endfor
" Then, set all the modified colors to approximate the gui colors. " We need to set the Normal group first so 'bg' and 'fg' work as colors
call sort(modified, "s:SortNormalFirst") call sort(modified, "s:SortNormalFirst")
" And finally set each modified color's cterm attributes to match gui " then set each modified color's cterm attributes to match gui
for hlid in modified for hlid in modified
call s:SetCtermFromGui(highlights[hlid]) call s:SetCtermFromGui(highlights[hlid])
endfor endfor
" And store the new highlights for use in the next iteration " and finally, store the new highlights for use in the next iteration
let s:highlights = highlights let s:highlights = highlights
endfunction endfunction