summaryrefslogtreecommitdiff
path: root/urwid/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'urwid/util.py')
-rw-r--r--urwid/util.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/urwid/util.py b/urwid/util.py
index f57c898..17c049d 100644
--- a/urwid/util.py
+++ b/urwid/util.py
@@ -41,6 +41,7 @@ within_double_byte = str_util.within_double_byte
def detect_encoding():
# Try to determine if using a supported double-byte encoding
import locale
+ initial = locale.getlocale()
try:
try:
locale.setlocale(locale.LC_ALL, "")
@@ -53,6 +54,8 @@ def detect_encoding():
return ""
else:
raise
+ finally:
+ locale.setlocale(locale.LC_ALL, initial)
if 'detected_encoding' not in locals():
detected_encoding = detect_encoding()
@@ -223,8 +226,8 @@ def trim_text_attr_cs( text, attr, cs, start_col, end_col ):
cstr = rle_subseg( cs, spos, epos )
if pad_left:
al = rle_get_at( attr, spos-1 )
- rle_append_beginning_modify( attrtr, (al, 1) )
- rle_append_beginning_modify( cstr, (None, 1) )
+ rle_prepend_modify( attrtr, (al, 1) )
+ rle_prepend_modify( cstr, (None, 1) )
if pad_right:
al = rle_get_at( attr, epos )
rle_append_modify( attrtr, (al, 1) )
@@ -283,7 +286,7 @@ def rle_len( rle ):
run += r
return run
-def rle_append_beginning_modify(rle, a_r):
+def rle_prepend_modify(rle, a_r):
"""
Append (a, r) (unpacked from *a_r*) to BEGINNING of rle.
Merge with first run when possible
@@ -298,7 +301,7 @@ def rle_append_beginning_modify(rle, a_r):
if a == al:
rle[0] = (a,run+r)
else:
- rle[0:0] = [(al, r)]
+ rle[0:0] = [(a, r)]
def rle_append_modify(rle, a_r):