Post Reply 
Eclipse Syntax Highlighter For Proxo/Sidki - Intro
Nov. 04, 2009, 07:39 AM (This post was last modified: Nov. 21, 2009 11:50 AM by ProxoDent.)
Post: #1
Eclipse Syntax Highlighter For Proxo/Sidki - Intro
I've finished up a working syntax highlighter / colorer for use with *.ptron and *.ptxt files in Eclipse. Colorer-take5 plug-in for Eclipse is required as the rules were written in CT5's hrc format.

I won't post the actual working files yet because I'd like to document it further, test it for a bit longer, and maybe add some color-scheme files. Some plug-ins for Eclipse can be a little quirky. So far everything seems stable enough.

In the meantime, I'll post some screenshots of it and provide a link to a 'blog' I set-up on Live.com. On the blog, you can view some video clips of the paired-symbol matching and outline features I coded (I'm not sure how long I'll leave the link active / available to the public).

I really doubt there will be much interest in this, but it was a nice diversion putting it together for myself. Smile!

----------------------------------------

2009-11-20 - Version 1.0.0 uploaded.

Files in 'zip' attachment (7):

ptron.hrc
ptxt.hrc
ptron01.hrd
ptxt01.hrd
FilterOutlined.gif
SectionOutlined.gif
README.txt

The README.txt file contains info and INSTALL instructions. I will not reproduce all of it here as it is quite lengthy, but here are the 'Requirements' section and selected 'Notes' from the file. The info may be of interest to anyone thinking about trying this out without having to download the zip file and digging through everything else. It may have the effect of persuading or dissuading you to continue.

Code:
-----
Requirements:

- Eclipse IDE - Galileo (3.5.1x) was used for testing, but any version
   compatible with the current Colorer-take5 plug-in should work. Get it here:
      
        http://www.eclipse.org/

- Colorer-take5 plug-in for Eclipse IDE - use only version 0.8.0 (or later).
   Get it here:
        
        http://sourceforge.net/projects/colorer/files/Eclipse%20Colorer/

Notes:

- Eclipse uses a lot of memory (everyone knows that, right?). However, be aware
  that a fast machine (CPU) is also required for this plug-in when using large,
  heavily colored files like Sidki *.ptron files. You may find it too much for
  your machine, especially in regard to the Outliner feature. If your Outline
  view doesn't fully populate initially, i.e., you don't see all of the *.ptron
  configuration file sections listed:
    
    Global
    WinSizes
    Blocklists
    HTTP Headers
    Patterns
    Proxies
  
  you can navigate to the bottom of the file and it should populate as the file
  is viewed. Again, this shouldn't always be necessary.
      
  If you have any doubts about your system, especially avoid the 'Colorer Parse
  Tree' available as an option in the Outline view. The option is primarily
  there for diagnostics when developing a colorer, so it really isn't necessary
  for general use. If you do decide to open it while viewing a *.ptron file on a
  slow / moderately fast machine, you may have to wait a while before your
  Eclipse session becomes usable again. On smaller files like the *.ptxt files,
  there shouldn't be a problem.

- The *.hrc and *.hrd files are heavily commented if anyone is interested in
  reviewing them. However, the *.hrd files, where colors are actually set, will
  likely be accessed more often if you care to change the colors. A reference
  section is included at the bottom of each Proxo *.hrd file as an aid to
  setting things to suit your taste.

- Useful links to Colorer-take5 HRC and HRD documentation:
  
  HRC Language Reference
  http://colorer.sourceforge.net/hrc-ref/

  HRD Spec
  http://colorer.sourceforge.net/hrc-ref/#ref.hrd.hrd

I'll post modified files required for console-based editors like FAR Manager later.


Attached File(s)
.png  ptron_colorer_eclipse.png (Size: 99.06 KB / Downloads: 776)
.png  ptxt_colorer_eclipse.png (Size: 90.95 KB / Downloads: 763)
.zip  proxo_CT5_v1.0.0.zip (Size: 18.35 KB / Downloads: 701)
Add Thank You Quote this message in a reply
Nov. 04, 2009, 09:37 AM
Post: #2
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
You got to kidding me! Proxo needs a syntax highlighter. LOL!
Add Thank You Quote this message in a reply
Nov. 04, 2009, 12:25 PM (This post was last modified: Nov. 04, 2009 12:27 PM by ProxRocks.)
Post: #3
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
looks pretty impressive...
i've seen similar for Notepad++

i've always kinda wondered if parenthesis-pairs could be paired somehow?
Add Thank You Quote this message in a reply
Nov. 13, 2009, 07:48 AM
Post: #4
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
Stop teasing, GIMME! :P
Im new at all this and regex stuff does my head in, looking at your screenshots its obvious this would help me alot.
Is there anychance it would work with this....
http://colorer.sourceforge.net/farplugin.html
...its just that eclipse is a bit much for me and I dont want to have to download it again (dialup and all) but I will Smile!
Really looking forward to this.
If anyone has a syntax highlighter for any other app Id really appreciate that also, except the Ultraedit one.....I dont like Ultraedit
Add Thank You Quote this message in a reply
Nov. 13, 2009, 02:55 PM
Post: #5
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
(Nov. 13, 2009 07:48 AM)PAEz Wrote:  Is there anychance it would work with this....
http://colorer.sourceforge.net/farplugin.html

No. Far Manager is a Windows-based file manager similar to Midnight Commander (MC is available on Linux-based systems, including Cygwin). Both of those file managers have plug-ins available to them that allow use of the Colorer library, but rather than being used for syntax highlighting, the library is used to distinguish file types, directory types, etc.

(Nov. 13, 2009 07:48 AM)PAEz Wrote:  ...its just that eclipse is a bit much for me and I dont want to have to download it again (dialup and all) but I will Smile!
Really looking forward to this.

See below.

(Nov. 13, 2009 07:48 AM)PAEz Wrote:  If anyone has a syntax highlighter for any other app Id really appreciate that also, except the Ultraedit one.....I dont like Ultraedit

I originally put together an Eclipse syntax highlighter using jEdit's format for use with another Eclipse plug-in. However, I realized early on I didn't really like the editor provided by the plug-in for one reason or another, so I switched to Colorer-Take5's plug-in. Colorer-Take5 is more complex to write syntax code for, but it is more flexible and customizable. The Colorer-Take5 plug-in does not provide a GUI for changing colors, so it is also more difficult to explain how to use, thus another reason for my delay in posting it: I'll have to do an instructional write-up explaining how to use it.

In the meantime, since you would prefer not to use Eclipse anyway, I'll post the jEdit-format file, which surprise, can be used with jEdit. It's not my editor of choice (I generally don't like JAVA apps, Eclipse excepted), but it might work for you.

Give it a try if you haven't already (download is ~3MB), and I'll post the Proxo syntax highlighter for it later today or tonight**. It may have some warts because, as I said, I don't use it, nor do I intend to use it. I'll clean it up a little, though.

http://www.jedit.org/

-----
** I reserve the right to change my mind after waking up a bit more and realizing just how warty I left the code the last time I worked on it. Smile!


Attached File(s)
.png  jEDIT.png (Size: 70.66 KB / Downloads: 688)
Add Thank You Quote this message in a reply
Nov. 13, 2009, 04:10 PM
Post: #6
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
Quote:No. Far Manager is a Windows-based file manager similar to Midnight Commander (MC is available on Linux-based systems, including Cygwin). Both of those file managers have plug-ins available to them that allow use of the Colorer library, but rather than being used for syntax highlighting, the library is used to distinguish file types, directory types, etc.
Are you sure? I got Far for something to do and the plugin and it was highlighting pas files (in edit, not view).

The Eclipse one looks better but either would help (Ill get Eclipse).
You fussy people worring about how good your code is :P....Im a crap coder so I wouldnt care :P

Looking forward to either, thanks.
Add Thank You Quote this message in a reply
Nov. 13, 2009, 07:25 PM
Post: #7
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
(Nov. 13, 2009 04:10 PM)PAEz Wrote:  
Quote:No. Far Manager is a Windows-based file manager similar to Midnight Commander (MC is available on Linux-based systems, including Cygwin). Both of those file managers have plug-ins available to them that allow use of the Colorer library, but rather than being used for syntax highlighting, the library is used to distinguish file types, directory types, etc.
Are you sure? I got Far for something to do and the plugin and it was highlighting pas files (in edit, not view).

Well. No. I'm not sure. I'm wrong actually (the underlined part above is where I went wrong ... the most important part). I actually built and installed Colorer for Midnight Commander on my Arch Linux installation some time ago ... I guess so long ago I forgot why I built and installed it.

Anyway, I downloaded FAR Manager to see how it would work. After modifying some code to get things right (especially modifying RGB colors to work in console), everything seems to work including matching pairs and even the Outliner. Screen shots posted.

I'll get the jEdit file up anyway later on today/tonight/early tomorrow morning, but I already noticed a problem when I reviewed the screen shot I posted ... text following a '#' that was actually part of the Proxo code was highlighted as a comment. That shouldn't be difficult to fix.

Hopefully, I can set some time aside within the week to finish documenting the Colorer-Take5 (Eclipse / FAR / MC) version and get a set of instructions drafted for installation and modifying the colors.


Attached File(s)
.png  FAR_Ptron.png (Size: 65.1 KB / Downloads: 716)
.png  FAR_PtronOutliner.png (Size: 96.26 KB / Downloads: 695)
Add Thank You Quote this message in a reply
Nov. 14, 2009, 06:17 AM
Post: #8
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
MORE TEASING!! Big TeethWinkBig Teeth
Great to hear it does work with FAR and thanks for taking the time to check.
Dont worry to much about the jedit one if Im going to be able to use a lighter option than eclipse with the plugin, Im impatient but Id rather you spend your time on the plugin. Im going to need those instructions on changeing colours as the FAR one has a bit to much contrast for my liking, sure does look sweet tho.
Ooooh, that outliner is an added bonus!
Add Thank You Quote this message in a reply
Nov. 15, 2009, 02:30 PM (This post was last modified: Nov. 15, 2009 08:43 PM by ProxoDent.)
Post: #9
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
(Nov. 14, 2009 06:17 AM)PAEz Wrote:  Dont worry to much about the jedit one if Im going to be able to use a lighter option than eclipse with the plugin, Im impatient but Id rather you spend your time on the plugin.

I took your suggestion yesterday and skipped working on the jEdit highlighter. However, during the course of the day, I used jEdit for some work just to see how it stacked up against my preconceived dislike for JAVA apps, and I have to admit I liked it enough to finish the jEdit-based highlighting code rather than just clean it up. Among other things, I added / modified code so the paired symbols matching now respects escapes and allows for Perl character class rules within square-brackets just as I had done for the Colorer-Take5 version.

I think if you give this a try with jEdit, you'll like it. I originally gave up on it because the Eclipse plug-in (I don't know who wrote it) that uses the jEdit format was pretty wonky: it didn't respect the rules I was writing which were based on jEdit's documentation (possibly because the plug-in may be based on an older version of jEdit's format), it didn't utilize the paired-matching capability, and the editor supplied was very basic and did some unexpected things that I couldn't tolerate (among the examples, undo'ing edits would never turn off the 'unsaved' status indicator despite the fact that the file had been returned to its original state). However, none of the issues are present when using the syntax code with jEdit itself.

Don't worry, I'll continue with the Colorer-Take5 code documentation, because it is likely the one I'll use the most. But I also use Eclipse for bigger projects (mostly Perl and Python). I don't think I'd wish it on anybody to set up Eclipse for the sole purpose of editing Proxomitron files. But that's your call. Editing files in MC or FAR doesn't appeal to me either; if I was going to use a console editor, I'd use Vim or emacs. That said, it's always nice to have options.

Okay, let's get to it:

1. Install jEdit;

2. Copy the attached 'ptron.xml' file (after unzipping it) to the 'modes' sub-directory under the jEdit root;

3. Open the existing 'catalog' file (also in the 'modes' sub-directory) and add this code to the file:

Code:
<MODE NAME="ptron"        FILE="ptron.xml"
                FILE_NAME_GLOB="*.{ptron,ptxt}"/>

Make sure the code is placed between the <MODES> </MODES> tags (it's easiest just to stick it at the end of the file right before the closing </MODES> tag.

Here's the mapping of the colors, and the corresponding RGB codes to set in jEdit if you want to make the syntax look exactly like it appears in the screen shots (the mapping documentation is in the xml file as well):

Code:
Color Mapping
COMMENT1 - Strings anchored at left margin by '#'
          - Config file section header
          - Blocklist section list separator string
COMMENT2 - List names (Bypass-List, AllowCookies, Exceptions, etc.)
COMMENT4 - Default highlighting for anything undefined by rules.
KEYWORD1 - Ptron Parameters (Enable, FreezeGIF, Bounds, Replace, etc.)
KEYWORD2 - Paired symbols (), {}, [], "", ''
KEYWORD3 - Proxomitron reserved words ($TST, $SET, $GET, etc.)
KEYWORD4 - Sidki-Proxo reserved words (keyword, adkey_j, i_level, etc.)
LABEL    - Ptron Parameter string values (TRUE, FALSE)
LITERAL1 - Escaped Left Brackets - Set Same Color As Literal2 (and Operator if desired)
LITERAL2 - Escaped Right Brackets - Set Same Color As Literal1 (and Operator if desired)
LITERAL3 - Other - paths, dates, Internet addresses
OPERATOR - All other symbols not in KEYWORD2

Colors as currently set in jEdit screenshots:

COMMENT1 - 153,153,153
COMMENT2 - 153,153,0    (BOLD)
COMMENT4 - 102,102,102
DIGIT    - 255,0,0      (BOLD)
KEYWORD1 - 219,0,124    (BOLD)
KEYWORD2 - 190,0,0      (BOLD)
KEYWORD3 - 139,0,0      (BOLD)
KEYWORD4 - 0,61,200     (BOLD)
LABEL    - 103,136,176  (BOLD)
LITERAL1 - 153,153,153  (BOLD)
LITERAL2 - 153,153,153  (BOLD)
LITERAL3 - 204,102,255  (BOLD)
OPERATOR - 0,142,0      (BOLD)

Also, jEdit has settings for adjusting the font appearance that were mandatory for me, otherwise jEdit was unusable. Adjust these settings if you have issues:
  • Utilities->Global Options->Text Area => Anti-Aliased Smooth Text (subpixel works for me)
  • Utilities->Global Options->Text Area => Fractional Font Metrics (selected)

Final caveat: I am definitely not a syntax-writing guru, and I learned the coding format strictly for this project. I also lose interest in side-projects pretty quickly, so any issues found may need to be addressed by the end-user. Smile!


Attached File(s)
.png  jEdit-Ptron.png (Size: 80.76 KB / Downloads: 693)
.zip  ptron_xml_v1.0.2.zip (Size: 5.99 KB / Downloads: 695)
Add Thank You Quote this message in a reply
Nov. 15, 2009, 08:02 PM
Post: #10
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
That works nicely. Smile!
jEdit feels cumbersome here however (in Ubuntu 9.10).

IIRC Notepad++ syntax highlighting is based on Scintilla/SciTE, which is available for Linux too.
Add Thank You Quote this message in a reply
Nov. 15, 2009, 08:30 PM (This post was last modified: Nov. 15, 2009 08:42 PM by ProxoDent.)
Post: #11
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
(Nov. 15, 2009 08:02 PM)sidki3003 Wrote:  That works nicely. Smile!
jEdit feels cumbersome here however (in Ubuntu 9.10).

IIRC Notepad++ syntax highlighting is based on Scintilla/SciTE, which is available for Linux too.

I use Arch Linux primarily, but I did all the work described in this thread on Windows, so I haven't tried jEdit on Linux yet (I do have Ubuntu installed as well, but it doesn't get much use ... still haven't upgraded to 9.10).

Compared to Scite, everything probably feels cumbersome. Smile!

And speaking of Scite, which is my default editor on both Windows and Linux, but for which I haven't a clue or desire to build a lexer, where can I pick up the syntax highlighter (hopefully you're not just referring to adding keywords to the Properties file)?

Thanks.
I uploaded a revised ptron.xml (v1.0.2 available in the original post).

Changelog:
- Added a couple of missing Proxo matching commands:
-- $FILE
-- $RESP

- Edited some majorly incoherent code comments so that they are at least only slightly incoherent. They'll be revisited when I have more time.
Add Thank You Quote this message in a reply
Nov. 15, 2009, 08:42 PM
Post: #12
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
Yep, i do mean syntax highlighting. I haven't SciTE installed right now, never really delved into it anyway, so i can't be of help here. No Expression
Add Thank You Quote this message in a reply
Nov. 20, 2009, 03:45 PM
Post: #13
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
(Nov. 13, 2009 07:25 PM)ProxoDent Wrote:  Hopefully, I can set some time aside within the week to finish documenting the Colorer-Take5 (Eclipse / FAR / MC) version and get a set of instructions drafted for installation and modifying the colors.

In the interest of keeping my word and as a show of good faith , I'm posting the core files required for use with the Colorer-Take5 Eclipse plug-in.
I'll be back on later with the instructions on how to use them. Smile!

The files are attached to the original post in this thread (as will be any updates, additions or instructions).
Add Thank You Quote this message in a reply
Nov. 21, 2009, 12:50 AM
Post: #14
RE: Eclipse Syntax Highlighter For Proxo/Sidki - Intro
Okay.

Proxo-CT5 v1.0.0 is uploaded and available in the original post. All files needed to get it working in Eclipse are included along with instructions.
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: