We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi. I'm trying to set up a LaTeX listing definition for Processing, and want to know what colors are being used for the automatic coloring of text in Processing code. (ie. int, float: comes in orange, if, else: comes in green, etc.)
It'd be great if you can provide the colors in RGB.
Answers
This would be a good place to start (Not familiar with the editor's source code...) as the mode needs to be taken into account for color key words assignations: https://github.com/processing/processing/blob/master/app/src/processing/app/ui/Editor.java#L296
PdeTextAreaDefaults took me to this part of the GitHub: https://github.com/davidfokkema/smaller-processing/tree/master/app/src/processing/app/syntax
Consider these two: https://github.com/davidfokkema/smaller-processing/blob/master/app/src/processing/app/syntax/Token.java https://github.com/davidfokkema/smaller-processing/blob/master/app/src/processing/app/syntax/SyntaxStyle.java
which are used by: https://github.com/davidfokkema/smaller-processing/blob/master/app/src/processing/app/syntax/PdeTextAreaDefaults.java
However, this will not get you to where you want as I couldn't find all my way to the links to the reserved keyword list. Please keep in mind that this might or might not be the current source code of the editor...
I will let other forum goers comment on this. I am tagging @gaocegege as he is working on Processing R mode and he might know this part of the code better. Also I am tagging benfry (@fry) as he is the owner of that repo.
Kf
Aha! Here: https://github.com/davidfokkema/smaller-processing/blob/master/app/src/processing/app/Mode.java#L122
Now, if you go to your folder containing the processing.exe file (in Windows for instance) then you can find the keyword.txt file there.
Kf
Hi, @ebigunso
Maybe build/shared/lib/defaults.txt#L242:#L268 is what you need.
And the code given by @kfrajer is the logic about coloring, maybe.
Oh, sorry, keywords.txt also plays an important role in coloring. You could get the colors of every keyword using keywords.txt and defaults.txt above.
Great! Thanks for pointing me to the right place. Now I can get started with actually making the language definition.
It'll probably take some time but I'll make sure to share it here once it's done so everyone can enjoy LaTeX awesomeness with Processing code :)
Awesome! Feel free to ask questions if you meet problems :)
Look forward to your work!
@gaocegege
I'm back here since I've finally managed to pull together the language definition! There are a few minor inconveniences though, that I will explain here.
Firstly, for function names that are the same as an already defined keyword (Such as "boolean" and "boolean()"), you have to use [escapechar = "char"] and \color{"color"}{"text"} to color them properly. Example:
Secondly, there is no bold style. In Processing, a few of the function names are defaulted to using bold font, but this could not be implemented.Bold style is now working as of v1.2.Copy and paste the below template if you want to use it. Alternatively, you can copy only the necessary parts. If in that case, note that \usepackage{listings} and \usepackage{color} is a must for this to work.
Also note, I have licensed this work with CreativeCommons license CC-BY-SA, so please remember to give some credit to me ;)
If you find any typos or any other errors, please tell me and I'll try to fix them as much as possible.
Download version: http://www.mediafire.com/file/cw861uy156xftkv/article_listing_Processing_v1.2.tex
Full template below:
It is awesome! Could you show us a snapshot of the generated PDF? :)
@gaocegege
Sure, here it is.
It's a secret that I fixed a major mistake and upped the version to v1.1.
Really neat!
Kf
Thanks!
Updated to v1.2
Now also on the Share Your Work category.
https://forum.processing.org/two/discussion/27887/code-coloring-for-processing-in-latex-listings-package
Patch Notes: