diff options
author | hut <hut@lavabit.com> | 2010-04-13 12:50:25 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-13 12:50:25 +0200 |
commit | 36352437d24d55c49c5daad3d64a217728b9d094 (patch) | |
tree | 138b0e5f16c083acb8f4ea47acdbd7d2ddfb7c24 /ranger | |
parent | eb3795d352893ce760bfa31383cf98ba1ad9d113 (diff) | |
parent | cf8b174eff6a9e016903d1071289453c8d9407d5 (diff) | |
download | ranger-36352437d24d55c49c5daad3d64a217728b9d094.tar.gz |
Merge branch 'master' into devel
Conflicts: ranger/gui/widgets/console.py
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/actions.py | 3 | ||||
-rw-r--r-- | ranger/defaults/commands.py | 8 | ||||
-rw-r--r-- | ranger/defaults/keys.py | 2 | ||||
-rw-r--r-- | ranger/defaults/options.py | 3 | ||||
-rw-r--r-- | ranger/ext/command_parser.py | 21 | ||||
-rw-r--r-- | ranger/gui/bar.py | 9 | ||||
-rw-r--r-- | ranger/gui/widgets/browserview.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/titlebar.py | 29 | ||||
-rw-r--r-- | ranger/shared/settings.py | 1 |
9 files changed, 54 insertions, 24 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index c0599b46..38744d94 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -514,8 +514,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): self.tab_open(newtab) def tab_new(self): - for i in range(10): - i = (i + 1) % 10 + for i in range(1, 10): if not i in self.tabs: self.tab_open(i) break diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py index c5c47340..03fa1634 100644 --- a/ranger/defaults/commands.py +++ b/ranger/defaults/commands.py @@ -79,11 +79,11 @@ class Command(FileManagerAware): # one result. since it must be a directory, append a slash. if len(dirnames) == 1: - return line + join(rel_dirname, dirnames[0]) + '/' + return line.start(1) + join(rel_dirname, dirnames[0]) + '/' # more than one result. append no slash, so the user can # manually type in the slash to advance into that directory - return (line + join(rel_dirname, dirname) for dirname in dirnames) + return (line.start(1) + join(rel_dirname, dirname) for dirname in dirnames) def _tab_directory_content(self): from os.path import dirname, basename, expanduser, join, isdir @@ -129,11 +129,11 @@ class Command(FileManagerAware): # one result. since it must be a directory, append a slash. if len(names) == 1: - return line + join(rel_dirname, names[0]) + '/' + return line.start(1) + join(rel_dirname, names[0]) + '/' # more than one result. append no slash, so the user can # manually type in the slash to advance into that directory - return (line + join(rel_dirname, name) for name in names) + return (line.start(1) + join(rel_dirname, name) for name in names) # -------------------------------- definitions diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 7a235a5d..44acd79f 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -185,7 +185,7 @@ def initialize_commands(map): map('gt', TAB, fm.tab_move(1)) map('gT', KEY_BTAB, fm.tab_move(-1)) map('gn', ctrl('N'), fm.tab_new()) - for n in range(10): + for n in range(1, 10): map('g' + str(n), fm.tab_open(n)) # ------------------------------------------------------- searching diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py index d96955b7..a9dd8bde 100644 --- a/ranger/defaults/options.py +++ b/ranger/defaults/options.py @@ -75,6 +75,9 @@ update_title = True # directories are displayed at once, False turns off this feature. shorten_title = 3 +# Abbreviate $HOME with ~ in the titlebar (first line) of ranger? +tilde_in_titlebar = True + # How many directory-changes or console-commands should be kept in history? max_history_size = 20 diff --git a/ranger/ext/command_parser.py b/ranger/ext/command_parser.py index 3a676e8f..d737c277 100644 --- a/ranger/ext/command_parser.py +++ b/ranger/ext/command_parser.py @@ -25,6 +25,7 @@ class LazyParser(object): self._setting_line = None self._rests_loaded = 0 self._rests_gen_instance = None + self._starts = None try: self.firstpart = line[:line.rindex(' ') + 1] @@ -52,6 +53,26 @@ class LazyParser(object): else: return otherwise + def start(self, n): + if self._starts is None: + self._starts = [''] + line = self.line + result = "" + while True: + try: + index = line.index(' ') + 1 + except: + break + if index == 1: + continue + result = line[:index] + self._starts.append(result) + line = line[index:] + try: + return self._starts[n] + except: + return self._starts[-1] + def _rest_generator(self): lastrest = self.line n = 0 diff --git a/ranger/gui/bar.py b/ranger/gui/bar.py index c06a201e..f5e34eb1 100644 --- a/ranger/gui/bar.py +++ b/ranger/gui/bar.py @@ -68,7 +68,8 @@ class Bar(object): rightsize = self.right.sumsize() nonfixed_items = self.left.nonfixed_items() - itemsize = int(float(wid - rightsize - fixedsize) / nonfixed_items) + 1 + itemsize = int(float(wid - rightsize - fixedsize) / \ + (nonfixed_items + 1)) + 1 for item in self.left: if not item.fixed: @@ -95,8 +96,7 @@ class BarSide(list): def add(self, string, *lst, **kw): cs = ColoredString(string, self.base_color_tag, *lst) - if 'fixedsize' in kw: - cs.fixed = kw['fixedsize'] + cs.__dict__.update(kw) self.append(cs) def add_space(self, n=1): @@ -119,11 +119,10 @@ class BarSide(list): class ColoredString(object): - fixed = False - def __init__(self, string, *lst): self.string = string self.lst = lst + self.fixed = False def cut_off(self, n): n = max(n, min(len(self.string), 1)) diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py index 163fd503..7f2ea5fb 100644 --- a/ranger/gui/widgets/browserview.py +++ b/ranger/gui/widgets/browserview.py @@ -264,7 +264,7 @@ class BrowserView(Widget, DisplayableContainer): def poke(self): DisplayableContainer.poke(self) if self.settings.collapse_preview and self.preview: - has_preview = self.columns[-2].has_preview() + has_preview = self.columns[-1].has_preview() if self.preview_available != has_preview: self.preview_available = has_preview self.resize(self.y, self.x, self.hei, self.wid) diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py index 62740e2d..b815a07e 100644 --- a/ranger/gui/widgets/titlebar.py +++ b/ranger/gui/widgets/titlebar.py @@ -84,7 +84,7 @@ class TitleBar(Widget): self.fm.enter_dir("/") else: try: - self.fm.env.enter_dir(self.env.pathway[(i-3)/2]) + self.fm.enter_dir(part.directory) except: pass return True @@ -106,33 +106,40 @@ class TitleBar(Widget): else: clr = 'good' - bar.add(self.env.username, 'hostname', clr, fixedsize=True) - bar.add('@', 'hostname', clr, fixedsize=True) - bar.add(self.env.hostname, 'hostname', clr, fixedsize=True) + bar.add(self.env.username, 'hostname', clr, fixed=True) + bar.add('@', 'hostname', clr, fixed=True) + bar.add(self.env.hostname, 'hostname', clr, fixed=True) + bar.add(':', 'hostname', clr, fixed=True) - for path in self.env.pathway: + pathway = self.env.pathway + if self.settings.tilde_in_titlebar and \ + self.fm.env.cwd.path.startswith(self.env.home_path): + pathway = pathway[self.env.home_path.count('/')+1:] + bar.add('~/', 'directory', fixed=True) + + for path in pathway: if path.islink: clr = 'link' else: clr = 'directory' - bar.add(path.basename, clr) - bar.add('/', clr, fixedsize=True) + bar.add(path.basename, clr, directory=path) + bar.add('/', clr, fixed=True, directory=path) if self.env.cf is not None: - bar.add(self.env.cf.basename, 'file', fixedsize=True) + bar.add(self.env.cf.basename, 'file', fixed=True) def _get_right_part(self, bar): kb = str(self.env.keybuffer) self.old_keybuffer = kb - bar.addright(kb, 'keybuffer', fixedsize=True) - bar.addright(' ', 'space', fixedsize=True) + bar.addright(kb, 'keybuffer', fixed=True) + bar.addright(' ', 'space', fixed=True) self.tab_width = 0 if len(self.fm.tabs) > 1: for tabname in self.fm._get_tab_list(): self.tab_width += len(str(tabname)) + 1 clr = 'good' if tabname == self.fm.current_tab else 'bad' - bar.addright(' '+str(tabname), 'tab', clr, fixedsize=True) + bar.addright(' '+str(tabname), 'tab', clr, fixed=True) def _print_result(self, result): import _curses diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py index c5544a47..692d06d2 100644 --- a/ranger/shared/settings.py +++ b/ranger/shared/settings.py @@ -34,6 +34,7 @@ ALLOWED_SETTINGS = { 'sort_directories_first': bool, 'update_title': bool, 'shorten_title': int, # Note: False is an instance of int + 'tilde_in_titlebar': bool, 'max_filesize_for_preview': (int, type(None)), 'max_history_size': (int, type(None)), 'scroll_offset': int, |