Skip to content

Commit

Permalink
Adding in a more comprehensive reference
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmoniz committed Jul 18, 2015
1 parent 8a10638 commit 10037b0
Show file tree
Hide file tree
Showing 7 changed files with 4,692 additions and 7 deletions.
51 changes: 48 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,25 @@ This mode adds in a Read-Evaluate-Print-Loop console to processing in the form o

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 REPL Mode- a 2 minute guide
-------------------------------------

Using the additional features of the mode is simple:

* **REPL Console**
* First, initialize the console with the init keyword.
* Next, type in absolutely anything into the console, and watch the output come alive!
* To split a single function call into multiple lines, press the Enter key after a comma.
* For more information about the init keyword, and for a list of keywords available, type help.
* **Hot swapping**
* Create a new sketch, type stuff in, and save it. Alternately, open an existing sketch.
* Run the sketch, and leave the sketch window open.
* Make required changes to the sketch, and voilà! Hot swapped!


Requirements
------------
* Processing 3.10a or later (preferably the latest version built from Github).
* Processing 3.11a or later (preferably the latest version built from Github).
* Apache Ant to build.

Building from Source
Expand All @@ -33,7 +49,7 @@ Using the hot-swap feature is super simple- simply save the sketch and run it an
The REPL Console Commands
-------------------------
* The REPL Mode Console supports pretty much anything that can be entered in the draw() method of processing- basic shapes, variable declarations, control constructs (`if-else`, `for`, `while`, etc.) and so on.
* At present, the REPL Mode Console does not support calling methods or declaring objects that would require a library to be imported. Support for this feature, however, will be added soon.
* In order to import a library, simply type `import awesome.cool.supercool.*;` in a new line in the REPL Console.
* The REPL Mode Console also has the following **`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 100x100
Expand All @@ -52,9 +68,38 @@ The REPL Console Commands
* `redo x`: "Redoes" the last x statements undone by an undo
* **`codify`**: 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.

Navigating in the REPL Console
------------------------------
* A single statement may be entered in a new line, for example,
```
>> rect(20,20,40,40);
```
* A statement block may take 2 forms:
* A single function call spilt over multiple lines (ending with a comma on the first line, and a semi-colon on the last), for example:
```
>> rect(20, 20,
... 40, 40);
```
* A statement block split over multiple lines (ending with an opening curly brace on the first line, and a closing curly brace on the last), for example:
```
>> if (true) {
... if (true) {
... print("I love processing");
... }
... }
```
* Command history may be easily navigated with the up and down arrow keys, much like a typical console
* To copy text, right click in the console, select `Mark`, mark the required text, right-click again, and select `Copy`. To copy everything, simply right-click and select `Copy All`

Use case
---------
The REPL Mode makes for some quick, handy, convenient prototyping. A typical "interaction" with the REPL Console may look like the following:
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:

* **REPL Console**: The REPL mode contains an REPL Console for easy, quick, handy, convenient prototyping
* **Hot swapping**: The REPL mode permits restartless hot-swapping of a sketch, saving developer time

A typical "interaction" with the REPL Console may look like the following:

![image](https://joelmoniz.files.wordpress.com/2015/06/repl_output_usecase.png?w=716)

Expand Down
4 changes: 2 additions & 2 deletions resources/mode.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = [Joel Moniz](http://joelmoniz.com)
url = https://github.com/joelmoniz/REPLmode
sentence = Adds an REPL Console to view the output of code typed into it immediately. Also gives the PDE the ability to hot swap code.
paragraph = 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. Ths mode also gives the PDE the ability to hot swap code, wherein the output corresponding to changes made in a running sketch can be viewed by simply saving the sketch, without restarting it.
version = 4
prettyVersion = 1.2.6b
version = 5
prettyVersion = 1.2.7b
imports = processing.mode.java.JavaMode
minRevision = 0238
Loading

0 comments on commit 10037b0

Please sign in to comment.