Follow up: Mantis 0022711: Syntax highlighting: Types should have different colo lazarus / 9-Editor ---------------------------------------------------------------------- Martin_fr · 2012-08-25 23:28 Moving discussion from the issue tracker: http://bugs.freepascal.org/view.php?id=22711 ---------------------------------------------------------------------- Martin_fr · 2012-08-25 23:33 Earlier I wrote in private mail as background for the mentioned issue: Code Explorer, uses codetools. The highlighter does not. Speed reasons: - The highlighter may have to scan between 1 or 2 (usual) and many 1000 lines (rare) on each keystroke. (And it is invoked on each character that changes)   [You can notice this, if you edit a pascal file with 300000 lines, and add a "(**" on the top. There will be a noticable delay before the 2nd "*"] - Codetool is not invoked on each keystroke. The Code Explorer, only updates on Idle (press and hold a key, and you may see that the code explorer is not showing each change) Sure the highlighting can be changed to a similar way. But that is a lot of work. As for try and find some: Sorry, but no. The highlight should be consistent. With $Include code can also be spread over many files, and the procedure header, may not be close to the implementation... It would be hard to explain, and misleading, why a type is sometimes highlighted, sometimes not. This is not a final "no", it is just a will not be done soon. It is also slightly more complex, because the above only refers to "the highlighter" while in fact highlighting is done by a combination of several modules... ---------------------------------------------------------------------- Martin_fr · 2012-08-25 23:35 QuoteIndependent parser would be great for one one reason: In fact the IDE has several independent scanners: 1) Codetools 2) highlighter 2a) several markup parts 3) Jedi code formatter They are optimized for different purposes. ---------------------------------------------------------------------- zex2011 · 2012-09-05 15:39 Ok, but presently highlighter already shows some types in bold. For example "string" and "utf8string". Would it be possible to add custom list of keywords to that? For example, to add a special group "Custom Keywords" under Options => IDE => Display => Colors. Inside that group one could manually add custom words and highlight style (same as for breakpoint or comment). So custom words will be painted in custom style. That way the highlighter stays the same, only the list of keywords is extended with custom words. And I'm pretty sure that "integer", "real" and "boolean" would be the most popular custom keywords ---------------------------------------------------------------------- Martin_fr · 2012-09-05 16:02 Quote from: zex2011 on September 05, 2012, 05:39:36 pmOk, but presently highlighter already shows some types in bold. For example "string" and "utf8string". Would it be possible to add custom list of keywords to that? For example, to add a special group "Custom Keywords" under Options => IDE => Display => Colors That is indeed possible, and has been on my list for quite a while now. (I do want this myself). And it is much easier, then auto-detecting identifiers that are a keyword. Though I can't tell you when I will actually start. I was hoping it would be one of my next things, but a couple of other issues came up... ---------------------------------------------------------------------- zex2011 · 2012-09-10 18:08 That would be nice. ---------------------------------------------------------------------- Martin_fr · 2012-09-10 18:26 Quote from: zex2011 on September 05, 2012, 05:39:36 pmOk, but presently highlighter already shows some types in bold. For example "string" and "utf8string". Btw "string" is a keyword. so it can not be used as identifier in other places. e.g. you can NOT have a variable called "string" "utf8string" (same for "AnsiString") is not a keyword. Therefore the IDE actually has an option, you can turn it off. Because the following is valid code: Code: [Select]var    utf8string: string;   ansistring: string; And if enabled, then those variables are highlighted too. Ansistring may be a poor example, as it is unlikely to be used this way. utf8string may very well be. Other types can suffer the same fate. But as already indicated. With custom word lists, everyone would be able to make their own decision. ---------------------------------------------------------------------- Martin_fr · 2013-02-20 22:32 Lazarus 1.1 now has "user defined words" that can be highlighted. So you can create a list with words like: Integer, boolean, byte, ... and make them display bold. However, this is not a context sensitive highlighter. So this words will also get highlighted in strings and comments. ---------------------------------------------------------------------- Blaazen · 2013-02-20 23:26 OK, works but I can have only one word in list. I created list "MyList". How can I add more words to it (I mean inside Options Dialog)? Thanks. Anyway, it is a good feature. I'm pretty sure I'll find some usage for it. EDIT: I assigned shortcut for adding words to list (Ctrl+Shift+A) and it works (words become bold in Source Editor) but these words still do not appear it the list in Option Dialog -> Editor -> Display -> User Defined MarkUp. EDIT2: It remember only one word when I restart Lazarus. Also, only one word is stored in editoroptions.xml. ---------------------------------------------------------------------- Martin_fr · 2013-02-20 23:45 What do you mean, you can have only one word? The grid should extend, if you press cursor down on the last line Adding by keyword is temporary, and only lasts for the session. I might make it permanent later, not sure. Same, if you use keys to disable (not remove) a word form the pre- configured list. It will be active again, after IDE restart @Edit1 They can't go into the same list. - Words in the options list are always *all* editors - Words by key, may be just the current editor. @Edit2 See above. Words by keyword are not (yet?) remembered ---------------------------------------------------------------------- Blaazen · 2013-02-20 23:54 If I understand well, each list can have (temporarily) only one word? ---------------------------------------------------------------------- Martin_fr · 2013-02-21 00:15 NO, each list can have - any amount of pre-defined words, - and any amount of key-added/session words. What happens if you press cursor down in the last row of the grid? (What widgetset?) ---------------------------------------------------------------------- Blaazen · 2013-02-21 00:33 @ What happens if you press cursor down in the last row of the grid? (What widgetset?) Oh yes, that's it.  I tried to click, right click (adding via context popup) or looking for some "Add Keyword" speed button. When I press down (and grid is not in editor mode) new line is added correctly. Thanks. ---------------------------------------------------------------------- Martin_fr · 2013-02-21 01:19 This is how the grids build in auto extend works... I realized only during this conversation, that this is not self explaining.