commit 18c2dba9b879c472792246f24d85825c7999b6ed
parent ff964df8ea30517b02bb795ec58d612dfb2e3294
Author: ThomasV <thomasv1@gmx.de>
Date: Tue, 5 Nov 2013 00:52:34 -0800
Merge pull request #358 from mkramlich/master
fix for issue 356: unicode labels cause the text/curses UI to crash
Diffstat:
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,8 +1,13 @@
####-*.patch
lib/icons_rc.py
*.pyc
+*.swp
build/
dist/
*.egg/
/electrum.py
contrib/pyinstaller/
+Electrum.egg-info/
+gui/qt/icons_rc.py
+locale/
+.devlocaltmp/
diff --git a/gui/text.py b/gui/text.py
@@ -1,4 +1,4 @@
-import curses, datetime
+import curses, datetime, locale
from decimal import Decimal
_ = lambda x:x
#from i18n import _
@@ -24,6 +24,9 @@ class ElectrumGui:
self.wallet = Wallet(storage)
self.wallet.start_threads(network)
+ locale.setlocale(locale.LC_ALL, '')
+ self.encoding = locale.getpreferredencoding()
+
self.stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
@@ -54,7 +57,7 @@ class ElectrumGui:
self.network.register_callback('disconnecting', self.refresh)
self.tab_names = [_("History"), _("Send"), _("Receive"), _("Contacts"), _("Wall")]
self.num_tabs = len(self.tab_names)
-
+
def set_cursor(self, x):
try:
@@ -140,8 +143,9 @@ class ElectrumGui:
self.print_list(messages, "%19s %25s "%("Address", "Label"))
def print_receive(self):
- messages = map(lambda addr: "%30s %30s "%(addr, self.wallet.labels.get(addr,"")), self.wallet.addresses())
- self.print_list(messages, "%19s %25s "%("Address", "Label"))
+ fmt = "%-35s %-30s"
+ messages = map(lambda addr: fmt % (addr, self.wallet.labels.get(addr,"")), self.wallet.addresses())
+ self.print_list(messages, fmt % ("Address", "Label"))
def print_edit_line(self, y, label, text, index, size):
text += " "*(size - len(text) )
@@ -160,7 +164,6 @@ class ElectrumGui:
def print_banner(self):
self.print_list( self.network.banner.split('\n'))
-
def print_list(self, list, firstline = None):
self.maxpos = len(list)
if not self.maxpos: return
@@ -170,7 +173,9 @@ class ElectrumGui:
for i in range(self.maxy-4):
msg = list[i] if i < len(list) else ""
msg += " "*(self.maxx - 2 - len(msg))
- self.stdscr.addstr( i+2, 1, msg[0:self.maxx - 2], curses.A_REVERSE if i == (self.pos % self.maxpos) else 0)
+ m = msg[0:self.maxx - 2]
+ m = m.encode(self.encoding)
+ self.stdscr.addstr( i+2, 1, m, curses.A_REVERSE if i == (self.pos % self.maxpos) else 0)
def refresh(self):
if self.tab == -1: return