In all briefness - jEdit abbreviations for Processing
This is a long planned follow-up to a previous
blog post about using jEdit for authoring Processing code. Previously I'd only released a syntax colouring/editing mode, however here's the real reason to
use jEdit as external editor: Abbreviations will save you
loads of typing and are slightly more intelligent (i hope) 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.
For example, the phrase "setupgl#800#600#" would generate all that for you:
import processing.opengl.*;
void setup() {
size(800,600,OPENGL);
}
void draw() {
}...and put the cursor straight into the 1st blank line after "size()" to continue editing seemlessly.
In total I've created
approx. 120 of such abbreviations, which are briefly listed below.
Installation
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...
Download
this file and extract it into this folder:
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 $HOME/abbrevs $HOME/.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.
Usage
Once installed the abbreviations are only active for the Processing editing mode (.pde files) to avoid conflicts with other languages.
By default abbrev's are expanded via the CTRL+; but you can choose to use SPACE instead (don't recommend it though). Some of the shortcodes will take a number of (optional) parameters which have to be appended to the abbreviation via # characters. AFAIK you can't change this separator, which is a bit of a letdown for Mac users. If some expected params are missing for an abbrev, I have tried to code them so that the cursor will be at a reasonable position (e.g. where the 1st param would be) in the generated code regardless
Finally, here's the list of this first release, sorted by category:
Scaffolding
| Abbrev | Result |
| setup#800#600# |
void setup() {
size(800,600);
}
void draw() {
} |
setupgl#800#600# setup3d#800#600# |
void setup() {
size(800,600,OPENGL); // or use P3D for setup3d
}
void draw() {
} |
| try#IO# |
try {
}
catch (IOException e) {
} |
Types and system variables
| PA | PApplet |
| PF | PFont |
| PG | PGraphics |
| PI | PImage |
| CL | Client |
| C | Capture |
| M | Movie |
| SE | Serial |
| SV | Server |
| HT | HashTable |
| O | Object |
| S | String |
| V | Vector |
| KP | keyPressed |
| KR | keyReleased |
| MP | mousePressed |
| MR | mouseReleased |
| MX | mouseX |
| MY | mouseY |
| PMX | pmouseX |
| PMY | pmouseY |
Some extra Java types with parameters:
| E#enum#myVector# | Enumeration enum = myVector.getElements(); |
| I#iter#myCollection# | Iterator iter = myCollection.iterator(); |
Loops
| 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/") |
| rb |
readBytes(); |
| rc |
readChar(); |
| rs |
readString(); |
| sf#foo.tga# |
saveFrame("foo.tga"); |
| lp |
loadPixels(); |
| up |
updatePixels();
|
Modes and details
| 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); |
| bd#3# |
bezierDetail(3); |
| cd#3# |
curveDetail(3); |
| nd#3# |
noiseDetail(8); |
| sd#3# |
sphereDetail(3); |
Graphics/rendering related
| am |
applyMatrix(); |
| 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; |
| bc |
beginCamera();
resetMatrix();
endCamera(); |
| bg#0# |
background(0); |
| bri#col# |
brightness(col) |
| bs#POINTS# |
beginShape(POINTS);
endShape(); |
| bv |
bezierVertex(); |
| cv |
curveVertex(); |
| cf#Arial#32# |
createFont("Arial",32); |
| el#100#100#10#10# |
ellipse(100,100,10,10); |
| fr#25# |
frameRate(25); |
| f#255# |
fill(255); |
| l#0#0#mouseX#mouseY# |
line(0,0,mouseX,mouseY); |
| noc |
noCursor(); |
| nof |
noFill(); |
| nos |
noStroke(); |
| nosm |
noSmooth(); |
| not |
noTint(); |
| pum |
pushMatrix(); |
| pom |
popMatrix(); |
| rem |
resetMatrix(); |
| rx#PI# |
rotateX(PI); |
| ry#PI# |
rotateY(PI); |
| rz#PI# |
rotateZ(PI); |
| sat#col# |
saturation(col) |
| sm |
smooth(); |
| sw#4# |
strokeWidth(4); |
| sx#-100#0#100# |
screenX(-100,0,100) |
| sy#-100#0#100# |
screenY(-100,0,100) |
| sz#-100#0#100# |
screenZ(-100,0,100) |
| s#128# |
stroke(128); |
| tf#myFont# |
textFont(myFont); |
| tr#0#0#1# |
translate(0,0,1); |
| v |
vertex(); |
Misc
| ac#pixels#0#pix#0#pix.length# |
System.arraycopy(pixels,0,pix,0,pix.length); |
| av |
available() |
| hme |
hasMoreElements() |
| ne |
nextElement() |
| lerp#a#b#0.25# |
(a+(b-a)*0.25) |
| n#i# |
noise(i) |
| pr |
println(); |
| rnd#100# |
random(100) |
| r |
return |
| t |
this. |
Core libraries
| imgl |
import processing.opengl.*; |
| imn |
import processing.net.*; |
| ims |
import processing.serial.*; |
| imv |
import processing.video.*; |