This repository will hold a new mode for Processing- the REPL mode
OTHER License
This mode adds in a Read-Evaluate-Print-Loop console to processing in the form of a tab at the bottom. The console enables users to type in processing code and to view the output of this code immediately. Each subsequent line of code shows the output incrementally, much like how an REPL Console for any interpretive language (like Python and the Linux bash terminal) would. The console also provides options to undo commands, to convert the valid commands entered so far into a function, and so on.
The mode also brings hot swapping to the table. This enables the user to view changes made to the sketch without the need for restarting the sketch.
Using the additional features of the mode is simple:
To build REPL Mode from source (recommended), do the following:
resources/build.properties
file. The following are likely the only paths that you will manually have to set:processing.source.base
: Represents the path to the processing source directoryprocessing.classes.core
: Represents the path to the core.jar fileprocessing.classes.pde
: Represents the path to the pde.jar fileprocessing.modes
: Represents the path to the folder where the mode is to be installed (usually the modes
folder inside the sketchbook)processing.executable
: Represents the path to the processing executableant run
from the resources directory (where the build.xml and build.properties files are present).Using the hot-swap feature is super simple- simply save the sketch and run it and leave the sketch window open, and after making the required changes, save the sketch to have the sketch window display the contents of the updated sketch.
if-else
, for
, while
, etc.) and so on.import awesome.cool.supercool.*;
in a new line in the REPL Console.command words
, used to issue commands to the REPL Console:
init
: Represents the first command issued to the REPL Mode Console, to initialize the it. Also used to pass in details about width and height of the sketch the console has to display. May take the following forms:
init
: The basic form, initializes the REPL Console to display a sketch of size 100x100init w h
: Initializes the console to display a sketch of width w and height h. Equivalent to calling size(w,h);
in the setup()
methodinit w h r
: Initializes the console to display a sketch of width w and height h, and to use a renderer of type r, where r is a string that may take values P2D
or P3D
. Equivalent to calling size(w,h,"P2D");
or size(w,h,"P3D");
in the setup()
methodresize
: Allows the user to resize sketch that the REPL console displays without losing the contents of the sketch. Can be run in one of the following 3 ways, each similiar to their init
counterparts:
resize
resize w h
resize w h r
clear
: Used to clear the REPL Console without affecting anything else.undo
: Used to undo a (set of) statement(s). Note that command statements cannot be undone. Can be called in one of 2 ways:
undo
: Undoes the last valid statment.undo x
: Undoes the last x statements.redo
: Used to redo a (set of) statement(s). Note that a redo can only be performed immendiately after an undo. Can be called in one of 2 ways:
redo
: "Redoes" the last undoredo x
: "Redoes" the last x statements undone by an undocodify
: Used to get a method that, if called, displays everything currently visible in the sketch window. More precisely, it adds a method of the void return type to the current tab, the method body consisting of all statements used to display the output visible at present (i.e., all statements from the last init, excluding those undone). Takes the format codify x
, where x is a string representing the method name.>> rect(20,20,40,40);
>> rect(20, 20,
... 40, 40);
>> if (true) {
... if (true) {
... print("I love processing");
... }
... }
Mark
, mark the required text, right-click again, and select Copy
. To copy everything, simply right-click and select Copy All
The REPL Mode is very similar to the Java Mode, and supports everything that the Java Mode does. However, it aims to bring 2 new features to the table:
A typical "interaction" with the REPL Console may look like the following:
Please file bugs and feature requests here.
A huge thank you to Manindra Moharana for helping me out every step of the way- in figuring out how to implement the UI, how to get the REPL part up and running, suggesting using the hot swapper, reviewing and testing everything extremely thoroughly, and so much more. Special thanks to Florian Jenett for first conceiving the idea of an REPL Mode, for helping me out with the UI, and for suggesting a bunch of new handy features.