Skip to content

Latest commit

 

History

History
150 lines (86 loc) · 5.11 KB

Container.md

File metadata and controls

150 lines (86 loc) · 5.11 KB

Container

Container is the base class of ALL document model objects having their own screenBuffer, most notably the Document instance.

A container has its own inputDst used as an outputDst for all its children, i.e. the exposed drawing area for its children. In conjunction with the rectangular viewport used for clipping, that Dst may eventually be much bigger than what is actually displayed on the terminal, it can be used to virtually enlarge the available area, for clipping/scrolling/overflowing purpose, and so one...

Everything needing an intermediate screenBuffer is an instance of Container.

Table of Contents

new Container( options )

  • options Object, where:
    • inputX, inputY number the position of the inputDst relative to its outputDst, default to outputX, outputY or x, y when there is no clipping/scrolling
    • inputWidth, inputHeight number the size of the inputDst, default to outputWidth, outputHeight or width, height when there is no clipping/scrolling, i.e. when the inputDst is fully drawn into the outputDst
    • movable boolean when set, the container can be moved using with a mouse drag (default: false)
    • scrollable boolean if set, the container is scrollable (default: false)
    • hasHScrollBar boolean if set and if scrollable, the container has a horizontal scrollbar
    • hasVScrollBar boolean if set and if scrollable, the container has a vertical scrollbar
    • scrollX number the initial horizontal scroll value, default: 0
    • scrollY number the initial vertical scroll value, default: 0
    • palette Palette a Palette instance, default to the current document's palette
    • backgroundAttr number or object the background attributes for the inputDst screenBuffer, default to { bgColor: 'default' }

While Container is a super-class that is never directly instantiated, the derived class's constructor always call the Container constructor with the options object. This contains all options that are common to all type of Container.

.resizeViewport( rect )

  • rect Rect or Rect-like object, see Rect

Resize the container viewport, the rectangle used to clip the inputDst before writing it to the outputDst.

.resizeInput( rect )

  • rect Rect or Rect-like object, see Rect

Resize this container own screenBuffer, the inputDst for its children to write on.

.resize( rect )

  • rect Rect or Rect-like object, see Rect

Resize both the inputDst and the viewport with the same size (like calling .resizeInput() and .resizeViewport() with the same arguments).

.move( dx , dy )

  • dx, dy number the delta of the position of the container relative to itself

Move that container relative to its current position. In other words, change the position of its own screenBuffer relative to its parent screenBuffer.

.moveTo( x , y )

  • x, y number the position of the container relative to its parent container

Move that container to a position relative to its parent's container. In other words, change the position of its own screenBuffer relative to its parent screenBuffer.

.scrollTo( x , y )

  • x, y number the new scrolling coordinates

This scrolls the container to the x,y coordinates and updates scrollbars.

.scroll( dx , dy )

  • dx, dy number the delta of the scroll

This scrolls the container from this x,y delta and updates scrollbars.

.scrollToTop()

This scrolls the container to the top and updates scrollbars.

.scrollToBottom()

This scrolls the container to the bottom and updates scrollbars.

.inputDst

This property holds the underlying screenBuffer object. It can be used to achieve more complex stuffs.