I want to insert some text according to a multiline selection in the text editor .
There are some handy attribute that could help, but there’s a critical one missing ! (maybe I dont see something obvious…)
Here is a list if these attributes (in a text datablock
current_character # character position (at selection character start) current_line # line object where cursor is (at selection start) current_line_index # index where cursor is (at selection start) select_end_character # character position at selection end select_end_line # line object where selection end #!! MISSING !! : select_end_line_index (impossible to know where the selection end !)
So it’s Impossible to determine where the selection has stopped at line level.
The only super ugly workaround I see is using bpy.ops.text.copy() and count the ‘\n’ in the clipboard to know how many line were selected…
Is there another way to get this ?
Also, is there a way to set cursor position on line and character ?
current_character and such are read_only and the only things I found is moving to the very start/end of line with some ops (
bpy.ops.text.move(override, type='LINE_END') but not at specific character position.
Thank you for your attention.