about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-01 18:19:08 +0200
committerhut <hut@lavabit.com>2011-10-01 18:22:54 +0200
commit6110c8cc1bb26eaf8564976e796c301ce4ef4861 (patch)
tree44e9e63c1e9d8a5c2aa4b5385cf9ad4aa53e387f
parente421ce0877ba54c6efa832b5d4c98f95655fee03 (diff)
downloadranger-6110c8cc1bb26eaf8564976e796c301ce4ef4861.tar.gz
ext.widestring: Fixes
-rw-r--r--ranger/ext/widestring.py7
-rw-r--r--ranger/gui/bar.py10
2 files changed, 9 insertions, 8 deletions
diff --git a/ranger/ext/widestring.py b/ranger/ext/widestring.py
index cdb58719..28f38e54 100644
--- a/ranger/ext/widestring.py
+++ b/ranger/ext/widestring.py
@@ -21,6 +21,7 @@ PY3 = sys.version > '3'
 ASCIIONLY = set(chr(c) for c in range(1, 128))
 NARROW = 1
 WIDE = 2
+WIDE_SYMBOLS = set('WF')
 
 def uwid(string):
 	"""Return the width of a string"""
@@ -38,7 +39,7 @@ def uchars(string):
 
 def utf_char_width(string):
 	"""Return the width of a single character"""
-	if east_asian_width(string)[0] == 'W':
+	if east_asian_width(string) in WIDE_SYMBOLS:
 		return WIDE
 	return NARROW
 
@@ -51,13 +52,13 @@ def string_to_charlist(string):
 	if PY3:
 		for c in string:
 			result.append(c)
-			if east_asian_width(c)[0] == 'W':
+			if east_asian_width(c) in WIDE_SYMBOLS:
 				result.append('')
 	else:
 		string = string.decode('utf-8', 'ignore')
 		for c in string:
 			result.append(c.encode('utf-8'))
-			if east_asian_width(c)[0] == 'W':
+			if east_asian_width(c) in WIDE_SYMBOLS:
 				result.append('')
 	return result
 
diff --git a/ranger/gui/bar.py b/ranger/gui/bar.py
index 91ea99c1..f2b1571a 100644
--- a/ranger/gui/bar.py
+++ b/ranger/gui/bar.py
@@ -69,18 +69,18 @@ class Bar(object):
 			raise ValueError("Cannot shrink down to that size by cutting")
 		leftsize = self.left.sumsize()
 		rightsize = self.right.sumsize()
-		oversize = leftsize + rightsize - wid - 1
+		oversize = leftsize + rightsize - wid
 		if oversize <= 0:
 			return self.fill_gap(' ', wid, gapwidth=False)
 		nonfixed_items = self.left.nonfixed_items()
 
-		# Shrink items to a minimum size of 1 until there is enough room.
+		# Shrink items to a minimum size until there is enough room.
 		for item in self.left:
 			if not item.fixed:
 				itemlen = len(item)
-				if oversize > itemlen - 1:
-					item.cut_off_to(1)
-					oversize -= (itemlen - 1)
+				if oversize > itemlen - item.min_size:
+					item.cut_off_to(item.min_size)
+					oversize -= (itemlen - item.min_size)
 				else:
 					item.cut_off(oversize)
 					break