diff options
author | hut <hut@lavabit.com> | 2011-10-07 02:40:19 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2011-10-08 06:09:02 +0200 |
commit | 7bf5f9672ee79489553506831b7cab54a8609077 (patch) | |
tree | 42c9dcd2621b428027b2d4281f5c12d3dc2b0298 /ranger | |
parent | afcc81964f8fa2a6e4800c725822feb0f7edebd3 (diff) | |
download | ranger-7bf5f9672ee79489553506831b7cab54a8609077.tar.gz |
general updates
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/__init__.py | 23 | ||||
-rw-r--r-- | ranger/core/actions.py | 2 | ||||
-rw-r--r-- | ranger/core/fm.py | 4 | ||||
-rw-r--r-- | ranger/core/helper.py | 7 | ||||
-rw-r--r-- | ranger/data/config_examples/options.py | 103 |
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 + +# =================================================================== |