JEdit as External IDE

From Processing

Jump to: navigation, search

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


Contents

Creating a syntax coloring module

jEdit is using XML files to define syntax coloring 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

Abbreviation Expanded result
setup#800#600#
void setup() {
  size(800,600);
}
 
void draw() {
 
}
setupgl#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 Expanded result
PA
PApplet
PF
PG
PI
CL
Client
C
Capture
M
Movie
SE
Serial
SV
Server
HT
HashTable
O
S
V
Vector
KP
KR
MP
MR
MX
MY
PMX
PMY


Some extra Java types with parameters:

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

Loops

Abbreviation Expanded 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

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


Event handlers

Abbreviation Expanded result
mp
mpe
void mousePressed(MouseEvent e) {
    if (e.) {
 
    }
}
mr
mre
void mouseReleased(MouseEvent e) {
    if (e.) {
 
    }
}
md
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"

Abbreviation Expanded result
lb#foo.dat#
loadBytes("foo.dat");
lf#Arial#
loadFont("Arial.vlw.gz");
li#foo.jpg#
loadImage("foo.jpg");
ls#foo.txt#
loadStrings("foo.txt");
rb
readBytes();
rc
readChar();
rs
readString();
sf#foo.tga#
saveFrame("foo.tga");
lp
up

Modes and details

Abbreviation Expanded result
cm#HSB#
em#RADIUS#
im#CORNERS#
rm#CORNERS#
tm#SCREEN#
txm#IMAGE#
bd#3#
cd#3#
nd#3#
sd#3#

Graphics/rendering related

Abbreviation Expanded result
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#
bri#col#
f#255#
fill(255);
sat#col#
sm
s#128#
stroke(128);
sw#4#
bs#POINTS#
bv
cv
el#100#100#10#10#
ellipse(100,100,10,10);
l#0#0#mouseX#mouseY#
v
bc
noc
nof
nos
nosm
not
am
pum
pom
rem
rx#PI#
ry#PI#
rz#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);
cf#Arial#32#
createFont("Arial",32);
tf#myFont#
textFont(myFont);

Misc

Abbreviation Expanded result
ac#pixels#0#pix#0#pix.length#
System.arraycopy(pixels,0,pix,0,pix.length);
av
available()
fr#25#
hme
hasMoreElements()
ne
nextElement()
lerp#a#b#0.25#
(a+(b-a)*0.25)
n#i#
pr
rnd#100#
random(100)
r
t

Core libraries

Abbreviation Expanded result
imgl
import processing.opengl.*;
imn
import processing.net.*;
ims
import processing.serial.*;
imv
import processing.video.*;

Downloads

There are two 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 coloring module

Download File:Processing.xml into the "modes" folder inside your jEdit installation. Then copy and paste the following XML node into the file "catalog" inside the same folder and syntax coloring/checking for PDE files should be ready:


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

Abbreviations

Download Media:abbrevs_v0.1.zip 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</source>

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...

Downloads

Related Links

Personal tools