Discussion:
SCI_POSITIONRELATIVE
Neil Hodgson
2013-08-20 05:58:55 UTC
Permalink
A new API, SCI_POSITIONRELATIVE, was implemented to optimize navigating by characters.

A document encoded in UTF-8 or DBCS may use multiple bytes for some characters. An application or platform may work with characters instead of bytes and there is a need to translate between the character-oriented view and Scintilla's byte-oriented view. For example, a compiler may report a warning for characters 12 to 18 inclusive on line 5. Previously, the SCI_POSITIONAFTER or SCI_POSITIONBEFORE methods could be called multiple times to navigate from the start of line 5 to character 12 on that line and then to (the end of) character 18. SCI_POSITIONRELATIVE avoids the loop and calling overhead.

Several platforms that Scintilla runs on use UTF-16 and treat non-BMP characters as 2 characters. It may simplify client code on these platforms to provide another API similar to SCI_POSITIONRELATIVE but which treats non-BMP characters as 2 characters to match the platform.

Here's an example interfacing to a spell checker that reports ranges in terms of UTF-16 code units where the non-BMP horse character 𐂃 confuses the position of the second mistake.



Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Mike Lischke
2013-08-20 06:58:08 UTC
Permalink
Hey Neil,
Post by Neil Hodgson
A new API, SCI_POSITIONRELATIVE, was implemented to optimize navigating by characters.
A document encoded in UTF-8 or DBCS may use multiple bytes for some characters. An application or platform may work with characters instead of bytes and there is a need to translate between the character-oriented view and Scintilla's byte-oriented view. For example, a compiler may report a warning for characters 12 to 18 inclusive on line 5. Previously, the SCI_POSITIONAFTER or SCI_POSITIONBEFORE methods could be called multiple times to navigate from the start of line 5 to character 12 on that line and then to (the end of) character 18. SCI_POSITIONRELATIVE avoids the loop and calling overhead.
Thanks for that new API. I can certainly use this to simply my code completion code. What I'd also appreciate is an API to convert text position <-> column/row pair (respecting tabs).

Mike
--
www.soft-gems.net
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2013-08-21 13:42:00 UTC
Permalink
Post by Mike Lischke
What I'd also appreciate is an API to convert text position <-> column/row pair (respecting tabs).
SCI_LINEFROMPOSITION, SCI_GETCOLUMN, SCI_FINDCOLUMN

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...