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

Martin Felke martin.felke at t-online.de
Wed Dec 17 13:37:11 CET 2014

Am Sonntag, den 07.12.2014, 12:18 +0100 schrieb Jacques Lucke:

> 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. :) 

Hi, back in 2012 i made a small C patch to expose the cursor position in
pixels to python. I have updated it today for 2.72+ and opened a patch
task also:


I did this because i worked at an own autocompleter addon back then, and
wanted to draw its bgl Menu near the cursor position. And as I type, the
menu keeps moving with the cursor position then.

Here you can find that addon: 



More information about the Bf-committers mailing list