about summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
...
* yet another simplification of dotile()Anselm R. Garbe2006-10-051-30/+25
* simplified dotile()Anselm R. Garbe2006-10-052-37/+20
* applied resizecol fix by JukkaAnselm R. Garbe2006-10-051-2/+4
* Button3 click on mode label toggles stack position nowAnselm R. Garbe2006-10-052-2/+5
* applied dave's highlight patch for big fontsAnselm R. Garbe2006-09-291-1/+1
* using ff tiled again, seems to work perfectly with new bottom stackAnselm R. Garbe2006-09-291-1/+1
* applied ality's hardcode-0 patchesAnselm R. Garbe2006-09-291-5/+5
* added symbols for different modesAnselm R. Garbe2006-09-294-6/+13
* removed useless updatemasterAnselm R. Garbe2006-09-294-9/+3
* documented the new behavior in man pageAnselm R. Garbe2006-09-291-0/+3
* fixed small offset issueAnselm R. Garbe2006-09-291-1/+1
* fixed the z-layer issue described on mailinglistAnselm R. Garbe2006-09-291-1/+8
* removed the direction flippingAnselm R. Garbe2006-09-294-66/+18
* small fix of a corner caseAnselm R. Garbe2006-09-291-1/+1
* small changeAnselm R. Garbe2006-09-292-2/+2
* added the new dotile as described on mlAnselm R. Garbe2006-09-296-36/+112
* prelim of dotile()Anselm R. Garbe2006-09-292-37/+68
* I changed sanders patch to fix the ff issue to be simplier, though it needs t...Anselm R. Garbe2006-09-291-3/+2
* first step to a more flexible dotile() algorithmAnselm R. Garbe2006-09-297-35/+52
* renamed column into areaAnselm R. Garbe2006-09-282-7/+25
* small change to READMEAnselm R. Garbe2006-09-281-1/+1
* applied Jukkas patchAnselm R. Garbe2006-09-283-17/+19
* Added tag 1.7.1 for changeset d5ad819f2a66a40fa75dd2e44429f3bfc884d07bAnselm R. Garbe2006-09-271-0/+1
* fixing the settags issue, preparing 1.7.1 1.7.1Anselm R. Garbe2006-09-274-16/+18
* removed an unused vararg@zarathustra2006-09-261-1/+0
* Added tag 1.7 for changeset 4dbdb61c8b8ce21dee5c7050a6b103855964ed20arg@zarathustra2006-09-261-0/+1
* updated README 1.7arg@mmvi2006-09-261-1/+1
* small changearg@mmvi2006-09-261-2/+2
* added slight error check to getcolorarg@mmvi2006-09-261-1/+2
* small fixarg@mmvi2006-09-261-1/+1
* changed order of colordefs in config.h's, changed config.arg.h to fit to new ...arg@mmvi2006-09-262-7/+8
* removed useless debug infoarg@mmvi2006-09-261-4/+0
* added configure(), but this doesn't really fix those frking broken SDL appsarg@mmvi2006-09-263-13/+27
* slight change of event handling orderarg@mmvi2006-09-251-6/+6
* simplified mouse resizalsarg@mmvi2006-09-251-43/+16
* applied sanders jukka patcharg@mmvi2006-09-253-11/+5
* applied Jukkas patcharg@mmvi2006-09-256-19/+19
* removed all dotile checksarg@mmvi2006-09-222-4/+4
* applied Jukkas remark (dunno if this is correct though)arg@mmvi2006-09-221-2/+2
* applied jukkas patcharg@mmvi2006-09-221-8/+4
* man page fixarg@mmvi2006-09-221-1/+1
* ismax toggling on mouse based actionarg@mmvi2006-09-221-0/+2
* hotfixarg@mmvi2006-09-221-5/+5
* small change to achieve Jukka's last proposalarg@mmvi2006-09-222-14/+34
* fixed issue pointed out by Jukkaarg@mmvi2006-09-224-10/+5
* patched resizemouse according to sanders remarkarg@mmvi2006-09-221-2/+2
* small man page fixarg@mmvi2006-09-221-0/+1
* sander check thisarg@mmvi2006-09-221-19/+37
* slight change to config.arg.h (I use ff floating)arg@mmvi2006-09-221-1/+1
* updated man pagearg@mmvi2006-09-221-5/+1
/gui/colorscheme.py?h=v1.2.1&id=9dc6fe07975ef2d489e5071f4e6d7223a33cb3b3'>9dc6fe07 ^
f027adc0 ^
9ec914e3 ^
9dc6fe07 ^
9dc6fe07 ^
9ec914e3 ^




728fb838 ^
f027adc0 ^
9ec914e3 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100





























                                                                             
                                  
                                                                          
                                          

                                                
                                                                            
                                                                            
                              

                                                                           
                                                 


                                                               
                            
 


                                                              
 



                                                                  
 

                               
 
                             





                                                                    

                                               
 
                                
                                              
 
                                                
                                                            
 
                                                                           


                                                 
 
                                  





                                                                   
                                                      
 
                                              
                                                           
 
                               




                                                                             
                                                           
 
                                     
"""
Colorschemes define colors for specific contexts.

Generally, this works by passing a set of keywords (strings) to
the colorscheme.get() method to receive the tuple (fg, bg, attr).
fg, bg are the foreground and background colors and attr is the attribute.
The values are specified in ranger.gui.color.

A colorscheme must...

1. be inside either of these directories:
~/.ranger/colorschemes/
path/to/ranger/colorschemes/

2. be a subclass of ranger.gui.colorscheme.ColorScheme

3. implement a use(self, context) method which returns (fg, bg, attr).
context is a struct which contains all entries of CONTEXT_KEYS,
associated with either True or False.

define which colorscheme to use by having this to your options.py:
from ranger import colorschemes
colorscheme = colorschemes.filename

If your colorscheme-file contains more than one colorscheme, specify it with:
colorscheme = colorschemes.filename.classname
"""

from ranger.ext.openstruct import OpenStruct

CONTEXT_KEYS = [ 'reset', 'error',
		'in_browser', 'in_statusbar', 'in_titlebar', 'in_console',
		'in_pager', 'in_taskview',
		'directory', 'file', 'hostname',
		'executable', 'media', 'link',
		'video', 'audio', 'image', 'media', 'document', 'container',
		'selected', 'empty', 'main_column', 'message', 'background',
		'good', 'bad',
		'space', 'permissions', 'owner', 'group', 'mtime', 'nlink',
		'scroll', 'all', 'bot', 'top', 'percentage',
		'marked', 'tagged', 'tag_marker',
		'help_markup',
		'seperator', 'key', 'special',
		'title', 'text', 'highlight', 'bars', 'quotes',
		'keybuffer']

class ColorScheme(object):
	"""
	This is the class that colorschemes must inherit from.

	it defines get() 
	it defines the get() method, which returns the color tuple
	which fits to the given keys.
	"""

	def __init__(self):
		self.cache = {}

	def get(self, *keys):
		"""
		Returns the (fg, bg, attr) for the given keys.

		Using this function rather than use() will cache all
		colors for faster access.
		"""
		try:
			return self.cache[keys]

		except KeyError:
			context = OpenStruct()

			for key in CONTEXT_KEYS:
				context[key] = (key in keys)

			# add custom error messages for broken colorschemes
			color = self.use(context)
			self.cache[keys] = color
			return color

	def get_attr(self, *keys):
		"""
		Returns the curses attribute for the specified keys
		
		Ready to use for curses.setattr()
		"""
		from curses import color_pair
		from ranger.gui.color import get_color

		fg, bg, attr = self.get(*keys)
		return attr | color_pair(get_color(fg, bg))

	def use(self, context):
		"""
		Use the colorscheme to determine the (fg, bg, attr) tuple.
		This is a dummy function which always returns default_colors.
		Override this in your custom colorscheme!
		"""
		from ranger.gui.color import default_colors

		return default_colors