[Bf-committers] Python access to the cursor in the text editor

Jacques Lucke mail at jlucke.com
Sun Dec 7 12:18:47 CET 2014


 

Hi, 

I'm currently working on a Auto-Completion Addon for the text editor in
Blender: 

https://www.youtube.com/watch?v=tfpHcKhFw_8&list=UU5ABAuGEvBMmau-1xJsNw6w


There are two main thinks which are kind of hacky at the moment. 

1. Currently I set the cursor position by inserting a special string and
then search-replace it with the normal operators. It would be great if
we could set the cursor position directly via python. Atm you can only
set the 'current_line_index', but 'current_character' is readonly. 

http://www.blender.org/api/blender_python_api_2_71_release/bpy.types.Text.html


2. Another problem I had to solve is how I can get the cursor position
in pixels. Currently I'm calculating this position based on several
properties (visible_lines, top, current_line_index, current_character,
region.width/height). I don't know if this is possible, but it would
make it much cleaner if there would be another way to do this. 

Maybe there is someone who can do this. As you can see it works even
without these options I wish for, but it would be so much cleaner. :) 

Thanks in advance
Jacques Lucke 
 


More information about the Bf-committers mailing list