dotfiles

config files and scripts
git clone git://git.hanetzok.net/dotfiles
Log | Files | Refs

dracula.py (5730B)


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