-
Notifications
You must be signed in to change notification settings - Fork 127
Internal API
Note: the following was added by @facekapow (NOT the author of runtime.js) and is only partially documented.
These are things accessible through requiring 'runtimejs':
Terminal interface object
Collection of colors for the terminal interface.
Prints text
to the terminal. Reprinted repeat
time(s). fg
for text color, bg
for background text color.
Moves screen position by adding the offset
.
Moves screen to specified x
and y
coordinates. Unlike moveOffset()
, it is not relevant to the current screen position.
Provides a stdio interface with the user. Mainly used outside of shell commands.
This is used mainly with runtime.shell.runCommand()
.
Stdio interface class.
Accessible through a new runtime.stdio.StdioInterface
These functions can be overridden, probably for capturing IO.
On write of text without appending a newline, this function is called with the text.
On write of text with appending a newline, this function is called with the text.
On write of an error, this function is called with the error as a string.
On read of a single char, this function is called with a callback that accepts a string (but only reads the first character).
On read of a line, this function is called with a callback that accepts a string.
These functions are only to be used, and cannot be overridden.
Calls interface.onwrite() with the text
joined as a string.
Calls interface.onwriteline() with the text
joined as a string and a newline appended.
Calls interface.onwriteerror() with error
as a string. If given a string, it passes it without modifying it. If given an error object, it reads the error's stack
property.
Calls interface.onread() with cb
. cb
should accept a string parameter.
Calls interface.onreadline() with cb
. cb
should accept a string parameter (does not include the newline).
The default stdio interface for runtime,
again, mainly used outside of shell commands.
It's an instance of runtime.stdio.StdioInterface
that inputs and outputs (including errors) to the shell.
Keyboard functions provided
Event controller for key down events. By default has one listener (the terminal input controller).
Event controller for key up events.
PCI controller for runtime.js, also enables device drivers.
Finds device using vendorId
and deviceId
and, if found, sets opts
as device driver.
PS2 controller for runtime.js
Sets driver
as driver for keyboard.
runtime.js memory allocator interface.
Returns some allocated memory.
Network access in runtime.js
Adds intf
to the interfaces available to runtime.js
Useful for network adapters.
runtime.js TCPSocket interface class, provides access to a TCPSocket. See the runtime.net.TCPSocket page. (yet to be created)
runtime.js TCPServerSocket interface class, provides access to a TCPSocket server. See the runtime.net.TCPSocket page. (yet to be created)
runtime.js UDPSocket interface class, provides access to a UDPSocket. See the runtime.net.UDPSocket page. (yet to be created)
Creates an IP4Address object from a
, b
, c
, and d
, without the dots.
Creates a MACAddress object from a
, b
, c
, d
, e
, and f
, without the colons.
Creates an Interface object from the given macAddr
, which must be an instance of runtime.net.MACAddress.
Collection of IP route functions
Adds a new subnet route
Adds the specifed gateway
and intf
as the default.
Lookup the destIp
route using interface intf
.
Controller triggered when an interface is added.
Controller triggered when an interface is removed.
Gets the memory address of the u8
buffer.
In debug mode? true
or false
, default false
.
Native functions
Shuts down the computer.
Reboots the computer.
Shell access for isolates.
Creates a new shell command accessible to the user via typing the name
in the shell and calls cb
when activated.
cb
should be something like:
runtime.shell.setCommand('foo', function(args, env, done) {
// `args` is a string,
// `env` is the command's environment object,
// and done is called like done([return code]) which tells the shell you're done.
});
Runs shell command name
. opts
should be an object, and accepts:
- args - A string containing arguments for the command,
- stdio - A runtime.stdio.StdioInterface to pipe stdio to.
ex:
var myio = new runtime.stdio.StdioInterface();
myio.onwriteline = function(text) {
console.log('hey! we got: ' + text);
};
myio.onreadline = function(cb) {
cb('foo');
};
runtime.shell.runCommand('foobar', {
args: 'someargs',
stdio: myio
}, function(retcode) {
console.log('exit with ' + retcode);
});
DNS interface for isolates.
Resolve domain
with options opts
, and when done call cb
with the result.
Example code:
runtime.dns.resolve('www.google.com', {}, function(result) {
console.log(JSON.stringify(result));
});
Example output:
{"hostname":"www.google.com","results":[{"hostname":"www.google.com","record":"A","address":[216,58,219,164],"ttl":144}]}