jEdit and haXe

Thursday, August 6, 2009

For a while now, i've been using GtkSourceView-based applications for writing (Geany&Gedit), but decided to move back to the old trusty friend. I must admit that i'm a newbie to java, my previous uses for jEdit were mainly as2 and php, this time its haxe and java.

There's a haxe mode for jEdit here, which does the highlighting, my intention is to write a proper haxe plugin for jedit, one which will install the mode above, add a haxe menu for easy access, options dialog for configuring general haxe stuff like paths, classpaths and the likes, sidekick integration, project integration, text completion, import tools and documentaion launchers.

I have'nt much thus far, but i'd like to share what i do.

Installing the console & errorlist plugins, you get a single click reference to the line on compilation error, and works for haxe\ant(i'm using anthx)\make\swfmill.

Installing the sidekick plugin, outline plugin, ctags plugin, and custom folds, will get you a couple of nice views on the sidebar.

So for a typical function that looks like this:

//{{{ doSomething
/** This function does something **/
public function doSomething() : Void {
trace("Done.")'
}
//}}}

I get 2 folds, one for the expilict fold (line #1), which opens up the comment and the function header, the second opens the function's body (#3). If 2 clicks seem much to get to the body, not to worry, keyboard shortcuts are a-plenty in jEdit, alt-enter and alt-bs will collapse and expand folds...

This needs a lot of cleanup, but basically works for the ctags plugins (place this at ~/.ctags on linux):

--langdef=haxe
--langmap=haxe:.hx

--regex-haxe=/^[ \t]*[import ]+[ \t]+([A-Za-z0-9_.]+)[ \t]*/\1 /F,import, imports/
--regex-haxe=/^[ \t]*[(enum) ( \t)]+ [ \t]+([A-Za-z0-9_.]+)[ \t]*\(/\1 /e,enum, enumerators/
--regex-haxe=/^[ \t]*[(typedef) ( \t)]+ [ \t]+([A-Za-z0-9_]+)[ \t]*\(/\1 /t,typedef, typedefs/
--regex-haXe=/^[ \t]*(private|public|static|inline) *[ \t]+var[ \t]+([A-Za-z0-9_]+)[ \t]*/\2 : \1/v,variable, variables/
--regex-haXe=/^[ \t]*(private|public|static|override) *[ \t]*function[ \t]+([A-Za-z0-9_]+)[ \t]*\(+([A-Za-z0-9_]+)*\)*/\1 \2 (\3)/f,function, functions/
--regex-haXe=/^[ \t]*[(class|interface) ( \t)]+([A-Za-z0-9_]+)+([ \t]?)(extends|implements)[ \t]+([A-Za-z0-9_]+)+[ \t]*/\1 \2 /c,class, classes/

The project viewer, buffer tabs, tasklist, svn, jdiff (uses the built-in splitting), whitespace, textautocomplete and textutils plugins are also great and must have.

Even with all these plugins loaded, the editor is very light compared to its java friends (eclipse and netbeans) both in size and resource usage.

Here are a couple of screenshots, to stop me yapping. have a great day!

4 comments:

Anonymous said...

Geany isn't GtkSourceView based. It is based on Scintilla.

gershon said...

I stand corrected, its my favorite gtk editor, scite also being top-rated.

Anonymous said...

Hi! Your work is brilliant!
I'm beginning with developing haxe in Jedit too!
Could you tell me what look and feel/ theme do you use in Jedit?
Thank you!

Dion said...

Hi, I've developed a jEdit haxe plugin (see the Haxe forums). I've included this info for using ctags with haxe in jedit, but is there a better way than asking the user to edit their ~/.ctags file?

Post a Comment