GNOME Bugzilla – Bug 343883
getcursorposition only suiteable for single line text
Last modified: 2009-01-19 19:46:18 UTC
if there is a multi-line text, the function only returns the column position of cursor, also need to return row position of cursor Other information:
The getcursorposition() function returns the position of the caret in the textbox, i.e. the characters before the caret position, it does not return the column or row numbers.
I think, this can be handled in the client itself using a function such as: def getcood(text, cursorpos): row = 1 col = 1 pos = 0 for char in text: if pos > cursorpos: break if char == '\n': row += 1 col = 1 elif char == '\t': col = ((col/8)+1)*8 col += 1 pos += 1 return row, col This will work in gedit for both word wrapping on and off (as reported by the status bar although text might appear on the next line)
*** Bug 350910 has been marked as a duplicate of this bug. ***
Alex: The suggestion from Prashanth worked for you ?
Closing this bug report as no further information has been provided. Please feel free to reopen this bug if you can provide the information asked for. Thanks!