Files
textmate/Applications/TextMate/resources/TextMate Help/javascript_object.md
Allan Odgaard f58a92885d Add titles to all help pages
Note that the documentation is a bit outdated as it hasn’t been touched since the first public alpha — updated documentation will appear when closer to final release, in the meantime interested parties should watch the release notes, wiki, and mailing list.

Closes #822.
2013-02-25 21:07:53 +01:00

55 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
title: Commands: JavaScript API for HTML Output
# TextMate JavaScript Object API
The object has the following methods available:
system() See below for information.
log(msg) Adds a message to the system console (using NSLog).
open(path, options) Opens a file on disk as a document in the current application.
options may be either a selection range string or a (line) number.
In addition, these properties are exposed:
busy (boolean) The busy spinner in the output window will be displayed when this is true.
progress (double, 0-1) Controls the value displayed in the determinate progress indicator.
## TextMate.system()
Also see <http://developer.apple.com/documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/Articles/CommandLine.html>.
### Synchronous Operation
Example:
obj = TextMate.system("/usr/bin/id -un", null);
Result is an object with following properties:
outputString: The output of the command, as placed on stdout.
errorString: The output of the command, as placed on stderr.
status: The exit status of the command.
### Asynchronous Operation
Example:
obj = TextMate.system("/usr/bin/id -un", handler);
Handler is called when the command is finished and given an object with the following properties:
outputString: The last output of the command, as placed on stdout.
errorString: The last output of the command, as placed on stderr.
status: The exit status of the command.
Result is an object with following properties/methods:
outputString: The current string written to stdout (standard output) by the command.
errorString: The current string written to stderr (standard error output) by the command.
status: The commands exit status, as defined by the command.
onreadoutput: A function called whenever the command writes to stdout. The handler must accept a single argument; when called, the argument contains the current string placed on stdout.
onreaderror: A function called whenever the command writes to stderr. The handler must accept a single argument; when called, the argument contains the current string placed on stderr.
cancel(): Cancels the execution of the command.
write(string): Writes a string to stdin (standard input).
close(): Closes stdin (EOF).