X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=mudpy%2Fmisc.py;h=3cd8e644c248e9a5fc8150b36ae5a0c41735615d;hp=439e00a6aeab779a25991672cf1ba82db0f43d6c;hb=b054ba768010f5a9b17f16c06f87d11ea98465e1;hpb=34d256939f22a5186b32d0628ed399e4b644e798 diff --git a/mudpy/misc.py b/mudpy/misc.py index 439e00a..3cd8e64 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -525,7 +525,7 @@ class User: self.output_queue = [] self.partial_input = b"" self.password_tries = 0 - self.state = "initial" + self.state = "telopt_negotiation" self.telopts = {} def quit(self): @@ -806,7 +806,7 @@ class User: self.check_idle() # if output is paused, decrement the counter - if self.state == "initial": + if self.state == "telopt_negotiation": if self.negotiation_pause: self.negotiation_pause -= 1 else: @@ -883,8 +883,8 @@ class User: line = line.strip() # log non-printable characters remaining - if mudpy.telnet.is_enabled(self, mudpy.telnet.TELOPT_BINARY, - mudpy.telnet.HIM): + if not mudpy.telnet.is_enabled( + self, mudpy.telnet.TELOPT_BINARY, mudpy.telnet.HIM): asciiline = bytes([x for x in line if 32 <= x <= 126]) if line != asciiline: logline = "Non-ASCII characters from " @@ -1143,18 +1143,17 @@ def wrap_ansi_text(text, width): # escape sequence escape = False - # track the most recent whitespace we've seen - # TODO(fungi) exclude non-breaking spaces (\x0a) - elif unicodedata.category(each_character) in ("Cc", "Zs"): - if each_character == "\n": - # the current character is a newline, so reset the relative - # position too (start a new line) - rel_pos = 0 - if each_character != "\r": - # the current character is not a carriage return, so mark it as - # whitespace (we don't want to break and wrap between CR+LF) - last_abs_whitespace = abs_pos - last_rel_whitespace = rel_pos + # the current character is a space + elif each_character == " ": + last_abs_whitespace = abs_pos + last_rel_whitespace = rel_pos + + # the current character is a newline, so reset the relative + # position too (start a new line) + elif each_character == "\n": + rel_pos = 0 + last_abs_whitespace = abs_pos + last_rel_whitespace = rel_pos # the current character meets the requested maximum line width, so we # need to wrap unless the current word is wider than the terminal (in @@ -1180,8 +1179,7 @@ def wrap_ansi_text(text, width): # printable character elif each_character != "\r": rel_pos += glyph_columns(each_character) - if unicodedata.category(each_character) in ("Cc", "Zs"): - # TODO(fungi) exclude non-breaking spaces (\x0a) + if each_character in (" ", "\n"): last_abs_whitespace = abs_pos last_rel_whitespace = rel_pos