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

Changing color of Characters like "{","}","(",")",";" etc. #93

Closed
deepsidhu1313 opened this issue Oct 29, 2014 · 6 comments
Closed

Changing color of Characters like "{","}","(",")",";" etc. #93

deepsidhu1313 opened this issue Oct 29, 2014 · 6 comments

Comments

@deepsidhu1313
Copy link

is there anyway i can change the color of Characters like "{","}","(",")",";" etc. and strings starts and ends with (") also line starts with (//) or where strings starts with ("/star") and end with ("star/") to theme my code area ??

@TomasMikula
Copy link
Member

Hello,

you can change the styling of these characters/strings the same way you set the style of any other word. If you started with the JavaKeywords example of using regular expressions, my comments in #62 show how to extends this to multiple styles (i.e. multiple regexes, each meaning a different style).

As your use case gets more complicated, a proper parser for your language becomes more and more justified. Then string literals, comments, braces, parens, punctuation, etc. are all just different kinds of lexical elements recognized by your grammar. The parser gives you index ranges of these elements in text and you can use these ranges to assign styles in the text area (e.g. CodeArea). You might be interested in @jrguenther's project Xanthic to hook up CodeArea with an ANTLR parser.

@deepsidhu1313
Copy link
Author

My apologies for commenting on a closed issue. For Coloring the code can we use /usr/share/gtksourceview-3.0/language-specs/* (from ubuntu 14.04) files in RichTextFX in some way? I was just wondering if there is anyway to implement these, this may save a lot of programming & development time. This will be good if RichTextFx includes support for all coding styles by default and formatting option by default (Just a request). :)

@jeffreyguenther
Copy link
Contributor

@deepsidhu1313, I don't think @TomasMikula has any plans to add this kind of support. You really should check out jrguenther/Xanthic. I haven't had time to take it any further, but all the pieces are there to provide syntax highlighting. The source should be fairly straightforward. Right now, all you need to do is create a parser for your language and setup the mapping between token and style. It might be less work than you think to get started.

Pull requests are very much welcome.

@deepsidhu1313
Copy link
Author

@jrguenther Sir, i am following your project from long time, i tried once understanding your project, but my bad, i have very less experience with parsers or compilers or ANTLR. Also i imported your code into netbeans and it says these classes are missing.

import xanthic.parsers.ShiroLexer;
import xanthic.parsers.ShiroParser;

I waited long for you to add these files and keep checking the last edit date on your project which remained unchanged :). So may i request you to please provide any documentation with your project so that i can contribute to it. In my project code editor is at its least priority and not a main feature. I just want to make the application beautiful. BTW good work and keep it up. :) 👍

@TomasMikula
Copy link
Member

@jrguenther is right that I don't plan to add any tool/language/grammar specific support to this project. To quote my comment from #104:

This project tries to be a flexible basis for code and other editors, not a full-featured editor by itself.

And further:

All that said, I support any effort to provide a more out-of-the-box solution for code editing based on RichTextFX. It's just someone would have to take the initiative to create and maintain that project, and we can then coordinate our efforts.

I had a quick look at GtkSourceView and it is a C library, so it would make sense to first find/write a Java port of it's parser part and then use both that project and RichTextFX to build an editor.

@deepsidhu1313
Copy link
Author

Thanks :) 👍

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

No branches or pull requests

3 participants