Adds function Text.selection_set() so it's possible to set text selection through python api.
Function takes four arguments: start line, start character, end line, end character
import bpy text = bpy.context.space_data.text endl = 2 endc = 10 text.selection_set(0, 0, endl, endc)
selects all text from the beginning of line 1 to the 10th character at line 3.
Reverse selection also possible.
Added checks to ensure given range is valid. Line lengths are measured using BLI_strlen_utf8.
When a char index passed is lower than 0, the rna function automatically clamps at 0.
When a char index passed is higher than the length of a line, clamp at line length.