Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIFF highlighting (feature request) #90

Open
balthisar opened this issue Dec 7, 2015 · 1 comment
Open

DIFF highlighting (feature request) #90

balthisar opened this issue Dec 7, 2015 · 1 comment

Comments

@balthisar
Copy link

I'll look into this myself, too, as I have some time but I wanted to capture it here for discussion.

Currently SMLSyntaxColouringDelegate offers delegates for syntax groups allowing applications to customize the coloring of groups (i.e., the attributes, strings, etc.). However a line-by-line delegate method would be useful, too. Although I have in mind the specific case of highlighting diff results, I'm sure other line-based custom highlighting cases can be found.

Adding to the existing delegate seems like the logical place and would allow the application to pass back a block providing any arbitrary styling desired for the line while keeping Fragaria light-weight.

(Alternatively it could be handled similar to the error icons with a dedicated delegate, but this might limit the styling that can be applied without making Fragaria too heavy in an effort to be universal.)

Something like:

fragariaDocument:shouldColorLine:withBlock:
and
fragariaDocument:didColourLine:withBlock

I've not worked with Fragaria's internals since early this year so I don't know how aware the syntax highlighter is of individual lines. It's something I will dig into when I have a chance unless someone beats me to it.

@shysaur
Copy link
Owner

shysaur commented Dec 7, 2015

Fragaria's syntax highlighter is a mess, and I am seriously considering a total rewrite of it, but real life is getting in the way, and I keep thinking about it without actually coding anything.

How it works is, in pseudocode:

  for each syntax color (coloring group):
      match some regular patterns on a range of text, and color the matches.

Since you can't parse almost anything serious with regular expressions alone, each coloring group has some hack applied to it to make the colorer seem aware of the context, but it's still an ugly hack with no future.

For example, it still has serious problems handling multiline strings, despite the many hacks that were applied to the colorer to improve the situation, both by me and by the original authors.

A real fix would be a reimplementation of the parsing components of the syntax colorer in the form of a state machine (the same approach used by Scintilla). The issue is that the current language definition is rigidly tailored upon the current approach, so we still have to support the current parser somehow.

Back on topic, implementing your proposal is a bit of a problem with the current design of the syntax colourer, but I think you could still implement it manually by listening for text change notifications on Fragaria's text view and then setting the custom color on the text storage, instead than with temporary attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants