summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-02-28 19:16:30 +0100
committerhut <hut@lavabit.com>2010-02-28 19:21:33 +0100
commit7740d52513dd78d1e5b84262c076c15f0a3e42d3 (patch)
treeff9381f286e7faae705c74c40c27e8008414a215
parentd8bb27bde7952939643f2d23711bd85c401d94d1 (diff)
downloadranger-7740d52513dd78d1e5b84262c076c15f0a3e42d3.tar.gz
added a seperate Context class
-rw-r--r--ranger/gui/colorscheme.py20
-rw-r--r--ranger/gui/context.py41
2 files changed, 43 insertions, 18 deletions
diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py
index f40e4a0d..867aec70 100644
--- a/ranger/gui/colorscheme.py
+++ b/ranger/gui/colorscheme.py
@@ -44,22 +44,7 @@ colorscheme = colorschemes.filename.classname
 from ranger.ext.openstruct import ReferencedOpenStruct
 from curses import color_pair
 from ranger.gui.color import get_color
-
-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']
+from ranger.gui.context import Context
 
 class ColorScheme(object):
 	"""
@@ -85,8 +70,7 @@ class ColorScheme(object):
 			return self.cache[keys]
 
 		except KeyError:
-			context = ReferencedOpenStruct(dict(
-				(key, key in keys) for key in CONTEXT_KEYS))
+			context = Context(keys)
 
 			# add custom error messages for broken colorschemes
 			color = self.use(context)
diff --git a/ranger/gui/context.py b/ranger/gui/context.py
new file mode 100644
index 00000000..25544932
--- /dev/null
+++ b/ranger/gui/context.py
@@ -0,0 +1,41 @@
+# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+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 Context(object):
+	def __init__(self, keys):
+		# set all given keys to True
+		d = self.__dict__
+		for key in keys:
+			d[key] = True
+
+# set all keys to False
+for key in CONTEXT_KEYS:
+	setattr(Context, key, False)
^
3791ec0 ^





eb184e0 ^



3791ec0 ^

eb184e0 ^



3791ec0 ^

eb184e0 ^





d8675f6 ^
eb184e0 ^




3791ec0 ^


eb184e0 ^

3791ec0 ^

eb184e0 ^


6458d72 ^

605630c ^
6649dcc ^
3791ec0 ^
650a1fb ^
605630c ^
1e7e57d ^
6649dcc ^
f1a34ae ^
6649dcc ^

1e7e57d ^

d8675f6 ^

f1a34ae ^
d8675f6 ^
3657eae ^
650a1fb ^
6649dcc ^
650a1fb ^

6649dcc ^
650a1fb ^
3657eae ^
6458d72 ^

f60c597 ^
6458d72 ^
f1a34ae ^
650a1fb ^

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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118