Using jEdit as external IDE

versionsall
contributorstoxi
started on2006-01-27 11:23

About jEdit

As you might know the Processing IDE is partly based on some components of the open source JEdit editor. This editor has a number of features which make it an ideal candidate to be used in place of the normal Processing PDE:

  • truly cross-platform (runs on Unix, Windows and OSX)
  • unlimited undo/redos
  • unlimited clipboards
  • window splitting and source code folding
  • built-in syntax highlighting for 130+ languages (we will add to this)
  • efficient, customizable keyboard shortcuts for everything
  • “Markers” for remembering positions in files to return to later
  • extensive search & replace (incl. Regular Expressions and multi-file searches)
  • built-in macro language (BeanShell)
  • numerous plugins (handled via plugin manager)

The full list of features can be found at: http://jedit.org/index.php?page=features

Creating a syntax colouring module

jEdit is using XML files to define syntax colouring rules (incl. simple checking) for its various editing modes. Each syntax definition file has a file extension mapping to tell jEdit which language mode to use for individual files. For Processing files we will use the standard .pde extension.

You can find download and installation instructions for a ready-to-go syntax module further below.

Introducing Abbreviations

Abbreviations are one of the most powerful and time saving features of jEdit. They will save you loads of typing and are slightly more intelligent then mere auto-complete functionality. You can use them to quickly generate often used code blocks, event handlers, statements, idioms, keywords etc. You can even pass parameters to some and so generate fully functioning code parts with your own variable names.

Usage

Below is a list of approx. 120 abbreviations specifically for writing Processing code. To use them type in a sequence as shown in the left column and then press Control+; to expand it into the source code shown in the right column. Additionally the cursor will be positioned where it makes most sense to continue. This will vary for each abbreviation. In some cases it is still inside the generated code, sometimes immediately after.

Some of the abbreviations are more complex and make use of parameters enclosed inside # signs. You can use any string as parameter, not just numbers. Also worth noting is that none of those parameters are mandatory, so can be ignored.

Scaffolding

AbbreviationExpanded result
setup#800#600#
void setup() {
    size(800,600);
}
 
void draw() {
 
}
setupgl#800#600#
setup3d#800#600#
import processing.opengl.*;
 
void setup() {
    size(800,600,OPENGL); // or use P3D for setup3d
}
 
void draw() {
 
}
try#IO#
try {
 
}
catch (IOException e) {
 
}

Types and system variables

Abbreviation
Common object types
Expanded result
PAPApplet
PFPFont
PGPGraphics
PIPImage
CLClient
CCapture
MMovie
SESerial
SVServer
HTHashTable
OObject
SString
VVector
System variables
KPkeyPressed
KRkeyReleased
MPmousePressed
MRmouseReleased
MXmouseX
MYmouseY
PMXpmouseX
PMYpmouseY

Some extra Java types with parameters:

E#enum#myVector#Enumeration enum = myVector.getElements();
I#iter#myCollection#Iterator iter = myCollection.iterator();

Loops

AbbreviationExpanded result
for#i#100#
for(int i = 0; i < 100; i++) {
 
}
wh#true#
while(true) {
 
}
we#enum#
while(enum.hasMoreElements()) {
 
}
wi#iter#
while(iter.hasNext()) {
 
}

Conditionals

if#speed>0#
if (speed>0) {
 
}
ie#speed>0#
if (speed>0) {
 
} else {
 
}
swi#key#
switch (key) {
    case :
 
        break;
 
    default:
 
}
c#'a'#
case 'a':
 
    break;
ifkp#a#
if (keyPressed == 'a') {
 
}
ifmp
if (mousePressed) {
 
}

Event handlers

mp
void mousePressed() {
 
}
mpe
void mousePressed(MouseEvent e) {
    if (e.) {
 
    }
}
mr
void mouseReleased() {
 
}
mre
void mouseReleased(MouseEvent e) {
    if (e.) {
 
    }
}
md
void mouseDragged() {
 
}
mm
void mouseMoved() {
 
}
kp
void keyPressed() {
 
}
kpe
void keyPressed(KeyEvent e) {
    if (e.) {
 
    }
}
kr
void keyReleased() {
 
}
kre
void keyReleased(KeyEvent e) {
    if (e.) {
 
    }
}
ce#myCapture#
void captureEvent(Capture myCapture) {
    myCapture.read();
}
me#myMovie#
void movieEvent(Movie myMovie) {
    myMovie.read();
}
se#port#
void serialEvent(Serial port) {
 
}
sve#myServer#c#
void serverEvent(Server myServer, Client c) {
 
}

Data "loaders"

lb#foo.dat#loadBytes(“foo.dat”);
lf#Arial#loadFont(“Arial.vlw.gz”);
li#foo.jpg#loadImage(“foo.jpg”);
ls#foo.txt#loadStrings(“foo.txt”);
os#http://example.org/#openStream(“http://example.org/”)
rbreadBytes();
rcreadChar();
rsreadString();
sf#foo.tga#saveFrame(“foo.tga”);
lploadPixels();
upupdatePixels();

Modes and details

modes
cm#HSB#colorMode(HSB);
em#CENTER_RADIUS#ellipseMode(CENTER_RADIUS);
im#CORNERS#imageMode(CORNERS);
rm#CORNERS#rectMode(CORNERS);
tm#SCREEN#textMode(SCREEN);
txm#IMAGE#textureMode(IMAGE);
detail settings
bd#3#bezierDetail(3);
cd#3#curveDetail(3);
nd#3#noiseDetail(8);
sd#3#sphereDetail(3);

Graphics/rendering related

colours & pixels
argb#pixels[i]#
int a = (pixels[i]>>>24);
int r = (pixels[i]>>16) & 0xff;
int g = (pixels[i]>>8) & 0xff;
int b = pixels[i] & 0xff;
bg#0#background(0);
bri#col#brightness(col)
f#255#fill(255);
sat#col#saturation(col)
smsmooth();
s#128#stroke(128);
sw#4#strokeWidth(4);
drawing
bs#POINTS#
beginShape(POINTS);
 
endShape();
bvbezierVertex();
cvcurveVertex();
el#100#100#10#10#ellipse(100,100,10,10);
l#0#0#mouseX#mouseY#line(0,0,mouseX,mouseY);
vvertex();
camera
bc
beginCamera();
    resetMatrix();
 
endCamera();
drawing flags
nocnoCursor();
nofnoFill();
nosnoStroke();
nosmnoSmooth();
notnoTint();
matrix operations
amapplyMatrix();
pumpushMatrix();
pompopMatrix();
remresetMatrix();
rx#PI#rotateX(PI);
ry#PI#rotateY(PI);
rz#PI#rotateZ(PI);
sx#-100#0#100#screenX(-100,0,100)
sy#-100#0#100#screenY(-100,0,100)
sz#-100#0#100#screenZ(-100,0,100)
tr#0#0#1#translate(0,0,1);
text
cf#Arial#32#createFont(“Arial”,32);
tf#myFont#textFont(myFont);

Misc

ac#pixels#0#pix#0#pix.length#System.arraycopy(pixels,0,pix,0,pix.length);
avavailable()
fr#25#frameRate(25);
hmehasMoreElements()
nenextElement()
lerp#a#b#0.25#(a+(b-a)*0.25)
n#i#noise(i)
prprintln();
rnd#100#random(100)
rreturn
tthis.

Core libraries

imglimport processing.opengl.*;
imnimport processing.net.*;
imsimport processing.serial.*;
imvimport processing.video.*;

Downloads

There're 2 files to download here, depending on which features you want (we recommend both). Before installing any of the files below, please make sure jEdit is not running.

Syntax colouring module

Download processing.xml into the “modes” folder inside your jEdit installation. Then copy & paste the following XML node into the file “catalog” inside the same folder and syntax colouring/checking for PDE files should be ready.

<MODE NAME="processing" FILE="processing.xml" FILE_NAME_GLOB="*.pde" />

Abbreviations

Download this file and extract it into the right folder for your system:

Windows

C:\Documents and Settings\{USERNAME}\.jedit

Mac

/Users/{USERNAME}/.jedit

Note: This folder is not visible in the Finder. Unzip the file in your home folder, open a terminal window and type:

mv ~/abbrevs ~/.jedit/abbrevs

Linux

Find the location of the jEdit settings directory via the menu: Utilities > Troubleshooting > Activity log, then extract/copy the file in that folder. For all systems, you'll need to restart jEdit in order for the abbreviations to come in effect.

A quick word of caution…

…for experienced jEdit users: The “abbrevs” file I've used only contained the default jEdit abbreviations. Installing this file will overwrite any existing abbreviations (for any language) you might have created yourself before. To avoid this copy and paste the Processing related ones into your existing file and restart jEdit…

Related Links

hacks/jedit.txt · Last modified: 2007-07-13 02:12 (external edit)