Text editor API needs a 'select_end_line_index' attribute to expose selection to the user. #66317

Closed
opened 2019-07-01 22:51:25 +02:00 by Samuel Bernou · 7 comments
Member

Hi,

As reported in this BA thread
There's one attribute missing to be able to perform actions relative to a multiline selection.

Here is the attibute list :

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 (but no index accessible)

!! MISSING !! >> select_end_line_index (impossible to know where the selection end)

Maybe I missed a way to get the selection directly ? (so we can count the '\n' as a workaround without using 'bpy.ops.text.copy()' that overwrite clipboard)

PS : I did not know who to assign so I chose you Jacques since you wrote code-autocomplete and should be familliar with text editor, I'm sorry if you're not the right guy to bother.

Hi, As reported in [this BA thread ](https://blenderartists.org/t/get-set-character-and-line-coordinate-of-the-selection-in-the-text-editor/1166728) There's one attribute missing to be able to perform actions relative to a multiline selection. Here is the attibute list : ``` 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 (but no index accessible) !! MISSING !! >> select_end_line_index (impossible to know where the selection end) ``` Maybe I missed a way to get the selection directly ? (so we can count the '\n' as a workaround without using 'bpy.ops.text.copy()' that overwrite clipboard) PS : I did not know who to assign so I chose you Jacques since you wrote code-autocomplete and should be familliar with text editor, I'm sorry if you're not the right guy to bother.
Jacques Lucke was assigned by Samuel Bernou 2019-07-01 22:51:25 +02:00
Author
Member

Added subscribers: @Pullup, @antoniov

Added subscribers: @Pullup, @antoniov

Added subscriber: @dfelinto

Added subscriber: @dfelinto

I have an old addon (which is outdated) that was handling text selection with no problems:
https://developer.blender.org/diffusion/BAC/browse/master/text_editor_hastebin.py

I have an old addon (which is outdated) that was handling text selection with no problems: https://developer.blender.org/diffusion/BAC/browse/master/text_editor_hastebin.py
Author
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author
Member

Nice !
I didn't thought to compare line object itself against select_end_line.
Someone also gave me this solution on BA thread "Get / set character and line coordinate of the selection in the text editor" .
Thanks for the digging.

Nice ! I didn't thought to compare line object itself against select_end_line. Someone also gave me this solution on [BA thread "Get / set character and line coordinate of the selection in the text editor" ](https://blenderartists.org/t/get-set-character-and-line-coordinate-of-the-selection-in-the-text-editor/1166728/2). Thanks for the digging.

Added subscriber: @zgorg

Added subscriber: @zgorg

This comment was removed by @zgorg

*This comment was removed by @zgorg*
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#66317
No description provided.