'Redraw the screen.'

def refresh(self):

    redraw = ''
    for command in self.commandQueue:
        if (command[0] == 'gotoxy'):
            redraw += ('\x1b[%i;%iH' % ((command[2] + 1), (command[1] + 1)))
        elif (command[0] == 'write'):
            redraw += command[1]
        elif (command[0] == 'eraseeol'):
            redraw += '\x1b[0K'
        elif (command[0] == 'eraseeos'):
            redraw += '\x1b[OJ'
        elif (command[0] == 'cls'):
            redraw += '\x1b[H\x1b[J'
        elif (command[0] == 'attributes'):
            redraw += ('\x1b[%sm' % ';'.join(map(str, command[1])))
        else:
            print(command)
    self.commandQueue = []
    self.transport.write(redraw)
