Difference between revisions of "Window (API)"
Bomb Bloke (Talk | contribs) |
MKlegoman357 (Talk | contribs) m (Recreated table using {{API table}} tag) |
||
| Line 1: | Line 1: | ||
| + | {{lowercase}} | ||
Added by ComputerCraft 1.6, the '''Window API''' allows easy definition of spaces within the display that can be written / drawn to, then later [[window.redraw|redrawn]] / [[window.reposition|repositioned]] / etc as need be. The API itself contains only one function, [[window.create|window.create()]], which returns the windows themselves. | Added by ComputerCraft 1.6, the '''Window API''' allows easy definition of spaces within the display that can be written / drawn to, then later [[window.redraw|redrawn]] / [[window.reposition|repositioned]] / etc as need be. The API itself contains only one function, [[window.create|window.create()]], which returns the windows themselves. | ||
| Line 8: | Line 9: | ||
A parent terminal object may have multiple children assigned to it, and windows may overlap. For example, the [[Multishell]] system functions by assigning each tab a window covering the screen, each using the starting terminal display as its parent, and only one of which is visible at a time. | A parent terminal object may have multiple children assigned to it, and windows may overlap. For example, the [[Multishell]] system functions by assigning each tab a window covering the screen, each using the starting terminal display as its parent, and only one of which is visible at a time. | ||
| − | |||
==API== | ==API== | ||
| − | {| | + | |
| − | + | {{API table|window|image=Grid disk.png|2= | |
| − | + | ||
| − | + | {{API table/row | |
| − | + | ||
| − | + | ||
|[[window.create]]({{type|table}} parentTerm, {{type|number}} x, {{type|number}} y, {{type|number}} width, {{type|number}} height [<nowiki/>, {{type|boolean}} visible]) | |[[window.create]]({{type|table}} parentTerm, {{type|number}} x, {{type|number}} y, {{type|number}} width, {{type|number}} height [<nowiki/>, {{type|boolean}} visible]) | ||
| + | |{{type|table}} windowObject | ||
|Creates and returns a new window object, similar to a [[peripheral.wrap|wrapped]] [[monitor]]. Refer to the [[term (API)|term API]] for a list of functions attached to it. | |Creates and returns a new window object, similar to a [[peripheral.wrap|wrapped]] [[monitor]]. Refer to the [[term (API)|term API]] for a list of functions attached to it. | ||
| − | |} | + | |odd}} |
| + | |||
| + | }} | ||
[[Category:APIs]] | [[Category:APIs]] | ||
Latest revision as of 19:21, 9 April 2014
Added by ComputerCraft 1.6, the Window API allows easy definition of spaces within the display that can be written / drawn to, then later redrawn / repositioned / etc as need be. The API itself contains only one function, window.create(), which returns the windows themselves.
Windows are considered terminal objects - as such, they have access to nearly all the commands in the term API (plus a few extras of their own, listed within said API) and are valid targets to redirect to.
Each window has a "parent" terminal object, which can be the computer's own display, a monitor, another window or even other, user-defined terminal objects. Whenever a window is rendered to, the actual screen-writing is performed via that parent (or, if that has one too, then that parent, and so forth). Bear in mind that the cursor of a window's parent will hence be moved around etc when writing a given child window.
Windows retain a memory of everything rendered "through" them (hence acting as display buffers), and if the parent's display is wiped, the window's content can be easily redrawn later. A window may also be flagged as invisible, preventing any changes to it from being rendered until it's flagged as visible once more.
A parent terminal object may have multiple children assigned to it, and windows may overlap. For example, the Multishell system functions by assigning each tab a window covering the screen, each using the starting terminal display as its parent, and only one of which is visible at a time.
API
|
| ||
|---|---|---|
| Function | Return values | Description |
| window.create(table parentTerm, number x, number y, number width, number height [, boolean visible]) | table windowObject | Creates and returns a new window object, similar to a wrapped monitor. Refer to the term API for a list of functions attached to it. |