code: def applyCommand(self):
          cursor      = self.textCursor()
          cursor.movePosition(cursor.EndOfLine)
          line        = projex.text.nativestring(cursor.block().text())
          at_end      = cursor.atEnd()
          modifiers   = QApplication.instance().keyboardModifiers()
          mod_mode    = at_end or modifiers == Qt.ShiftModifier
          if mod_mode and line.endswith(':'):
              cursor.movePosition(cursor.EndOfLine)
              line = re.sub('^>>> ', '', line)
              line = re.sub('^\.\.\. ', '', line)
              count = len(line) - len(line.lstrip()) + 4
              self.insertPlainText('\n... ' + count * ' ')
              return False
          elif mod_mode and line.startswith('...') and \
              (line.strip() != '...' or not at_end):
              cursor.movePosition(cursor.EndOfLine)
              line = re.sub('^\.\.\. ', '', line)
              count = len(line) - len(line.lstrip())
              self.insertPlainText('\n... ' + count * ' ')
              return False
          elif line.startswith('>>>') or line.startswith('...'):
              line = projex.text.nativestring(cursor.block().text())
              while line.startswith('...'):
                  cursor.movePosition(cursor.PreviousBlock)
                  line = projex.text.nativestring(cursor.block().text())
              cursor.movePosition(cursor.EndOfLine)
              line = projex.text.nativestring(cursor.block().text())
              ended = False
              lines = []
              while True:
                  lines.append(line)
                  if cursor.atEnd():
                      ended = True
                      break
                  cursor.movePosition(cursor.NextBlock)
                  cursor.movePosition(cursor.EndOfLine)
                  line = projex.text.nativestring(cursor.block().text())
                  if not line.startswith('...'):
                      break
              command = '\n'.join(lines)
              if not (ended and command):
                  self.waitForInput()
                  self.insertPlainText(command.replace('>>> ', ''))
                  cursor.movePosition(cursor.End)
                  return False
          else:
              self.waitForInput()
              return False
          self.executeCommand(command)
          return True