Difference between revisions of "Multishell (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(moved Multishell (API) to Multishell: This is actually a program, not an API.)
 
(Or rather, said program leaves part of itself loaded, as an API of sorts.)
Line 1: Line 1:
#REDIRECT [[Multishell]]
+
{{lowercase}}
 +
Added by ComputerCraft 1.6, the '''Multishell API''' is used to manipulate tabs.
 +
 
 +
On boot, advanced systems will automatically launch the [[multishell|multishell script]], which by default loads only a single tab running a standard shell ([[CraftOS]] or [[TurtleOS]]). Said script also loads a number of functions into memory to be used as an API by other scripts and/or functions, allowing them to add, switch between, or rename tabs.
 +
 
 +
Note that two related, higher-level commands are also available via the [[shell (API)|shell API]] - [[shell.openTab|shell.openTab()]] and [[shell.switchTab|shell.switchTab()]].
 +
 
 +
Although this API isn't visible to the "apis" shell command, its existence (or lack thereof) provides an easy method to determine if a system has access to the multishell system (eg "if multishell then ...").
 +
 
 +
==API==
 +
 
 +
{{API table|multishell|image=Grid disk.png|2=
 +
 
 +
{{API table/row
 +
|[[multishell.getCurrent]]()
 +
|{{type|number}} tab
 +
|Returns the ID of the currently running tab.
 +
|odd}}
 +
 
 +
{{API table/row
 +
|[[multishell.getCount]]()
 +
|{{type|number}} tabCount
 +
|Returns the number of tabs currently being handled by the multishell system.
 +
}}
 +
 
 +
{{API table/row
 +
|[[multishell.launch]]({{type|table}} environment, {{type|string}} program path [, {{type|string}} arguments])
 +
|{{type|number}} newTabID
 +
|Launches the specified script in a new tab.
 +
|odd}}
 +
 
 +
{{API table/row
 +
|[[multishell.setFocus]]({{type|number}} tab)
 +
|{{type|boolean}} success
 +
|Switches focus to the specified tab.
 +
}}
 +
 
 +
{{API table/row
 +
|[[multishell.setTitle]]({{type|number}} tab, {{type|string}} title)
 +
|
 +
|Relabels the specified tab to use the specified title.
 +
|odd}}
 +
 
 +
{{API table/row
 +
|[[multishell.getTitle]]()
 +
|{{type|string}} title
 +
|Returns the title of the specified tab.
 +
}}
 +
 
 +
{{API table/row
 +
|[[multishell.getFocus]]()
 +
|{{type|number}} tab
 +
|Returns the ID of the currently focused tab.
 +
|odd}}
 +
}}
 +
 
 +
[[Category:APIs]]

Revision as of 11:15, 10 April 2014

Added by ComputerCraft 1.6, the Multishell API is used to manipulate tabs.

On boot, advanced systems will automatically launch the multishell script, which by default loads only a single tab running a standard shell (CraftOS or TurtleOS). Said script also loads a number of functions into memory to be used as an API by other scripts and/or functions, allowing them to add, switch between, or rename tabs.

Note that two related, higher-level commands are also available via the shell API - shell.openTab() and shell.switchTab().

Although this API isn't visible to the "apis" shell command, its existence (or lack thereof) provides an easy method to determine if a system has access to the multishell system (eg "if multishell then ...").

API

Grid disk.png  multishell (API)
Function Return values Description
multishell.getCurrent() number tab Returns the ID of the currently running tab.
multishell.getCount() number tabCount Returns the number of tabs currently being handled by the multishell system.
multishell.launch(table environment, string program path [, string arguments]) number newTabID Launches the specified script in a new tab.
multishell.setFocus(number tab) boolean success Switches focus to the specified tab.
multishell.setTitle(number tab, string title) Relabels the specified tab to use the specified title.
multishell.getTitle() string title Returns the title of the specified tab.
multishell.getFocus() number tab Returns the ID of the currently focused tab.