ktexteditor and syntax-highlighting porting
dhaumann at kde.org
Sun Jul 29 08:53:13 BST 2018
KDEPIM also uses the syntax hl framworks.
But I think this will not help.
Reading the docs and source code:
- the Format ID is unique per Repository and valid as long as the
Repository is not reloaded
- the Format IDs are NOT saved by the Repository, so a map from ALL
IDs to Formats does not exist
- the Format is saved in the DefinitionData class, which essentially
is the data holder class of Definition
- the DefinitionData class holds a QHash<QString, Format> formats; but
no id -> Format hash
What we can add:
1. QHash<uint16_t, Format> Definition::formatHash() const;
2. Format Definition::format(uint16_t) const;
3. QHash<uint16_t, Format> Repository::formatHash() const;
4. Format Repository::format(uint16_t) const;
What are our use cases?
a) print syntax guide (we need all itemDatas)
b) syntax highlighting (your case)
For a) printing the syntax guide, I think 1+2 would be useful
For b) syntax highlighting, the full hash is probably easier: 3+4
Adding these functions is not much work, any opinions?
Shall I create a review request so we can discuss on code level?
@Volker: Any comments from your side? ;)
On Sat, Jul 28, 2018 at 7:33 PM, Dr.-Ing. Christoph Cullmann
<cullmann at absint.com> wrote:
> after some years, I guess it is really time that we port our highlighting to the infrastructure
> Volker provides.
> I started an "syntax-highlighting" branch in our ktexteditor.git to do so.
> Thought I already have some questions:
> 1) The format provides an "id" to store them nicely in our textlines, but how do I get a format back for a given id?
> Shall one hash them on the fly with the ids?
> Actually it would be more nice to have some vector with all known formats for a highlighting definition.
> That would make porting easier, too, as ATM we hold such an "attribute" list per highlighting.
> (if that is wrong, Dominik can correct me)
> 2) Is there a way to get the default style for a format? Would be needed to map them to the KTextEditor default styles
> (which are 1:1 as the ones in syntax-highlighting beside a swap of errors/others)
> ----------------------------- Dr.-Ing. Christoph Cullmann ---------
> AbsInt Angewandte Informatik GmbH Email: cullmann at AbsInt.com
> Science Park 1 Tel: +49-681-38360-22
> 66123 Saarbrücken Fax: +49-681-38360-20
> GERMANY WWW: http://www.AbsInt.com
> Geschäftsführung: Dr.-Ing. Christian Ferdinand
> Eingetragen im Handelsregister des Amtsgerichts Saarbrücken, HRB 11234
More information about the KWrite-Devel