summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-07 02:40:19 +0200
committerhut <hut@lavabit.com>2011-10-08 06:09:02 +0200
commit7bf5f9672ee79489553506831b7cab54a8609077 (patch)
tree42c9dcd2621b428027b2d4281f5c12d3dc2b0298 /ranger
parentafcc81964f8fa2a6e4800c725822feb0f7edebd3 (diff)
downloadranger-7bf5f9672ee79489553506831b7cab54a8609077.tar.gz
general updates
Diffstat (limited to 'ranger')
-rw-r--r--ranger/__init__.py23
-rw-r--r--ranger/core/actions.py2
-rw-r--r--ranger/core/fm.py4
-rw-r--r--ranger/core/helper.py7
-rw-r--r--ranger/data/config_examples/options.py103
5 files changed, 106 insertions, 33 deletions
diff --git a/ranger/__init__.py b/ranger/__init__.py
index 32a31eae..f6d6529b 100644
--- a/ranger/__init__.py
+++ b/ranger/__init__.py
@@ -14,18 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 """
-Console-based visual file manager.
+A console file manager with VI key bindings.
 
-Ranger is a file manager with an ncurses frontend written in Python.
-It is designed to give you a broader overview of the file system by
-displaying previews and backviews, dividing the screen into columns.
-
-The keybindings are similar to those of other console programs like
-vim, mutt or ncmpcpp so the usage will be intuitive and efficient.
+It provides a minimalistic yet nice curses interface with a view on the
+directory hierarchy.  The secondary task of ranger is to psychically guess
+which program you want to use for opening particular files.
 """
 
 import os
-from ranger.core.main import main
 
 # Information
 __license__ = 'GPL3'
@@ -35,3 +31,14 @@ __email__ = 'romanz@lavabit.com'
 
 # Constants
 RANGERDIR = os.path.dirname(__file__)
+TICKS_BEFORE_COLLECTING_GARBAGE = 100
+TIME_BEFORE_FILE_BECOMES_GARBAGE = 1200
+MACRO_DELIMITER = '%'
+LOGFILE = '/tmp/errorlog'
+USAGE = '%prog [options] [path/filename]'
+
+# If the environment variable XDG_CONFIG_HOME is non-empty, CONFDIR is ignored
+# and the configuration directory will be $XDG_CONFIG_HOME/ranger instead.
+CONFDIR = '~/.config/ranger'
+
+from ranger.core.main import main
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 58edc56a..9f7321be 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -38,7 +38,7 @@ MACRO_FAIL = "<\x01\x01MACRO_HAS_NO_VALUE\x01\01>"
 
 class _MacroTemplate(string.Template):
 	"""A template for substituting macros in commands"""
-	delimiter = '%'
+	delimiter = ranger.MACRO_DELIMITER
 
 class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 	search_method = 'ctime'
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index 9192f15c..6d772054 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -25,6 +25,7 @@ import stat
 import sys
 
 import ranger
+from ranger import *
 from ranger.core.actions import Actions
 from ranger.container.tags import Tags
 from ranger.gui.ui import UI
@@ -36,9 +37,6 @@ from ranger.ext.signals import SignalDispatcher
 from ranger import __version__
 from ranger.core.loader import Loader
 
-TICKS_BEFORE_COLLECTING_GARBAGE = 100
-TIME_BEFORE_FILE_BECOMES_GARBAGE = 1200
-
 class FM(Actions, SignalDispatcher):
 	input_blocked = False
 	input_blocked_until = 0
diff --git a/ranger/core/helper.py b/ranger/core/helper.py
index 9a403a15..f4035ef8 100644
--- a/ranger/core/helper.py
+++ b/ranger/core/helper.py
@@ -20,8 +20,6 @@ import os.path
 import sys
 from ranger import *
 
-LOGFILE = '/tmp/errorlog'
-
 def parse_arguments():
 	"""Parse the program arguments"""
 	from optparse import OptionParser, SUPPRESS_HELP
@@ -32,10 +30,9 @@ def parse_arguments():
 	if 'XDG_CONFIG_HOME' in os.environ and os.environ['XDG_CONFIG_HOME']:
 		default_confdir = os.environ['XDG_CONFIG_HOME'] + '/ranger'
 	else:
-		default_confdir = '~/.config/ranger'
-	usage = '%prog [options] [path/filename]'
+		default_confdir = CONFDIR
 
-	parser = OptionParser(usage=usage, version='ranger '+__version__)
+	parser = OptionParser(usage=USAGE, version='ranger '+__version__)
 
 	parser.add_option('-d', '--debug', action='store_true',
 			help="activate debug mode")
diff --git a/ranger/data/config_examples/options.py b/ranger/data/config_examples/options.py
index e37605ce..7006ebd5 100644
--- a/ranger/data/config_examples/options.py
+++ b/ranger/data/config_examples/options.py
@@ -1,32 +1,103 @@
 # ===================================================================
-# This is the main configuration file of ranger.  It consists of python code,
-# but fear not, you don't need any python knowledge for this.
+# This is the main configuration file of ranger.  It consists of python
+# code, but fear not, you don't need any python knowledge for changing
+# the settings.
 #
 # Lines beginning with # are comments.  To enable a line, remove the #.
 #
-# Technical information:  This file is imported as a python module.  Every
-# top-level variable with the name of a ranger setting will be used to change
-# the value of that setting.  You can use "del <variable-name>" to avoid that.
+# Here are the most important settings.  Refer to the man page for
+# a list and descriptions of all settings.
 # ===================================================================
 
-# This line imports some basic variables to get some basic variables
+# This line imports some basic variables
 from ranger.api.options import *
 
-# T
-#column_ratios = (1, 1, 4, 3)
+# Ranger can use a customizable external script for previews.  The included
+# default script prints previews of archives, html/pdf documents and even
+# images.  This is, however, disabled by default for performance reasons.  Turn
+# it on by uncommenting this line:
+#use_preview_script = True
 
-# A function that adds an additional macro:
+# This changes the location of the preview script
+#preview_script = "~/.config/ranger/scope.sh"
+
+# Use a simple character-wise sort algorithm instead of the default natural
+# sorting.  This is faster, although the difference is hardly noticeable.
+#sort = "basename"
+
+# Use a unicode "..." symbol when filenames are truncated.  This is disabled
+# by default since some systems don't support unicode+curses well.
+#unicode_ellipsis = True
+
+# Uncomment these lines to disable previews by default?
+#preview_files = False
+#preview_directories = False
+
+# xterm handles the ALT key differently.  If you use xterm, uncomment this line
+#xterm_alt_key = True
+
+# Change what files ranger should hide with this setting.  Its value is a
+# "regular expression".  If you don't know about them, there are lots of good
+# tutorials on the web!  Below is the default value.
+#hidden_filter = regexp(r"^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__cache__$")
+
+
+# ===================================================================
+# Beware: from here on, you are on your own.  This part requires python
+# knowledge.
+#
+# Since python is a dynamic language, it gives you the power to replace any
+# part of ranger without touching the code.  This is commonly referred to as
+# Monkey Patching and can be helpful if you, for some reason, don't want to
+# modify rangers code directly.  Just remember: the more you mess around, the
+# more likely it is to break when you switch to another version.  Here are some
+# practical examples of monkey patching.
 #
+# Technical information:  This file is imported as a python module.  If a
+# variable has the name of a setting, ranger will attempt to use it to change
+# that setting.  You can write "del <variable-name>" to avoid that.
+# ===================================================================
+# Add a new sorting algorithm: Random sort.
+# Enable this with :set sort=random
+
+#from ranger.fsobject.directory import Directory
+#from random import random
+#Directory.sort_dict['random'] = lambda path: random()
+
+# ===================================================================
+# A function that changes which files are displayed.  This is more powerful
+# than the hidden_filter setting since this function has more information.
+
+## Save the original filter function
+#import ranger.fsobject.directory
+#old_accept_file = ranger.fsobject.directory.accept_file
+
+## Define a new one
+#def accept_file_MOD(fname, mypath, hidden_filter, name_filter):
+#	if mypath == '/' and fname in ('boot', 'sbin', 'proc', 'sys'):
+#		return False
+#	else:
+#		return old_accept_file(fname, mypath, hidden_filter, name_filter)
+
+## Overwrite the old function
+#import ranger.fsobject.directory
+#ranger.fsobject.directory.accept_file = accept_file_MOD
+
+# ===================================================================
+# A function that adds an additional macro.  Test this with :shell -p echo %date
+
 ## Save the original macro function
-#import ranger.actions
-#old_get_macros = ranger.actions.Actions.get_macros
+#import ranger.core.actions
+#old_get_macros = ranger.core.actions.Actions._get_macros
 #
 ## Define a new macro function
 #import time
-#def add_my_macro(self):
-#  macros = old_get_macros(self)
-#  macros['date'] = time.strftime('%m/%d/%Y')
-#  return macros
+#def get_macros_MOD(self):
+#	macros = old_get_macros(self)
+#	macros['date'] = time.strftime('%m/%d/%Y')
+#	return macros
 #
 ## Overwrite the old one
-#ranger.actions.Actions.get_macros = add_my_macro
+#ranger.core.actions.Actions._get_macros = get_macros_MOD
+
+# ===================================================================
e='author hut <hut@lavabit.com> 2009-12-25 21:55:04 +0100 committer hut <hut@lavabit.com> 2009-12-25 21:55:04 +0100 updated pydoc pages' href='/akspecs/ranger/commit/doc/ranger.gui.displayable.html?id=f07bb12fc5c59430e995a64956b36331ce3629b9'>f07bb12f ^
4c13e1f2 ^




34a60763 ^
4c13e1f2 ^
34a60763 ^
4c13e1f2 ^



f07bb12f ^
62cd83ba ^
f07bb12f ^






4c13e1f2 ^















f07bb12f ^





4c13e1f2 ^
f07bb12f ^
34a60763 ^
f07bb12f ^




4c13e1f2 ^
f07bb12f ^








f07bb12f ^



4c13e1f2 ^
f07bb12f ^


62cd83ba ^

f07bb12f ^




4c13e1f2 ^
f07bb12f ^
4c13e1f2 ^

f07bb12f ^



f07bb12f ^















4c13e1f2 ^

f07bb12f ^
4c13e1f2 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
34a60763 ^
f07bb12f ^
4c13e1f2 ^
f07bb12f ^

4c13e1f2 ^
62cd83ba ^
4c13e1f2 ^

f07bb12f ^
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294