Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Internal API

Ariel Abreu edited this page Jul 12, 2015 · 5 revisions

Note: the following was added by @ArielAbreu (NOT the author of runtime.js) and is only partially documented.


require('runtimejs')

These are things accessible through requiring 'runtimejs':


runtime.tty

Terminal interface object

runtime.tty.color {}

Collection of colors for the terminal interface.

runtime.tty.print(text, [repeat], [fg], [bg])

Prints text to the terminal. Reprinted repeat time(s). fg for text color, bg for background text color.

runtime.tty.moveOffset(offset)

Moves screen position by adding the offset.

runtime.tty.moveTo(x, y)

Moves screen to specified x and y coordinates. Unlike moveOffset(), it is not relevant to the current screen position.


runtime.keyboard

Keyboard functions provided

runtime.keyboard.onKeydown EventController

Event controller for key down events. By default has one listener (the terminal input controller).

runtime.keyboard.onKeyup EventController

Event controller for key up events.


runtime.pci

PCI controller for runtime.js, also enables device drivers.

runtime.pci.addDriver(vendorId, deviceId, opts)

Finds device using vendorId and deviceId and, if found, sets opts as device driver.


runtime.ps2

PS2 controller for runtime.js

runtime.ps2.setKeyboardDriver(driver)

Sets driver as driver for keyboard.


runtime.allocator

??

runtime.allocator.allocDMA(??)

allocDMA function in runtime.allocator... usage: unknown


runtime.net

Network access in runtime.js

runtime.net.interfaceAdd(intf)

Adds intf to the interfaces available to runtime.js Useful for network adapters.

runtime.net.TCPSocket class

runtime.js TCPSocket interface class, provides access to a TCPSocket. See the runtime.net.TCPSocket page. (yet to be created)

runtime.net.TCPServerSocket class

runtime.js TCPServerSocket interface class, provides access to a TCPSocket server. See the runtime.net.TCPSocket page. (yet to be created)

runtime.net.UDPSocket class

runtime.js UDPSocket interface class, provides access to a UDPSocket. See the runtime.net.UDPSocket page. (yet to be created)

runtime.net.IP4Address(a, b, c, d)

Creates an IP4Address object from a, b, c, and d, without the dots.

runtime.net.MACAddress(a, b, c, d, e, f)

Creates a MACAddress object from a, b, c, d, e, and f, without the colons.

runtime.net.Interface(macAddr)

Creates an Interface object from the given macAddr, which must be an instance of runtime.net.MACAddress.

runtime.net.route {}

Collection of IP route functions

runtime.net.route.addSubnet(ip, mask, gateway, intf)

Adds a new subnet route

runtime.net.route.addDefault(gateway, intf)

Adds the specifed gateway and intf as the default.

runtime.net.route.lookup(destIP, intf)

??

runtime.net.onInterfaceAdded EventController

Controller triggered when an interface is added.

runtime.net.onInterfaceRemoved EventController

Controller triggered when an interface is removed.


runtime.bufferAdress(??)

Gets buffer address.


runtime.debug bool

In debug mode? true or false, default false.


runtime.machine

Native functions

runtime.machine.shutdown()

Shuts down the computer.

runtime.machine.reboot()

Reboots the computer.


runtime.shell

Shell access for isolates.

runtime.shell.setCommand(name, cb)

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.
});

runtime.shell.runCommand(name, opts, cb)

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);
});

runtime.dns

DNS interface for isolates. TODO: document DNS

Clone this wiki locally