Hi all. ( Forgive my English )
I was looking about how to retrieve the position of the caret relative at it's current line ( not relative at the entire document ).
On the documentation, I spotted this words:
Editor.getCurLine() ? str
Retrieve the text of the line containing the caret. Returns the index of the caret on the line.
See Scintilla documentation for SCI_GETCURLINE
On this page:
So, this says that the method "returns the index of the caret on the line", but the function returns the text of the line.
Is there any way to acess the "index of the caret on the line" that this method "returns".
How this function returns 2 things ( 'returns' one thing and 'retrieves' another ).
Help, please. Thanks.
Unfortunately the documentation (and the code) for the scintilla wrapper are generated direct from the Scintilla interface file. The real API call does in fact return both (the string is an output parameter), but the python function only returns the text. To get the current line number:
current_line_number = editor.lineFromPosition(editor.getCurrentPos())
Hi Dave. Thank you for your attention.
The code posted by you is nice and helped me think, but it does not make exactly what I want. I don't want the number of the line with the caret, but the number of characters from the start of the line to the caret.
So, I did these options:
editor.getCurrentPos() - editor.positionFromLine( editor.lineFromPosition( editor.getCurrentPos() ))
posMemo = editor.getCurrentPos()
posLinha = editor.getCurrentPos()
editor.setCurrentPos( posMemo )
posMemo - posLinha
I found another reference to a 'retrieve and return' function.
Editor.getLine(line) ? str
Retrieve the contents of a line. Returns the length of the line.
It would be cool if this 2 values came in a ordered pair.
Thank you again! :)
Log in to post a comment.