I use SCI_GETFIRSTVISIBLELINE of Scintilla in order to get the first displayed line of the document.
Now, I enabled word wrapping mode by setting SCI_SETWRAPMODE to SC_WRAP_WORD. But SCI_GETFIRSTVISIBLELINE does not match the document line any more.
Is there a way to get the first displayed document line (also, how to know if the displayed line is part of a wrapped line)? Scintilla itself knows it, as the correct line number is displayed before the text (when enabling SC_MARGIN_NUMBER).
Update: The first document line of the visible line can be get by calling SCI_DOCLINEFROMVISIBLE with the result of SCI_GETFIRSTVISIBLELINE. However, detecting partial lines is still a problem.
The corresponding document line of first visible line can be get by calling SCI_DOCLINEFROMVISIBLE with the result of SCI_GETFIRSTVISIBLELINE: DOCLINEFROMVISIBLE(GETFIRSTVISIBLELINE())
The second part is a bit more tricky and seems a bit hacky to me:
First, I call SCI_WRAPCOUNT with the document line number of the first line and get the number of rows this line uses. If SCI_WRAPCOUNT()>1 it's a candidate for a partial line. The number of skipped lines can be calculated with SCI_DOCLINEFROMVISIBLE(SCI_GETFIRSTVISIBLELINE() + SCI_WRAPCOUNT() - 1) - SCI_DOCLINEFROMVISIBLE(SCI_GETFIRSTVISIBLELINE()).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With