2 " Maintainer: Henry So, Jr. <henryso@panix.com>
4 " These are the colors of the "desert" theme by Hans Fugal with a few small
5 " modifications (namely that I lowered the intensity of the normal white and
6 " made the normal and nontext backgrounds black), modified to work with 88-
7 " and 256-color xterms.
9 " The original "desert" theme is available as part of the vim distribution or
10 " at http://hans.fugal.net/vim/colors/.
12 " The real feature of this color scheme, with a wink to the "inkpot" theme, is
13 " the programmatic approximation of the gui colors to the palettes of 88- and
14 " 256- color xterms. The functions that do this (folded away, for
15 " readability) are calibrated to the colors used for Thomas E. Dickey's xterm
16 " (version 200), which is available at http://dickey.his.com/xterm/xterm.html.
18 " I struggled with trying to parse the rgb.txt file to avoid the necessity of
19 " converting color names to #rrggbb form, but decided it was just not worth
20 " the effort. Maybe someone seeing this may decide otherwise...
24 " no guarantees for version 5.8 and below, but this makes it stop
27 if exists("syntax_on")
31 let g:colors_name="desert256"
33 if has("gui_running") || &t_Co == 88 || &t_Co == 256
35 " returns an approximate grey index for the given grey level
36 fun <SID>grey_number(x)
63 let l:n = (a:x - 8) / 10
64 let l:m = (a:x - 8) % 10
74 " returns the actual grey level represented by the grey index
75 fun <SID>grey_level(n)
102 return 8 + (a:n * 10)
107 " returns the palette index for the given grey index
108 fun <SID>grey_color(n)
128 " returns an approximate color index for the given color level
129 fun <SID>rgb_number(x)
144 let l:n = (a:x - 55) / 40
145 let l:m = (a:x - 55) % 40
155 " returns the actual color level for the given color index
156 fun <SID>rgb_level(n)
171 return 55 + (a:n * 40)
176 " returns the palette index for the given R/G/B color indices
177 fun <SID>rgb_color(x, y, z)
179 return 16 + (a:x * 16) + (a:y * 4) + a:z
181 return 16 + (a:x * 36) + (a:y * 6) + a:z
185 " returns the palette index to approximate the given R/G/B color levels
186 fun <SID>color(r, g, b)
187 " get the closest grey
188 let l:gx = <SID>grey_number(a:r)
189 let l:gy = <SID>grey_number(a:g)
190 let l:gz = <SID>grey_number(a:b)
192 " get the closest color
193 let l:x = <SID>rgb_number(a:r)
194 let l:y = <SID>rgb_number(a:g)
195 let l:z = <SID>rgb_number(a:b)
197 if l:gx == l:gy && l:gy == l:gz
198 " there are two possibilities
199 let l:dgr = <SID>grey_level(l:gx) - a:r
200 let l:dgg = <SID>grey_level(l:gy) - a:g
201 let l:dgb = <SID>grey_level(l:gz) - a:b
202 let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
203 let l:dr = <SID>rgb_level(l:gx) - a:r
204 let l:dg = <SID>rgb_level(l:gy) - a:g
205 let l:db = <SID>rgb_level(l:gz) - a:b
206 let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
209 return <SID>grey_color(l:gx)
212 return <SID>rgb_color(l:x, l:y, l:z)
215 " only one possibility
216 return <SID>rgb_color(l:x, l:y, l:z)
220 " returns the palette index to approximate the 'rrggbb' hex string
222 let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
223 let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
224 let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
226 return <SID>color(l:r, l:g, l:b)
229 " sets the highlighting for the given group
230 fun <SID>X(group, fg, bg, attr)
232 exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg)
235 exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg)
238 exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
243 call <SID>X("Normal", "cccccc", "000000", "")
246 call <SID>X("Cursor", "708090", "f0e68c", "")
254 call <SID>X("VertSplit", "c2bfa5", "7f7f7f", "reverse")
255 call <SID>X("Folded", "ffd700", "4d4d4d", "")
256 call <SID>X("FoldColumn", "d2b48c", "4d4d4d", "")
257 call <SID>X("IncSearch", "708090", "f0e68c", "")
259 call <SID>X("ModeMsg", "daa520", "", "")
260 call <SID>X("MoreMsg", "2e8b57", "", "")
261 call <SID>X("NonText", "addbe7", "000000", "bold")
262 call <SID>X("Question", "00ff7f", "", "")
263 call <SID>X("Search", "f5deb3", "cd853f", "")
264 call <SID>X("SpecialKey", "9acd32", "", "")
265 call <SID>X("StatusLine", "c2bfa5", "000000", "reverse")
266 call <SID>X("StatusLineNC", "c2bfa5", "7f7f7f", "reverse")
267 call <SID>X("Title", "cd5c5c", "", "")
268 call <SID>X("Visual", "6b8e23", "f0e68c", "reverse")
270 call <SID>X("WarningMsg", "fa8072", "", "")
276 " syntax highlighting groups
277 call <SID>X("Comment", "87ceeb", "", "")
278 call <SID>X("Constant", "ffa0a0", "", "")
279 call <SID>X("Identifier", "98fb98", "", "none")
280 call <SID>X("Statement", "f0e68c", "", "bold")
281 call <SID>X("PreProc", "cd5c5c", "", "")
282 call <SID>X("Type", "bdb76b", "", "bold")
283 call <SID>X("Special", "ffdead", "", "")
285 call <SID>X("Ignore", "666666", "", "")
287 call <SID>X("Todo", "ff4500", "eeee00", "")
289 " delete functions {{{
298 delf <SID>grey_number
301 " color terminal definitions
302 hi SpecialKey ctermfg=darkgreen
303 hi NonText cterm=bold ctermfg=darkblue
304 hi Directory ctermfg=darkcyan
305 hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1
306 hi IncSearch cterm=NONE ctermfg=yellow ctermbg=green
307 hi Search cterm=NONE ctermfg=grey ctermbg=blue
308 hi MoreMsg ctermfg=darkgreen
309 hi ModeMsg cterm=NONE ctermfg=brown
311 hi Question ctermfg=green
312 hi StatusLine cterm=bold,reverse
313 hi StatusLineNC cterm=reverse
314 hi VertSplit cterm=reverse
316 hi Visual cterm=reverse
317 hi VisualNOS cterm=bold,underline
318 hi WarningMsg ctermfg=1
319 hi WildMenu ctermfg=0 ctermbg=3
320 hi Folded ctermfg=darkgrey ctermbg=NONE
321 hi FoldColumn ctermfg=darkgrey ctermbg=NONE
323 hi DiffChange ctermbg=5
324 hi DiffDelete cterm=bold ctermfg=4 ctermbg=6
325 hi DiffText cterm=bold ctermbg=1
326 hi Comment ctermfg=darkcyan
327 hi Constant ctermfg=brown
329 hi Identifier ctermfg=6
330 hi Statement ctermfg=3
333 hi Underlined cterm=underline ctermfg=5
334 hi Ignore ctermfg=darkgrey
335 hi Error cterm=bold ctermfg=7 ctermbg=1
338 " vim: set fdl=0 fdm=marker: