This contains a handful of javascript functions, used to create native TinyShell applications.
Shortcuts: run, onkeydown, onkeypress.
Object: Plugin
An application is basically a MooTools javascript class. The application is initiated with the member function run and the application should terminate itself by calling resume() on the TinyShell object. The following methods are special and might be called while the application is being executed.
Properties
- description – (string) A short help text describing the application.
Example
All application plugins are programmed this way, for simple examples see Clear, Cowsay. For a bit more advanced examples see Cat or Sys.
Plugin Method: run
Application constructor function.
Syntax
- run(terminal, args, line);
Arguments
- terminal – (object) Reference to the calling TinyShell.shell instance. Use this object to access functions in the Core API.
- args – (array) Arguments passed to the command, not including the program name.
- line – (string) Complete unparsed command entered to execute the program.
Returns
- (void) Return value is not expected
Example
If the application is called test, the command
- $ test -a "Test argument 1" -b arg2
Would cause the TinyShell object to start the application with similar code:
- this.proc = new TinyShell.plugins.test();
- proc.run(this, ["-a", "Test argument 1", "-b", "arg2"], "test -a \"Test argument 1\" -b arg2");
Plugin Method: onkeydown
Event is fired when a keyboard button is pressed down, while an instance of the application is running. Use this event to catch special buttons, like tab, enter, arrows, etc.
Syntax
- onkeydown(event);
Arguments
- event – (event) A native MooTools event object.
Returns
- (boolean) If native onkeydown events should be fired true, otherwise false.
Example
This function is implemented in the default plugins: MySQL and Tiny.
Plugin Method: onkeypress
Event is fired when a keyboard button is pressed, while an instance of the application is running. Use this event to catch character inputs, like letters, number, etc.
Syntax
- onkeypress(event);
Arguments
- event – (event) A native MooTools event object.
Returns
- (boolean) If native onkeypress events should be fired true, otherwise false.
Example
The function is used in the default plugin Tiny to make sure that some keyboards events are not caught by both onkeypress and onkeydown.