Fall-back for non-unicode terminals.

This commit is contained in:
Aldo Cortesi 2012-02-23 12:41:01 +13:00
parent 4f38b3a9c0
commit 3f6619ff59
1 changed files with 10 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import urwid import urwid
import urwid.util
from .. import utils from .. import utils
@ -82,10 +83,14 @@ def fcol(s, attr):
) )
) )
if urwid.util.detected_encoding:
SYMBOL_REPLAY = u"\u21ba"
SYMBOL_RETURN = u"\u2190"
else:
SYMBOL_REPLAY = u"[r]"
SYMBOL_RETURN = u"<-"
REPLAY_SYMBOL = u"\u21ba"
def format_flow(f, focus, extended=False, padding=2): def format_flow(f, focus, extended=False, padding=2):
pile = [] pile = []
@ -100,7 +105,7 @@ def format_flow(f, focus, extended=False, padding=2):
else: else:
req.append(fcol(">>" if focus else " ", "focus")) req.append(fcol(">>" if focus else " ", "focus"))
if f.request.is_replay(): if f.request.is_replay():
req.append(fcol(REPLAY_SYMBOL, "replay")) req.append(fcol(SYMBOL_REPLAY, "replay"))
req.append(fcol(f.request.method, "method")) req.append(fcol(f.request.method, "method"))
preamble = sum(i[1] for i in req) + len(req) -1 preamble = sum(i[1] for i in req) + len(req) -1
@ -124,11 +129,11 @@ def format_flow(f, focus, extended=False, padding=2):
) )
if f.response or f.error: if f.response or f.error:
resp.append(fcol(u"\u2190", "method")) resp.append(fcol(SYMBOL_RETURN, "method"))
if f.response: if f.response:
if f.response.is_replay(): if f.response.is_replay():
resp.append(fcol(REPLAY_SYMBOL, "replay")) resp.append(fcol(SYMBOL_REPLAY, "replay"))
if f.response.code in [200, 304]: if f.response.code in [200, 304]:
resp.append(fcol(f.response.code, "goodcode")) resp.append(fcol(f.response.code, "goodcode"))
else: else: