Advertisement
hundone

solarized.py

Apr 8th, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.05 KB | None | 0 0
  1. # Joseph Tannhuber <sepp.tannhuber@yahoo.de>, 2013
  2. # Solarized like colorscheme, similar to solarized-dircolors
  3. # from https://github.com/seebi/dircolors-solarized.
  4. # This is a modification of Roman Zimbelmann's default colorscheme.
  5. # This software is distributed under the terms of the GNU GPL version 3.
  6.  
  7. from ranger.gui.colorscheme import ColorScheme
  8. from ranger.gui.color import *
  9.  
  10. class Solarized(ColorScheme):
  11.     progress_bar_color = 33
  12.  
  13.     def use(self, context):
  14.         fg, bg, attr = default_colors
  15.  
  16.         if context.reset:
  17.             return default_colors
  18.  
  19.         elif context.in_browser:
  20.             fg = 244
  21.             if context.selected:
  22.                 attr = reverse
  23.             else:
  24.                 attr = normal
  25.             if context.empty or context.error:
  26.                 fg = 235
  27.                 bg = 160
  28.             if context.border:
  29.                 fg = default
  30.             if context.media:
  31.                 if context.image:
  32.                     fg = 136
  33.                 else:
  34.                     fg = 166
  35.             if context.container:
  36.                 fg = 61
  37.             if context.directory:
  38.                 fg = 4
  39.             elif context.executable and not \
  40.                     any((context.media, context.container,
  41.                         context.fifo, context.socket)):
  42.                 fg = 64
  43.                 attr |= bold
  44.             if context.socket:
  45.                 fg = 136
  46.                 bg = 230
  47.                 attr |= bold
  48.             if context.fifo:
  49.                 fg = 136
  50.                 bg = 230
  51.                 attr |= bold
  52.             if context.device:
  53.                 fg = 244
  54.                 bg = 230
  55.                 attr |= bold
  56.             if context.link:
  57.                 fg = context.good and 37 or 160
  58.                 attr |= bold
  59.                 if context.bad:
  60.                     bg = 235
  61.             if context.tag_marker and not context.selected:
  62.                 attr |= bold
  63.                 if fg in (red, magenta):
  64.                     fg = white
  65.                 else:
  66.                     fg = red
  67.             if not context.selected and (context.cut or context.copied):
  68.                 fg = 234
  69.                 attr |= bold
  70.             if context.main_column:
  71.                 if context.selected:
  72.                     attr |= bold
  73.                 if context.marked:
  74.                     attr |= bold
  75.                     bg = 237
  76.             if context.badinfo:
  77.                 if attr & reverse:
  78.                     bg = magenta
  79.                 else:
  80.                     fg = magenta
  81.  
  82.         elif context.in_titlebar:
  83.             attr |= bold
  84.             if context.hostname:
  85.                 fg = context.bad and 16 or 3
  86.                 if context.bad:
  87.                     bg = 166
  88.             elif context.directory:
  89.                 fg = 7
  90.             elif context.tab:
  91.                 fg = context.good and 3 or 7
  92.                 bg = 0
  93.             elif context.link:
  94.                 fg = cyan
  95.  
  96.         elif context.in_statusbar:
  97.             if context.permissions:
  98.                 if context.good:
  99.                     fg = 2
  100.                 elif context.bad:
  101.                     fg = 160
  102.                     bg = 235
  103.             if context.marked:
  104.                 attr |= bold | reverse
  105.                 fg = 237
  106.                 bg = 47
  107.             if context.message:
  108.                 if context.bad:
  109.                     attr |= bold
  110.                     fg = 160
  111.                     bg = 235
  112.             if context.loaded:
  113.                 bg = self.progress_bar_color
  114.  
  115.         if context.text:
  116.             if context.highlight:
  117.                 attr |= reverse
  118.  
  119.         if context.in_taskview:
  120.             if context.title:
  121.                 fg = 93
  122.  
  123.             if context.selected:
  124.                 attr |= reverse
  125.  
  126.             if context.loaded:
  127.                 if context.selected:
  128.                     fg = self.progress_bar_color
  129.                 else:
  130.                     bg = self.progress_bar_color
  131.  
  132.         return fg, bg, attr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement