summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-10-04 21:52:46 +0200
committerhut <hut@lavabit.com>2010-10-04 21:52:46 +0200
commit70cd83bb27d6b4a3236af0f2c922fb1975af342a (patch)
treeb8cd80cf5a91377987db668121c8c0a7fc78a553
parentb514d28d25e24c674058342e61bd6678ba24c21f (diff)
downloadranger-70cd83bb27d6b4a3236af0f2c922fb1975af342a.tar.gz
gui.widgets.titlebar: truncate dirnames in tab titles
-rw-r--r--ranger/gui/widgets/titlebar.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py
index fc2b9dae..d87a0803 100644
--- a/ranger/gui/widgets/titlebar.py
+++ b/ranger/gui/widgets/titlebar.py
@@ -144,10 +144,16 @@ class TitleBar(Widget):
 				bar.addright(tabtext, 'tab', clr, fixed=True)
 
 	def _get_tab_text(self, tabname):
+		result = ' ' + str(tabname)
 		if self.settings.dirname_in_tabs:
-			return ' ' + str(tabname) + ":" + (basename(self.fm.tabs[tabname]) or '/')
-		else:
-			return ' ' + str(tabname)
+			dirname = basename(self.fm.tabs[tabname])
+			if not dirname:
+				result += ":/"
+			elif len(dirname) > 15:
+				result += ":" + dirname[:14] + "~"
+			else:
+				result += ":" + dirname
+		return result
 
 	def _print_result(self, result):
 		self.win.move(0, 0)