summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--README2
-rw-r--r--TODO2
-rw-r--r--doc/ranger.12
-rw-r--r--ranger/core/actions.py3
-rw-r--r--ranger/defaults/commands.py8
-rw-r--r--ranger/defaults/keys.py2
-rw-r--r--ranger/defaults/options.py3
-rw-r--r--ranger/ext/command_parser.py21
-rw-r--r--ranger/gui/bar.py9
-rw-r--r--ranger/gui/widgets/browserview.py2
-rw-r--r--ranger/gui/widgets/titlebar.py29
-rw-r--r--ranger/shared/settings.py1
12 files changed, 57 insertions, 27 deletions
diff --git a/README b/README
index 07837688..429aefa1 100644
--- a/README
+++ b/README
@@ -130,7 +130,7 @@ Tips
 Change the directory of your parent shell when you exit ranger:
 
 ranger() {
-    $(which ranger) $@ &&
+    command ranger $@ &&
     cd "$(grep \^\' ~/.ranger/bookmarks | cut -b3-)"
 }
 
diff --git a/TODO b/TODO
index d715c991..6be34f8c 100644
--- a/TODO
+++ b/TODO
@@ -49,7 +49,7 @@ General
    (X) #66  10/02/28  explain how colorschemes work
    (X) #70  10/03/14  mouse handler for titlebar
    (X) #71  10/03/21  previews: black/whitelist + read file
-   ( ) #79  10/04/08  tab number zero
+   (X) #79  10/04/08  tab number zero
    ( ) #80  10/04/08  when closing tabs, avoid gaps?
 
 
diff --git a/doc/ranger.1 b/doc/ranger.1
index 9e1ab5a0..6adaf43f 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -169,7 +169,7 @@ of your parent shell after exiting ranger:
 .nf
 
 ranger() {
-    $(which ranger) $@ &&
+    command ranger $@ &&
     cd "$(grep \\^\\' ~/.ranger/bookmarks | cut -b3-)"
 }
 .\"-----------------------------------------
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,