Difference between revisions of "Window (API)"

From ComputerCraft Wiki
Jump to: navigation, search
m (Added {{NeedsWork}} tag)
Line 1: Line 1:
{{NeedsWork|This page needs more explanation and examples. [[User:MKlegoman357|MKlegoman357]] 09:22, 6 April 2014 (GMT)}}
+
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.
 +
 
 +
Windows are considered terminal objects - as such, they have access to nearly all the commands in the [[Term (API)|term API]] (plus a few extras of their own, listed within said API) and are valid targets to [[term.redirect|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 [[window.redraw|redrawn]] later. A window may also be flagged as [[window.setVisible|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.
  
Added by ComputerCraft 1.6, the '''Window API''' allows easy definition of spaces within the display that can be written / drawn to, then repositioned or hidden (along with their contents).
 
  
 
==API==
 
==API==

Revision as of 15:14, 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

Returns Method name Description
table window object window.create(table parentTerm, number x, number y, number width, number height [, boolean visible]) 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.