From 3937f01085b05b486a597cd6865ca49a5af2a1e4 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 23 Mar 2010 18:32:47 +0100 Subject: main: updated --- ranger/__main__.py | 21 ++++++++++++--------- ranger/core/fm.py | 5 +++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ranger/__main__.py b/ranger/__main__.py index 23491c28..bd01bf4a 100644 --- a/ranger/__main__.py +++ b/ranger/__main__.py @@ -40,8 +40,7 @@ def parse_arguments(): help="activate debug mode") parser.add_option('-c', '--clean', action='store_true', - help="don't touch/require any config files. " \ - "This will disable certain features. (tagging, bookmarks)") + help="don't touch/require any config files. ") parser.add_option('-r', '--confdir', dest='confdir', type='string', default=DEFAULT_CONFDIR, @@ -87,7 +86,7 @@ def main(): sys.exit(1) from signal import signal, SIGINT - from locale import setlocale, LC_ALL + from locale import getdefaultlocale, setlocale, LC_ALL import ranger from ranger.ext import curses_interrupt_handler @@ -97,16 +96,20 @@ def main(): from ranger.gui.defaultui import DefaultUI as UI from ranger.fsobject.file import File - try: - setlocale(LC_ALL, 'en_US.utf8') - except: - pass - - curses_interrupt_handler.install_interrupt_handler() + # Ensure that a utf8 locale is set. + if getdefaultlocale()[1] not in ('utf8', 'UTF-8'): + for locale in ('en_US.utf8', 'en_US.UTF-8'): + try: setlocale(LC_ALL, locale) + except: pass #sometimes there is none available though... + else: + setlocale(LC_ALL, '') arg = parse_arguments() ranger.arg = arg + if not ranger.arg.debug: + curses_interrupt_handler.install_interrupt_handler() + SettingsAware._setup() # Initialize objects diff --git a/ranger/core/fm.py b/ranger/core/fm.py index d6822940..ba64b5bf 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -142,6 +142,11 @@ class FM(Actions): gc_tick = 0 env.garbage_collect() + except KeyboardInterrupt: + # this only happens in --debug mode. By default, interrupts + # are caught in curses_interrupt_handler + raise SystemExit + finally: bookmarks.remember(env.cwd) bookmarks.save() -- cgit 1.4.1-2-gfad0