summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-13 12:19:10 +0200
committerhut <hut@lavabit.com>2010-04-13 12:19:10 +0200
commit465dd890060c96f2ff8badd46a9f7fb75d29fc68 (patch)
tree6d4a8878e90cca498faff09691e7d77dfeb927fe
parent12ddb42454baf3dbe620d2f6c13d6c0f0ce83423 (diff)
downloadranger-465dd890060c96f2ff8badd46a9f7fb75d29fc68.tar.gz
Abbreviate HOME with ~ in the titlebar
-rw-r--r--ranger/defaults/options.py3
-rw-r--r--ranger/gui/bar.py4
-rw-r--r--ranger/gui/widgets/titlebar.py15
-rw-r--r--ranger/shared/settings.py1
4 files changed, 18 insertions, 5 deletions
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index 46723aa8..0593bae3 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/gui/bar.py b/ranger/gui/bar.py
index c06a201e..0ef840a4 100644
--- a/ranger/gui/bar.py
+++ b/ranger/gui/bar.py
@@ -95,8 +95,10 @@ class BarSide(list):
 
 	def add(self, string, *lst, **kw):
 		cs = ColoredString(string, self.base_color_tag, *lst)
+		cs.__dict__.update(kw)
 		if 'fixedsize' in kw:
-			cs.fixed = kw['fixedsize']
+			kw['fixed'] = kw['fixedsize']
+			del kw['fixedsize']
 		self.append(cs)
 
 	def add_space(self, n=1):
diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py
index 62740e2d..ddcd03c3 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
@@ -109,15 +109,22 @@ class TitleBar(Widget):
 		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(':', 'hostname', clr, fixedsize=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', fixedsize=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, fixedsize=True, directory=path)
 
 		if self.env.cf is not None:
 			bar.add(self.env.cf.basename, 'file', fixedsize=True)
diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py
index ebbe12c7..01d4caf6 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,