- AuthorPosts
- February 15, 2007 at 11:10 pm #4185NazgulledParticipant
I’m creating a syntax highlighting file for some language that EmEditor is missing, Haskell, but I’m having some problems highlighting words the way I want.
I have the following rules for color 4 and 5:
; Standard prelude classes
#Keyword color=4,word=on,rightall=off,case=on,insidetag=off,regexp=off
Bounded
Enum
(...); Standard prelude constructors
#Keyword color=5,word=on,rightall=off,case=on,insidetag=off,regexp=off
EQ
False
(...)And then I have the following regular expression for color 3:
; Custom data-types
#Keyword color=3,word=on,rightall=off,case=on,insidetag=off,regexp=on
[A-Z][A-Za-z0-9_]*And as you see, this regular expression will highlight all words starting with some uppercase letter followed by zero or more letters (uppercase or lowercase), numbers and the underscore. This regular expression is also highlighting the words that I have specified in the rules before it, Bounded, Enum, EQ and False (for instance, there’s more not listed here).
I tried to put this regular expression before these other rules, but it did not work… How can I fix this? I want to have some regular expression that colors text according to it’s rules but I also want to have some specific words, that happen to be matched by the regular expression, to have different colors.
How can I achieve this?
February 17, 2007 at 7:57 pm #4192NazgulledParticipantanyone? I would really love to have this fixed…
February 17, 2007 at 9:55 pm #4193CaptainFlintParticipantYutaka has explained somewhere that for highlighting he uses a mechanism that is very fast and effective but does not allow to prioritize the rules.
February 18, 2007 at 12:27 pm #4194NazgulledParticipantThat doesn’t sound right… There must be somehow to do it, not in EmEditor, but for future versions, I mean, for some reason that rule is taking precedence over others… So, it’s being applied after all the others. There must be a way to apply before, no? Why is it being applied after all others? Cause it’s a regexp? If so, then add an option to apply all regexps before or after all the others, that must be possible…
February 18, 2007 at 12:48 pm #4196CaptainFlintParticipantThere are many kinds of programmers’ tricks. For example, for extremely quick access to some data associated with some text, so-called hash-tables are used. They allow to find the specified line of text very quickly, without necessity of successive comparing it with every piece of text present in the table.
Now, let’s have an example: regexps could be stored in a kind of hash-table, and hence they could be accessed very quickly, without looking each of them one-by-one. If you add the possibility of setting priorities, you will have to look each and every of them, just to know if there is some other regexp that has higher priority. If there are many highlighting rules, this would become a very long task. Would you like EmEditor to wait for 10 seconds every time it has to redraw the screen? :)
Of course, I don’t know if Yutaka uses hash-tables for storing regexps, but anyway, it was just an illustrative example (and, besides, I won’t wonder if he really does).
February 18, 2007 at 5:27 pm #4197NazgulledParticipantI see, but if other apps can do it, than it is possible for EmEditor to do it also…
March 7, 2007 at 11:24 pm #4226VladMemberI want to have some regular expression that colors text according to it’s rules but I also want to have some specific words, that happen to be matched by the regular expression, to have different colors.
You can define “specific words, that happen to be matched by the regular expression” as regex words and put them after the regular expression that matches them. I once tried that with a Python syntax file that has >200 keywords. If they are all defined as regex, there is a noticeable screen redrawing, but the editor is still usable, which shows that the colorizer is extremely efficient.
I agree that it would be much more useful if the non-regex keywords were colorized _after_ regex keywords.
March 16, 2007 at 6:26 pm #4239NazgulledParticipantThanks, it worked as expected and it doesn’t seem to be slow as I don’t have that many words…
- AuthorPosts
- You must be logged in to reply to this topic.