'Return text between *position_from* and *position_to*
Positions may be positions or \'sol\', \'eol\', \'sof\', \'eof\' or \'cursor\''

def get_text(self, position_from, position_to):

    cursor = self.__select_text(position_from, position_to)
    text = to_text_string(cursor.selectedText())
    all_text = ((position_from == 'sof') and (position_to == 'eof'))
    if (text and (not all_text)):
        while text.endswith('\n'):
            text = text[:(-1)]
        while text.endswith(u'\u2029'):
            text = text[:(-1)]
    return text
