HOW-TO: Adding Monkey Scripts from clipboard

A place for those developing Aptana plugins, scripts or extending the IDE to gather and discuss extending Studio beyond the standard features.

Moderator: Aptana Staff

HOW-TO: Adding Monkey Scripts from clipboard

Postby NCoDer » Sun Mar 23, 2008 9:37 am

Since it took me some time, to find out, how the "Paste new script" feature in the "Scripts" menu works, here a short "How-To":

1. Create a script in your favorite text editor:
First add metadata, e.g.:
Code: Select all
/*
* Key: M1+M3+y
* Menu: Synchronize > Save and Upload Current File
* Kudos: <your name here>
* License: EPL 1.0
* DOM: http://localhost/com.aptana.ide.syncing
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
*/

then write a main function e.g.:
Code: Select all
function main(){
    editors.activeEditor.save();
    sync.uploadCurrentEditor();
}


2. To avoid the error message "Can't find any scripts on clipboard - make sure you include the Jabberwocky-inspired markers at the beginning and ending of the script" you have to add two lines. One before the whole stuff:
Code: Select all
--- Came wiffling through the eclipsey wood ---
and one behind:
Code: Select all
--- And burbled as it ran! ---


So the whole script looks similar like this:
Code: Select all
--- Came wiffling through the eclipsey wood ---
/*
* Key: M1+M3+y
* Menu: Synchronize > Save and Upload Current File
* Kudos: <your name here>
* License: EPL 1.0
* DOM: http://localhost/com.aptana.ide.syncing
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
*/


function main(){
    editors.activeEditor.save();
    sync.uploadCurrentEditor();
}
--- And burbled as it ran! ---

You can now copy the whole code to the clipboard and then select Scripts->Paste new script from the menu in Aptana.

So you can avoid, to add a new folder to each projects workspace (which is not useful, if you create a single workspace for each project).

The above script let you save and upload the current file in the editor with a simple shortcut: STRG + ALT + y

Hope this helps,

Nico
NCoDer
 
Posts: 11
Joined: Wed Dec 05, 2007 7:12 am

Return to Customizing and Extending Studio