'Block comment current line or selection.'

def blockcomment(self):

    comline = (self.__blockcomment_bar() + self.get_line_separator())
    cursor = self.textCursor()
    if self.has_selected_text():
        self.extend_selection_to_complete_lines()
        (start_pos, end_pos) = (cursor.selectionStart(), cursor.selectionEnd())
    else:
        start_pos = end_pos = cursor.position()
    cursor.beginEditBlock()
    cursor.setPosition(start_pos)
    cursor.movePosition(QTextCursor.StartOfBlock)
    while (cursor.position() <= end_pos):
        cursor.insertText((self.comment_string + '    '))
        cursor.movePosition(QTextCursor.EndOfBlock)
        if cursor.atEnd():
            break
        cursor.movePosition(QTextCursor.NextBlock)
        end_pos += len((self.comment_string + '    '))
    cursor.setPosition(end_pos)
    cursor.movePosition(QTextCursor.EndOfBlock)
    if cursor.atEnd():
        cursor.insertText(self.get_line_separator())
    else:
        cursor.movePosition(QTextCursor.NextBlock)
    cursor.insertText(comline)
    cursor.setPosition(start_pos)
    cursor.movePosition(QTextCursor.StartOfBlock)
    cursor.insertText(comline)
    cursor.endEditBlock()
