If the title string is too big then xtermTitle() can
authorZac Medico <zmedico@gentoo.org>
Thu, 25 Oct 2007 05:57:32 +0000 (05:57 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 25 Oct 2007 05:57:32 +0000 (05:57 -0000)
misbehave by causing the terminal to echo some of the
characters and generate a "beep" sound. This is easily
triggered by doing things like `emerge world` now since
all the the atoms are expanded.

svn path=/main/trunk/; revision=8289

pym/portage/output.py

index f4e90fb8e06ed0692af087c9d95304539486a9a7..ff3e27171c06f44a8ec2543757223449453bbf24 100644 (file)
@@ -236,6 +236,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: