diff options
author | hut <hut@lavabit.com> | 2009-12-12 00:23:18 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-12 00:23:18 +0100 |
commit | 22449efdeaec4ae089a6461ab93700536b5ea1bd (patch) | |
tree | e50ea0bcd38f93bd3fa59f60086980f84e33282f /ranger | |
parent | 649a69cb87af38f4bf1848085d49d1193f6e01ab (diff) | |
download | ranger-22449efdeaec4ae089a6461ab93700536b5ea1bd.tar.gz |
clean ups/fixes
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/defaults/apps.py | 4 | ||||
-rw-r--r-- | ranger/defaults/keys.py | 28 | ||||
-rw-r--r-- | ranger/ext/log.py | 2 | ||||
-rw-r--r-- | ranger/fm.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/console.py | 42 | ||||
-rw-r--r-- | ranger/gui/widgets/filelist.py | 1 |
6 files changed, 47 insertions, 32 deletions
diff --git a/ranger/defaults/apps.py b/ranger/defaults/apps.py index b2dc36c6..37422a6e 100644 --- a/ranger/defaults/apps.py +++ b/ranger/defaults/apps.py @@ -53,12 +53,16 @@ class CustomApplications(Applications): def app_feh(self, **kw): if kw['files']: if kw['mode'] == 1: + kw['flags'] += 'd' return run('feh', '--bg-scale', kw['files'][0], **kw) if kw['mode'] == 2: + kw['flags'] += 'd' return run('feh', '--bg-tile', kw['files'][0], **kw) if kw['mode'] == 3: + kw['flags'] += 'd' return run('feh', '--bg-center', kw['files'][0], **kw) if kw['mode'] == 4: + kw['flags'] += 'd' return run('gimp', *kw['files'], **kw) return run('feh', *kw['files'], **kw) diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 5edae929..7d6f7bd6 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -15,9 +15,9 @@ def initialize_commands(command_list): # * an integer which represents an ascii code # * a tuple of integers - def curry(fnc, *args, **keywords): + # currying + def c(fnc, *args, **keywords): return lambda fm: fnc(fm, *args, **keywords) - c=curry def move(**keywords): return lambda fm: fm.move_pointer(**keywords) @@ -75,13 +75,13 @@ def initialize_commands(command_list): bind(do.interrupt, ctrl('C')) bind(do.resize, curses.KEY_RESIZE) bind(do.handle_mouse, curses.KEY_MOUSE) - bind(curry(do.open_console, ':'), ':') - bind(curry(do.open_console, '/'), '/') - bind(curry(do.open_console, '!'), '!') - bind(curry(do.open_console, '@'), 'r') + bind(c(do.open_console, ':'), ':') + bind(c(do.open_console, '/'), '/') + bind(c(do.open_console, '!'), '!') + bind(c(do.open_console, '@'), 'r') def test(fm): - from ranger.helper import log + from ranger import log log(fm.bookmarks.dct) bind(test, 'x') @@ -96,15 +96,14 @@ def initialize_console_commands(command_list): command_list.bind(fnc, *keys) def type_key(key): - return lambda con, fm: con.type_key(key) + return lambda con: con.type_key(key) - def curry(fnc, *args, **keywords): - return lambda con, fm: fnc(con, *args, **keywords) + # currying + def c(fnc, *args, **keywords): + return lambda con: fnc(con, *args, **keywords) - def curry_fm(fnc, *args, **keywords): - return lambda con, fm: fnc(fm, *args, **keywords) - c_fm = curry_fm - c = curry + def c_fm(fnc, *args, **keywords): + return lambda con: fnc(con.fm, *args, **keywords) # movement bind(c(Console.move, relative = -1), curses.KEY_LEFT, ctrl('b')) @@ -113,6 +112,7 @@ def initialize_console_commands(command_list): bind(c(Console.move, absolute = -1), curses.KEY_END, ctrl('e')) bind(c(Console.delete, 0), curses.KEY_DC, ctrl('d')) bind(c(Console.delete, -1), curses.KEY_BACKSPACE, 127, ctrl('h')) + bind(c(Console.delete_word), ctrl('W')) bind(c(Console.delete_rest, -1), ctrl('U')) bind(c(Console.delete_rest, 1), ctrl('K')) diff --git a/ranger/ext/log.py b/ranger/ext/log.py index 9f56dd71..c2521e09 100644 --- a/ranger/ext/log.py +++ b/ranger/ext/log.py @@ -7,7 +7,7 @@ Has the same arguments as print() in python3""" sep = 'sep' in keywords and keywords['sep'] or ' ' _file = 'file' in keywords and keywords['file'] or open(LOGFILE, 'a') end = 'end' in keywords and keywords['end'] or '\n' - _file.write(sep.join((start, ) + objects) + end) + _file.write(sep.join(map(str, (start, ) + objects)) + end) #for python3-only versions, this could be replaced with: # diff --git a/ranger/fm.py b/ranger/fm.py index dd74342f..5abb2a8e 100644 --- a/ranger/fm.py +++ b/ranger/fm.py @@ -47,4 +47,4 @@ class FM(Actions): self.env.garbage_collect() except KeyboardInterrupt: - self.ui.handle_key(CTRL_C, self) + self.ui.handle_key(CTRL_C) diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index c7f3b29d..b1c9e15a 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -55,6 +55,7 @@ class Console(Displayable): def close(self): curses.curs_set(self.last_cursor_mode) + self.clear() self.focused = False self.visible = False if hasattr(self, 'on_close'): @@ -76,7 +77,7 @@ class Console(Displayable): if cmd == self.commandlist.dummy_object: return - cmd.execute(self, self.fm) + cmd.execute(self) self.env.key_clear() def type_key(self, key): @@ -105,6 +106,15 @@ class Console(Displayable): else: self.line = self.line[self.pos:] self.pos = 0 + + def delete_word(self): + try: + i = self.line.rindex(' ', 0, self.pos - 1) + 1 + self.line = self.line[:i] + self.line[self.pos:] + self.pos = len(self.line) + except ValueError: + self.line = '' + self.pos = 0 def delete(self, mod): if mod == -1 and len(self.line) == 0: @@ -114,46 +124,46 @@ class Console(Displayable): self.line = self.line[0:pos] + self.line[pos+1:] self.move(relative = mod) - def execute(self, fm): + def execute(self): try: - self.execute_funcs[self.mode] (self, fm) + self.execute_funcs[self.mode] (self) except KeyError: pass self.line = '' self.pos = 0 self.close() - def execute_search(self, fm): + def execute_search(self): import re - if fm.env.pwd: + if self.fm.env.pwd: # try: regexp = re.compile(self.line, re.L | re.U | re.I) - fm.env.last_search = regexp - if fm.env.pwd.search(regexp): - fm.env.cf = fm.env.pwd.pointed_file + self.fm.env.last_search = regexp + if self.fm.env.pwd.search(regexp): + self.fm.env.cf = self.fm.env.pwd.pointed_file # except: # pass - def execute_openwith(self, fm): + def execute_openwith(self): line = self.line if line[0] == '!': - fm.execute_file(tuple(line[1:].split()) + (fm.env.cf.path, )) + self.fm.execute_file(tuple(line[1:].split()) + (self.fm.env.cf.path, )) else: - fm.execute_file(tuple(line.split()) + (fm.env.cf.path, ), background = True) + self.fm.execute_file(tuple(line.split()) + (self.fm.env.cf.path, ), background = True) - def execute_openwith_quick(self, fm): + def execute_openwith_quick(self): split = self.line.split() - app, flags, mode = get_app_flags_mode(self.line, fm) - fm.execute_file( + app, flags, mode = get_app_flags_mode(self.line, self.fm) + self.fm.execute_file( files = [self.cf], app = app, flags = flags, mode = mode ) - def execute_noreturn(self, fm): + def execute_noreturn(self): pass - def execute_command(self, fm): + def execute_command(self): pass def get_app_flags_mode(line, fm): diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py index 493dae24..2bca6e24 100644 --- a/ranger/gui/widgets/filelist.py +++ b/ranger/gui/widgets/filelist.py @@ -185,6 +185,7 @@ class FileList(Displayable): # TODO: does not work if options.scroll_offset is high, # relative > 1 and you scroll from scroll_begin = 1 to 0 def scroll(self, relative): + """scroll by n lines""" self.set_scroll_begin() old_value = self.target.scroll_begin self.target.scroll_begin += relative |