X-Git-Url: https://mudpy.org/gitweb?a=blobdiff_plain;f=lib%2Fmudpy%2Fmisc.py;h=d8c863ab80032e103882c5163fdb545ba21c73cb;hb=c817b9432d6ac5512dc86a266ac033d3078fcdcc;hp=50d026924cf83302e0d39ff471a588730531a643;hpb=b28e214eea15030d747ea7f6ab241c8cf500d773;p=mudpy.git diff --git a/lib/mudpy/misc.py b/lib/mudpy/misc.py index 50d0269..d8c863a 100644 --- a/lib/mudpy/misc.py +++ b/lib/mudpy/misc.py @@ -800,15 +800,15 @@ class User: # and the ansi escape to return to normal text if not just_prompt and prepend_padding: if not self.output_queue \ - or not self.output_queue[-1].endswith("\r\n"): + or not self.output_queue[-1].endswith(b"\r\n"): output = "$(eol)" + output elif not self.output_queue[-1].endswith( - "\r\n\x1b[0m\r\n" + b"\r\n\x1b[0m\r\n" ) and not self.output_queue[-1].endswith( - "\r\n\r\n" + b"\r\n\r\n" ): output = "$(eol)" + output - output += eol + unichr(27) + "[0m" + output += eol + chr(27) + "[0m" # tack on a prompt if active if self.state == "active": @@ -1202,7 +1202,11 @@ def wrap_ansi_text(text, width): escape = False # normalize any potentially composited unicode before we count it - text = unicodedata.normalize("NFKC", text) + # TODO: remove this check after the switch to py3k + try: + text = unicodedata.normalize("NFKC", text) + except TypeError: + text = unicodedata.normalize("NFKC", unicode(text)) # iterate over each character from the begining of the text for each_character in text: @@ -1354,15 +1358,15 @@ def replace_macros(user, text, is_input=False): # a dict of replacement macros macros = { "eol": "\r\n", - "bld": unichr(27) + "[1m", - "nrm": unichr(27) + "[0m", - "blk": unichr(27) + "[30m", - "blu": unichr(27) + "[34m", - "cyn": unichr(27) + "[36m", - "grn": unichr(27) + "[32m", - "mgt": unichr(27) + "[35m", - "red": unichr(27) + "[31m", - "yel": unichr(27) + "[33m", + "bld": chr(27) + "[1m", + "nrm": chr(27) + "[0m", + "blk": chr(27) + "[30m", + "blu": chr(27) + "[34m", + "cyn": chr(27) + "[36m", + "grn": chr(27) + "[32m", + "mgt": chr(27) + "[35m", + "red": chr(27) + "[31m", + "yel": chr(27) + "[33m", } # add dynamic macros where possible