From kwrite-devel Sun Nov 13 13:00:06 2011 From: Dominik Haumann Date: Sun, 13 Nov 2011 13:00:06 +0000 To: kwrite-devel Subject: Re: Detailes needed for XML-plugin implementation Message-Id: <201111131400.06800.dhdev () gmx ! de> X-MARC-Message: https://marc.info/?l=kwrite-devel&m=132118928416779 On Saturday, 12. November 2011, Adrian Lungu wrote: > Now, that we will start the actual implementation, we'd like to ask you > some questions to make sure we go the right way: > > 1. We definitely don't want to write a new parser (it's very likely to be > buggy and slow). We saw that Kate's highlight uses "KateSyntaxDocument". > Would that be our best choice to find the XML-tags from a document? If > yes, is "katehighlight" the best example of KateSyntaxDocument's usage, > or is there something better? With regard to KateSyntaxDocument: The answer is clearly no. If you write a Kate plugin, you can only use the KTextEditor interfaces and the Kate Application interfaces. 1. KTextEditor interfaces - API docs online: http://api.kde.org/4.7-api/kdelibs-apidocs/interfaces/ktexteditor/html/index.html - in Kate git: ktexteditor/*.h The Kate Editor Component implements all the KTextEditor classes. And it also INTERNALLY has more classes / information. But from the (external) plugin view, there is no way to get to these information. In other words, a plugin does not know that a class KateSyntaxDocument exists (Similar: Plugins have no way to access your code folding classes, it's completely internal to the implementation). 2. Kate Application interfaces - in git: kate/interfaces/kate/*.h - online API documentation is not generated, unfortunately In other words, you use 2. to create a basic plugin framework. There are a log of plugins in kate/plugins/, even an example called helloworld (I do not know whether it works, though). So assume you have a basic plugin structure working. It appears in the plugin list and you can enable the plugin. Then you can start to add real code. > 2. For the XML document formatting : We saw that "plugin_katexmlcheck" > uses "xmllint" application. xmllint can be used to format an xml > document, too (using "--format" argument). What would be the best > choice: using xmllint or writing the code that does the format using the > parser (KateSyntaxDocument). It depends on what you want to do: If you want to reindent the code, this is one way. However, it's not so good as we then depend on xmllint (which is probably not available on Windows or so...). So writing a small parser shoudn't be too hard. On the other hand, this exists already in the XML Tool plugin, as far as I know, and that's also where I would add the code to do the highlighting and so on (folder: kate/plugins/xmltools/). Hope that helps, Dominik _______________________________________________ KWrite-Devel mailing list KWrite-Devel@kde.org https://mail.kde.org/mailman/listinfo/kwrite-devel