Not straightforward, as we use copy on write file interface in a separate process to protect Sigil from plugin errors. In addition, internally everything Qt is encoded as utf-16 with no carriage returns, but the files themselves utf-8 encoded and carriage returns are included but only on Windows. And finally, each xhtml parser treats DOM building and especially how whitespace and text is handled differently making cfi and path approaches incorrect as well.
So even something simple such as a cursor position is in a Qt based QPlainTextEdit internal to Sigil is hard to translate to a utf-8 encoded file with platform specific line endings, tab expansions, etc, being parsed by a different xhtml parser.
So using a marker such as an inserted comment, class or id, is the most reliable way to handle cursor/text marking in xhtml that works cross platform across file formats.
Furthermore, there is very little simple text manipulation that can not be handled internal to Sigil using Regular Expressions, clips, Saved Searches, etc.
Quote:
Originally Posted by AxaRu
Yes. This good way.
I think if you adds to API class like cursor you will get more interactivity in plugins.
|