git » msnlib » commit 2e1849f

Don't allow lines longer than 1500 chars.

author Alberto Bertogli
2005-05-14 04:44:48 UTC
committer Alberto Bertogli
2005-05-14 04:44:48 UTC
parent 3b428eb87bf0427f778c2e6d236e4ba522f273c1

Don't allow lines longer than 1500 chars.
As the max length for a message is 1500, never allow lines longer than that.
Yes, it wastes a couple of bytes for the "m friend " or "r " beginning, but
if you're writing a message _that_ long, a couple of bytes won't make a
difference.

msn +12 -1

diff --git a/msn b/msn
index 923c238..d6840b4 100644
--- a/msn
+++ b/msn
@@ -794,7 +794,18 @@ def stdin_read():
 
 		else:						# normal
 			if not in_esc:
-				redraw_cli_cond(char)
+				# Never allow lines longer than 1500, since
+				# that's the max for a single message.
+				# Actually this calculates based on the whole
+				# buffer and not on just the message, but the
+				# code is nicer and 16 bytes won't make a
+				# difference.
+				if len(inbuf) > 1500:
+					inbuf = inbuf[:1500]
+					beep()
+					redraw_cli()
+				else:
+					redraw_cli_cond(char)
 				continue
 
 			# comes from a escape code