ktexteditor and syntax-highlighting porting
Dominik Haumann
dhaumann at kde.org
Sun Jul 29 08:53:13 BST 2018
Hi Christoph,
KDEPIM also uses the syntax hl framworks.
- https://phabricator.kde.org/D7672
- https://cgit.kde.org/kpimtextedit.git/commit/?id=c775ce3a438814f82cb1ba9c2c8671b9f5be08c4
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? ;)
Greetings
Dominik
On Sat, Jul 28, 2018 at 7:33 PM, Dr.-Ing. Christoph Cullmann
<cullmann at absint.com> wrote:
> Hi,
>
> 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.
>
> https://cgit.kde.org/ktexteditor.git/log/?h=syntax-highlighting
>
> ;=)
>
> 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)
>
> Greetings
> Christoph
>
> --
> ----------------------------- 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
mailing list