mrkn256.vim 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. " Vim color file
  2. " Maintainer: Kenta Murata <mrkn@mrkn.jp>
  3. " These are the color theme designed by mrkn based on "desert256" theme
  4. " created by Henry So, Jr. This theme is designed to work with with 88-
  5. " and 256-color xterms.
  6. "
  7. " The ancestor version "desert256" theme is available at
  8. " http://www.vim.org/scripts/script.php?script_id=1243
  9. "
  10. " The real feature of this color scheme, with a wink to the "inkpot" theme, is
  11. " the programmatic approximation of the gui colors to the palettes of 88- and
  12. " 256- color xterms. The functions that do this (folded away, for
  13. " readability) are calibrated to the colors used for Thomas E. Dickey's xterm
  14. " (version 200), which is available at http://dickey.his.com/xterm/xterm.html.
  15. "
  16. " Henry had struggled with trying to parse the rgb.txt file to avoid the
  17. " necessity of converting color names to #rrggbb form, but decided it was just
  18. " not worth the effort. I thank a lot for his results.
  19. set background=dark
  20. if version > 580
  21. " no guarantees for version 5.8 and below, but this makes it stop
  22. " complaining
  23. hi clear
  24. if exists("syntax_on")
  25. syntax reset
  26. endif
  27. endif
  28. let g:colors_name="mrkn256"
  29. if has("gui_running") || &t_Co == 88 || &t_Co == 256
  30. " functions {{{
  31. " returns an approximate grey index for the given grey level
  32. function! <SID>grey_number(x)
  33. if &t_Co == 88
  34. if a:x < 23
  35. return 0
  36. elseif a:x < 69
  37. return 1
  38. elseif a:x < 103
  39. return 2
  40. elseif a:x < 127
  41. return 3
  42. elseif a:x < 150
  43. return 4
  44. elseif a:x < 173
  45. return 5
  46. elseif a:x < 196
  47. return 6
  48. elseif a:x < 219
  49. return 7
  50. elseif a:x < 243
  51. return 8
  52. else
  53. return 9
  54. endif
  55. else
  56. if a:x < 14
  57. return 0
  58. else
  59. let l:n = (a:x - 8) / 10
  60. let l:m = (a:x - 8) % 10
  61. if l:m < 5
  62. return l:n
  63. else
  64. return l:n + 1
  65. endif
  66. endif
  67. endif
  68. endfun
  69. " returns the actual grey level represented by the grey index
  70. function! <SID>grey_level(n)
  71. if &t_Co == 88
  72. if a:n == 0
  73. return 0
  74. elseif a:n == 1
  75. return 46
  76. elseif a:n == 2
  77. return 92
  78. elseif a:n == 3
  79. return 115
  80. elseif a:n == 4
  81. return 139
  82. elseif a:n == 5
  83. return 162
  84. elseif a:n == 6
  85. return 185
  86. elseif a:n == 7
  87. return 208
  88. elseif a:n == 8
  89. return 231
  90. else
  91. return 255
  92. endif
  93. else
  94. if a:n == 0
  95. return 0
  96. else
  97. return 8 + (a:n * 10)
  98. endif
  99. endif
  100. endfun
  101. " returns the palette index for the given grey index
  102. function! <SID>grey_color(n)
  103. if &t_Co == 88
  104. if a:n == 0
  105. return 16
  106. elseif a:n == 9
  107. return 79
  108. else
  109. return 79 + a:n
  110. endif
  111. else
  112. if a:n == 0
  113. return 16
  114. elseif a:n == 25
  115. return 231
  116. else
  117. return 231 + a:n
  118. endif
  119. endif
  120. endfun
  121. " returns an approximate color index for the given color level
  122. function! <SID>rgb_number(x)
  123. if &t_Co == 88
  124. if a:x < 69
  125. return 0
  126. elseif a:x < 172
  127. return 1
  128. elseif a:x < 230
  129. return 2
  130. else
  131. return 3
  132. endif
  133. else
  134. if a:x < 75
  135. return 0
  136. else
  137. let l:n = (a:x - 55) / 40
  138. let l:m = (a:x - 55) % 40
  139. if l:m < 20
  140. return l:n
  141. else
  142. return l:n + 1
  143. endif
  144. endif
  145. endif
  146. endfun
  147. " returns the actual color level for the given color index
  148. function! <SID>rgb_level(n)
  149. if &t_Co == 88
  150. if a:n == 0
  151. return 0
  152. elseif a:n == 1
  153. return 139
  154. elseif a:n == 2
  155. return 205
  156. else
  157. return 255
  158. endif
  159. else
  160. if a:n == 0
  161. return 0
  162. else
  163. return 55 + (a:n * 40)
  164. endif
  165. endif
  166. endfun
  167. " returns the palette index for the given R/G/B color indices
  168. function! <SID>rgb_color(x, y, z)
  169. if &t_Co == 88
  170. return 16 + (a:x * 16) + (a:y * 4) + a:z
  171. else
  172. return 16 + (a:x * 36) + (a:y * 6) + a:z
  173. endif
  174. endfun
  175. " returns the palette index to approximate the given R/G/B color levels
  176. function! <SID>color(r, g, b)
  177. " get the closest grey
  178. let l:gx = <SID>grey_number(a:r)
  179. let l:gy = <SID>grey_number(a:g)
  180. let l:gz = <SID>grey_number(a:b)
  181. " get the closest color
  182. let l:x = <SID>rgb_number(a:r)
  183. let l:y = <SID>rgb_number(a:g)
  184. let l:z = <SID>rgb_number(a:b)
  185. if l:gx == l:gy && l:gy == l:gz
  186. " there are two possibilities
  187. let l:dgr = <SID>grey_level(l:gx) - a:r
  188. let l:dgg = <SID>grey_level(l:gy) - a:g
  189. let l:dgb = <SID>grey_level(l:gz) - a:b
  190. let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
  191. let l:dr = <SID>rgb_level(l:gx) - a:r
  192. let l:dg = <SID>rgb_level(l:gy) - a:g
  193. let l:db = <SID>rgb_level(l:gz) - a:b
  194. let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
  195. if l:dgrey < l:drgb
  196. " use the grey
  197. return <SID>grey_color(l:gx)
  198. else
  199. " use the color
  200. return <SID>rgb_color(l:x, l:y, l:z)
  201. endif
  202. else
  203. " only one possibility
  204. return <SID>rgb_color(l:x, l:y, l:z)
  205. endif
  206. endfun
  207. " returns the palette index to approximate the 'rrggbb' hex string
  208. function! <SID>rgb(rgb)
  209. let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
  210. let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
  211. let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
  212. return <SID>color(l:r, l:g, l:b)
  213. endfun
  214. " sets the highlighting for the given group
  215. function! <SID>X(group, fg, bg, attr)
  216. if a:fg != ""
  217. exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg)
  218. endif
  219. if a:bg != ""
  220. exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg)
  221. endif
  222. if a:attr != ""
  223. exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
  224. endif
  225. endfun
  226. " }}}
  227. call <SID>X("Normal", "cccccc", "000000", "")
  228. " highlight groups
  229. call <SID>X("Cursor", "708090", "f0e68c", "")
  230. "CursorIM
  231. call <SID>X("CursorColumn", "", "333333", "none")
  232. call <SID>X("CursorLine", "", "333333", "underline")
  233. "Directory
  234. "DiffAdd
  235. "DiffChange
  236. "DiffDelete
  237. "DiffText
  238. "ErrorMsg
  239. call <SID>X("VertSplit", "666666", "000000", "none")
  240. call <SID>X("Folded", "ffd700", "4d4d4d", "")
  241. call <SID>X("FoldColumn", "d2b48c", "4d4d4d", "")
  242. call <SID>X("IncSearch", "708090", "f0e68c", "")
  243. call <SID>X("LineNr", "666666", "", "none")
  244. call <SID>X("ModeMsg", "daa520", "", "")
  245. call <SID>X("MoreMsg", "2e8b57", "", "")
  246. call <SID>X("NonText", "666699", "", "none")
  247. call <SID>X("Question", "00ff7f", "", "")
  248. call <SID>X("Search", "f5deb3", "cd853f", "")
  249. call <SID>X("SpecialKey", "666699", "", "none")
  250. call <SID>X("StatusLine", "ffffff", "666666", "none")
  251. call <SID>X("StatusLineNC", "000000", "666666", "none")
  252. call <SID>X("Title", "cd5c5c", "", "")
  253. call <SID>X("Visual", "6b8e23", "f0e68c", "reverse")
  254. "VisualNOS
  255. call <SID>X("WarningMsg", "fa8072", "", "")
  256. "WildMenu
  257. "Menu
  258. "Scrollbar
  259. "Tooltip
  260. call <SID>X("Pmenu", "cccccc", "333333", "none")
  261. call <SID>X("PmenuSel", "663333", "cccccc", "bold")
  262. " call <SID>X("PmenuSbar", "", "", "")
  263. " call <SID>X("PmenuThumb", "", "", "")
  264. " syntax highlighting groups
  265. call <SID>X("Comment", "87ceeb", "", "")
  266. call <SID>X("Constant", "ffcc66", "", "")
  267. call <SID>X("Identifier", "99ff00", "", "none")
  268. call <SID>X("Statement", "6699ff", "", "none")
  269. call <SID>X("PreProc", "ff6666", "", "")
  270. call <SID>X("Type", "ffcc66", "", "none")
  271. call <SID>X("Special", "ffdead", "", "")
  272. "Underlined
  273. call <SID>X("Ignore", "666666", "", "")
  274. "Error
  275. call <SID>X("Todo", "ff4500", "eeee00", "")
  276. " delete functions {{{
  277. delf <SID>X
  278. delf <SID>rgb
  279. delf <SID>color
  280. delf <SID>rgb_color
  281. delf <SID>rgb_level
  282. delf <SID>rgb_number
  283. delf <SID>grey_color
  284. delf <SID>grey_level
  285. delf <SID>grey_number
  286. " }}}
  287. else
  288. " color terminal definitions
  289. hi SpecialKey ctermfg=darkgreen
  290. hi NonText cterm=bold ctermfg=darkblue
  291. hi Directory ctermfg=darkcyan
  292. hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1
  293. hi IncSearch cterm=NONE ctermfg=yellow ctermbg=green
  294. hi Search cterm=NONE ctermfg=grey ctermbg=blue
  295. hi MoreMsg ctermfg=darkgreen
  296. hi ModeMsg cterm=NONE ctermfg=brown
  297. hi LineNr ctermfg=3
  298. hi Question ctermfg=green
  299. hi StatusLine cterm=bold,reverse
  300. hi StatusLineNC cterm=reverse
  301. hi VertSplit cterm=reverse
  302. hi Title ctermfg=5
  303. hi Visual cterm=reverse
  304. hi VisualNOS cterm=bold,underline
  305. hi WarningMsg ctermfg=1
  306. hi WildMenu ctermfg=0 ctermbg=3
  307. hi Folded ctermfg=darkgrey ctermbg=NONE
  308. hi FoldColumn ctermfg=darkgrey ctermbg=NONE
  309. hi DiffAdd ctermbg=4
  310. hi DiffChange ctermbg=5
  311. hi DiffDelete cterm=bold ctermfg=4 ctermbg=6
  312. hi DiffText cterm=bold ctermbg=1
  313. hi Comment ctermfg=darkcyan
  314. hi Constant ctermfg=brown
  315. hi Special ctermfg=5
  316. hi Identifier ctermfg=6
  317. hi Statement ctermfg=3
  318. hi PreProc ctermfg=5
  319. hi Type ctermfg=2
  320. hi Underlined cterm=underline ctermfg=5
  321. hi Ignore ctermfg=darkgrey
  322. hi Error cterm=bold ctermfg=7 ctermbg=1
  323. endif
  324. " vim: set fdl=0 fdm=marker: