dracula.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. # This file is part of ranger, the console file manager.
  2. # License: GNU GPL version 3, see the file "AUTHORS" for details.
  3. # This theme was greatly inspired by "RougarouTheme" for ranger
  4. # It can be found in: `https://github.com/RougarouTheme/ranger`
  5. from __future__ import absolute_import, division, print_function
  6. from ranger.gui.colorscheme import ColorScheme
  7. from ranger.gui.color import (
  8. black,
  9. blue,
  10. cyan,
  11. green,
  12. magenta,
  13. red,
  14. white,
  15. yellow,
  16. default,
  17. normal,
  18. bold,
  19. reverse,
  20. default_colors,
  21. )
  22. class Dracula(ColorScheme):
  23. progress_bar_color = 13
  24. def verify_browser(self, context, fg, bg, attr):
  25. if context.selected:
  26. attr = reverse
  27. else:
  28. attr = normal
  29. if context.empty or context.error:
  30. bg = 1
  31. fg = 0
  32. if context.border:
  33. fg = default
  34. if context.document:
  35. attr |= normal
  36. fg = 13
  37. if context.media:
  38. if context.image:
  39. attr |= normal
  40. fg = 3
  41. elif context.video:
  42. fg = 1
  43. elif context.audio:
  44. fg = 6
  45. else:
  46. fg = 10
  47. if context.container:
  48. attr |= bold
  49. fg = 9
  50. if context.directory:
  51. attr |= bold
  52. fg = 4
  53. elif context.executable and not any(
  54. (context.media, context.container, context.fifo, context.socket)
  55. ):
  56. attr |= bold
  57. fg = 2
  58. if context.socket:
  59. fg = 5
  60. attr |= bold
  61. if context.fifo or context.device:
  62. fg = 3
  63. if context.device:
  64. attr |= bold
  65. if context.link:
  66. fg = 6 if context.good else 13
  67. if context.tag_marker and not context.selected:
  68. attr |= bold
  69. if fg in (red, magenta):
  70. fg = 1
  71. else:
  72. fg = 15
  73. if not context.selected and (context.cut or context.copied):
  74. fg = 8
  75. attr |= bold
  76. if context.main_column:
  77. if context.selected:
  78. attr |= bold
  79. if context.marked:
  80. attr |= bold
  81. fg = 11
  82. if context.badinfo:
  83. if attr & reverse:
  84. bg = 5
  85. else:
  86. fg = 5
  87. if context.inactive_pane:
  88. fg = 6
  89. return fg, bg, attr
  90. def verify_titlebar(self, context, fg, bg, attr):
  91. attr |= bold
  92. if context.hostname:
  93. fg = 1 if context.bad else 2
  94. elif context.directory:
  95. fg = 4
  96. elif context.tab:
  97. if context.good:
  98. bg = 2
  99. elif context.link:
  100. fg = 6
  101. return fg, bg, attr
  102. def verify_statusbar(self, context, fg, bg, attr):
  103. if context.permissions:
  104. if context.good:
  105. fg = 2
  106. elif context.bad:
  107. bg = 5
  108. fg = 8
  109. if context.marked:
  110. attr |= bold | reverse
  111. fg = 3
  112. if context.frozen:
  113. attr |= bold | reverse
  114. fg = 6
  115. if context.message:
  116. if context.bad:
  117. attr |= bold
  118. fg = 1
  119. if context.loaded:
  120. bg = self.progress_bar_color
  121. if context.vcsinfo:
  122. fg = 4
  123. attr &= ~bold
  124. if context.vcscommit:
  125. fg = 3
  126. attr &= ~bold
  127. if context.vcsdate:
  128. fg = 6
  129. attr &= ~bold
  130. return fg, bg, attr
  131. def verify_taskview(self, context, fg, bg, attr):
  132. if context.title:
  133. fg = 4
  134. if context.selected:
  135. attr |= reverse
  136. if context.loaded:
  137. if context.selected:
  138. fg = self.progress_bar_color
  139. else:
  140. bg = self.progress_bar_color
  141. return fg, bg, attr
  142. def verify_vcsfile(self, context, fg, bg, attr):
  143. attr &= ~bold
  144. if context.vcsconflict:
  145. fg = 5
  146. elif context.vcschanged:
  147. fg = 1
  148. elif context.vcsunknown:
  149. fg = 1
  150. elif context.vcsstaged:
  151. fg = 2
  152. elif context.vcssync:
  153. fg = 2
  154. elif context.vcsignored:
  155. fg = default
  156. return fg, bg, attr
  157. def verify_vcsremote(self, context, fg, bg, attr):
  158. attr &= ~bold
  159. if context.vcssync or context.vcsnone:
  160. fg = 2
  161. elif context.vcsbehind:
  162. fg = 1
  163. elif context.vcsahead:
  164. fg = 6
  165. elif context.vcsdiverged:
  166. fg = 5
  167. elif context.vcsunknown:
  168. fg = 1
  169. return fg, bg, attr
  170. def use(self, context):
  171. fg, bg, attr = default_colors
  172. if context.reset:
  173. return default_colors
  174. elif context.in_browser:
  175. fg, bg, attr = self.verify_browser(context, fg, bg, attr)
  176. elif context.in_titlebar:
  177. fg, bg, attr = self.verify_titlebar(context, fg, bg, attr)
  178. elif context.in_statusbar:
  179. fg, bg, attr = self.verify_statusbar(context, fg, bg, attr)
  180. if context.text:
  181. if context.highlight:
  182. attr |= reverse
  183. if context.in_taskview:
  184. fg, bg, attr = self.verify_taskview(context, fg, bg, attr)
  185. if context.vcsfile and not context.selected:
  186. fg, bg, attr = self.verify_vcsfile(context, fg, bg, attr)
  187. elif context.vcsremote and not context.selected:
  188. fg, bg, attr = self.verify_vcsremote(context, fg, bg, attr)
  189. return fg, bg, attr