desert256.vim (10402B)
1 " Vim color file 2 " Maintainer: Henry So, Jr. <henryso@panix.com> 3 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. 8 " 9 " The original "desert" theme is available as part of the vim distribution or 10 " at http://hans.fugal.net/vim/colors/. 11 " 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. 17 " 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... 21 22 set background=dark 23 if version > 580 24 " no guarantees for version 5.8 and below, but this makes it stop 25 " complaining 26 hi clear 27 if exists("syntax_on") 28 syntax reset 29 endif 30 endif 31 let g:colors_name="desert256" 32 33 if has("gui_running") || &t_Co == 88 || &t_Co == 256 34 " functions {{{ 35 " returns an approximate grey index for the given grey level 36 fun <SID>grey_number(x) 37 if &t_Co == 88 38 if a:x < 23 39 return 0 40 elseif a:x < 69 41 return 1 42 elseif a:x < 103 43 return 2 44 elseif a:x < 127 45 return 3 46 elseif a:x < 150 47 return 4 48 elseif a:x < 173 49 return 5 50 elseif a:x < 196 51 return 6 52 elseif a:x < 219 53 return 7 54 elseif a:x < 243 55 return 8 56 else 57 return 9 58 endif 59 else 60 if a:x < 14 61 return 0 62 else 63 let l:n = (a:x - 8) / 10 64 let l:m = (a:x - 8) % 10 65 if l:m < 5 66 return l:n 67 else 68 return l:n + 1 69 endif 70 endif 71 endif 72 endfun 73 74 " returns the actual grey level represented by the grey index 75 fun <SID>grey_level(n) 76 if &t_Co == 88 77 if a:n == 0 78 return 0 79 elseif a:n == 1 80 return 46 81 elseif a:n == 2 82 return 92 83 elseif a:n == 3 84 return 115 85 elseif a:n == 4 86 return 139 87 elseif a:n == 5 88 return 162 89 elseif a:n == 6 90 return 185 91 elseif a:n == 7 92 return 208 93 elseif a:n == 8 94 return 231 95 else 96 return 255 97 endif 98 else 99 if a:n == 0 100 return 0 101 else 102 return 8 + (a:n * 10) 103 endif 104 endif 105 endfun 106 107 " returns the palette index for the given grey index 108 fun <SID>grey_color(n) 109 if &t_Co == 88 110 if a:n == 0 111 return 16 112 elseif a:n == 9 113 return 79 114 else 115 return 79 + a:n 116 endif 117 else 118 if a:n == 0 119 return 16 120 elseif a:n == 25 121 return 231 122 else 123 return 231 + a:n 124 endif 125 endif 126 endfun 127 128 " returns an approximate color index for the given color level 129 fun <SID>rgb_number(x) 130 if &t_Co == 88 131 if a:x < 69 132 return 0 133 elseif a:x < 172 134 return 1 135 elseif a:x < 230 136 return 2 137 else 138 return 3 139 endif 140 else 141 if a:x < 75 142 return 0 143 else 144 let l:n = (a:x - 55) / 40 145 let l:m = (a:x - 55) % 40 146 if l:m < 20 147 return l:n 148 else 149 return l:n + 1 150 endif 151 endif 152 endif 153 endfun 154 155 " returns the actual color level for the given color index 156 fun <SID>rgb_level(n) 157 if &t_Co == 88 158 if a:n == 0 159 return 0 160 elseif a:n == 1 161 return 139 162 elseif a:n == 2 163 return 205 164 else 165 return 255 166 endif 167 else 168 if a:n == 0 169 return 0 170 else 171 return 55 + (a:n * 40) 172 endif 173 endif 174 endfun 175 176 " returns the palette index for the given R/G/B color indices 177 fun <SID>rgb_color(x, y, z) 178 if &t_Co == 88 179 return 16 + (a:x * 16) + (a:y * 4) + a:z 180 else 181 return 16 + (a:x * 36) + (a:y * 6) + a:z 182 endif 183 endfun 184 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) 191 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) 196 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) 207 if l:dgrey < l:drgb 208 " use the grey 209 return <SID>grey_color(l:gx) 210 else 211 " use the color 212 return <SID>rgb_color(l:x, l:y, l:z) 213 endif 214 else 215 " only one possibility 216 return <SID>rgb_color(l:x, l:y, l:z) 217 endif 218 endfun 219 220 " returns the palette index to approximate the 'rrggbb' hex string 221 fun <SID>rgb(rgb) 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 225 226 return <SID>color(l:r, l:g, l:b) 227 endfun 228 229 " sets the highlighting for the given group 230 fun <SID>X(group, fg, bg, attr) 231 if a:fg != "" 232 exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg) 233 endif 234 if a:bg != "" 235 exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg) 236 endif 237 if a:attr != "" 238 exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr 239 endif 240 endfun 241 " }}} 242 243 call <SID>X("Normal", "cccccc", "000000", "") 244 245 " highlight groups 246 call <SID>X("Cursor", "708090", "f0e68c", "") 247 "CursorIM 248 "Directory 249 "DiffAdd 250 "DiffChange 251 "DiffDelete 252 "DiffText 253 "ErrorMsg 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", "") 258 "LineNr 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") 269 "VisualNOS 270 call <SID>X("WarningMsg", "fa8072", "", "") 271 "WildMenu 272 "Menu 273 "Scrollbar 274 "Tooltip 275 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", "", "") 284 "Underlined 285 call <SID>X("Ignore", "666666", "", "") 286 "Error 287 call <SID>X("Todo", "ff4500", "eeee00", "") 288 289 " delete functions {{{ 290 delf <SID>X 291 delf <SID>rgb 292 delf <SID>color 293 delf <SID>rgb_color 294 delf <SID>rgb_level 295 delf <SID>rgb_number 296 delf <SID>grey_color 297 delf <SID>grey_level 298 delf <SID>grey_number 299 " }}} 300 else 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 310 hi LineNr ctermfg=3 311 hi Question ctermfg=green 312 hi StatusLine cterm=bold,reverse 313 hi StatusLineNC cterm=reverse 314 hi VertSplit cterm=reverse 315 hi Title ctermfg=5 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 322 hi DiffAdd ctermbg=4 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 328 hi Special ctermfg=5 329 hi Identifier ctermfg=6 330 hi Statement ctermfg=3 331 hi PreProc ctermfg=5 332 hi Type ctermfg=2 333 hi Underlined cterm=underline ctermfg=5 334 hi Ignore ctermfg=darkgrey 335 hi Error cterm=bold ctermfg=7 ctermbg=1 336 endif 337 338 " vim: set fdl=0 fdm=marker: