X

Geertjan's Blog

  • October 22, 2005

More Than One Kind Of Syntax Highlighting

Geertjan Wielenga
Product Manager
There's more. More than one kind of syntax highlighting. Typically, you would implement it for a syntax that the IDE doesn't support by default, such as the manifest file syntax shown in yesterday's blog entry. However, how about this scenario—typing regular expressions can be not much fun. How about some syntax highlighting to help you? Here you see a Regular Expression Tester (made by my NetBeans colleague Martin Adamek) with syntax highlighting for typing in the regular expression. This makes it easier to scan and easier to type. Check it out:

So, instead of syntax highlighting being associated with a file type, in this case it is associated with a JEditorPane. This scenario will also be covered in the upcoming NetBeans Syntax Highlighting Tutorial.

Update 11 January 2006: You can get the sources of the above syntax highlighted regular expression checker by clicking here. Note that there are several issues: the syntax highlighting works but is not correct; you need to press Enter after entering the pattern, which adds a new line; and sometimes there are strange things going on that I can't explain. Any fixes to this module would be appreciated!

Join the discussion

Comments ( 9 )
  • Martin Krauskopf Wednesday, January 11, 2006
    Would be great if the plugin is on the AutoUpdate center. Such small plugins are often the best ;)
  • Geertjan Wednesday, January 11, 2006
    Thanks. If you can explain to me how to get it there, I'd be happy to put it there (but preferably after you or someone like Martin K. has fixed some of the obvious bugs.)
  • Martin Krauskopf Wednesday, January 11, 2006
    First step is to make it buildable under $NB_CVS/contrib (e.g. make it nb_module). There was a discussion about this at dev (or openide?) mailing list with Sandip Chitale. I could move it there if you don't want to :). Also I don't know the code. Do you feel it is ready?
    BTW I'm Martin K. You mean probably Martin A. :)
  • Geertjan Wednesday, January 11, 2006
    Well, I mean Martin A. and Martin K. Both of you!

    Actually, I don't think it's ready yet. One important issue needs to be fixed: when you press Enter in the Pattern field, you should escape from the textfield, but instead a newline is added. I think it should be trivial to fix, if your name is Martin A. or Martin K... :-)

  • Martin Adamek Wednesday, January 11, 2006
    I will refactor it, fix some bugs (instead of highlighting and commit to contrib) today.
  • Geertjan Wednesday, January 11, 2006
    Cool. Don't just commit to contrib, but also make it available to update center.
  • Martin Adamek Wednesday, January 11, 2006
    OK, it is in the contrib. I fixed those Enters/Tabs. I didn't fix anything in highlighting and there is some problem with options deserialization which I am not able to fix. These 2 things need to be done to go to AU, I think. Any volunteers? :-)
  • Martin Krauskopf Wednesday, January 11, 2006
    Ups I forgot to make my self notified by emails and huh... it's all done :) (I saw the cvs commit which pinged me)
    > some problem with options deserialization
    I think that the best would be if you file the problems you mean into issuezilla contrib/code, subejct "[regextester] ....." and assign to Martin A. ;) (I'll CC my self)
    Anyway thanks for the work. It's quite useful for me. I have (had) a simple tester class and still pressing S-F6 during testing compicated rexexps :)
  • Sunanda Sanjeewa Wednesday, February 1, 2006
    Dear Sir,
    Can you plese send me the sourse code of the last self working example appears on http://platform.netbeans.org/tutorials/nbm-mfsyntax.html .
    Thanks,
    Sunanda.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.