If the title string is too big then xtermTitle() can
authorZac Medico <zmedico@gentoo.org>
Fri, 2 Nov 2007 05:15:35 +0000 (05:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 2 Nov 2007 05:15:35 +0000 (05:15 -0000)
misbehave by causing the terminal to echo some of the
characters and generate a "beep" sound. (trunk r8289)

svn path=/main/branches/2.1.2/; revision=8363

pym/output.py

index 08e4d84011f9c2dab8e79013bc570f2b0c899728..f59609ee7f44d9652a97f307db92b5471a8f4211 100644 (file)
@@ -231,6 +231,11 @@ def nc_len(mystr):
 
 def xtermTitle(mystr, raw=False):
        if dotitles and "TERM" in os.environ and sys.stderr.isatty():
+               # If the title string is too big then the terminal can
+               # misbehave. Therefore, truncate it if it's too big.
+               max_len = 253
+               if len(mystr) > max_len:
+                       mystr = mystr[:max_len]
                myt=os.environ["TERM"]
                legal_terms = ["xterm","Eterm","aterm","rxvt","screen","kterm","rxvt-unicode","gnome"]
                for term in legal_terms: