code: def write(self, text):
          
          escape_parts = re.compile('\x01?\x1b\\[([0-9;]*)m\x02?')
          chunks = escape_parts.split(text)
          i = 0
          for chunk in chunks:
              if chunk != '':
                  if i % 2 == 0:
                      self.stream.write(chunk)
                  else:
                      c = chunk.split(';')
                      r = Magic.rdisplay(c)
                      self.display(**r) #see caveat 0
                  self.flush()
              i += 1
docs: Parses text and prints proper output to the terminal
          
          This method will extract escape codes from the text and
          handle them as well as possible for whichever platform
          is being used. At the moment only the display escape codes
          are supported.