Skip to content

Latest commit

 

History

History
228 lines (169 loc) · 7.85 KB

LayoutManager.md

File metadata and controls

228 lines (169 loc) · 7.85 KB

Classes

LayoutManager

Constants

CM : ConsoleManager

the instance of ConsoleManager (singleton)

pageTitle : string

The application title.

Interfaces

LayoutOptions : Object

The type containing all the possible options for the layout.

LayoutOptions : Object

The type containing all the possible options for the layout.

Kind: global interface
Properties

Name Type Description
[showTitle] boolean

If the title should be shown.

[boxed] boolean

If the layout should be boxed.

[boxColor] ForegroundColorName | HEX | RGB | ""

The color of the box taken from the chalk library.

[boxStyle] "bold"

If the border of the box should be bold.

[type] "single" | "double" | "triple" | "quad"

The type of the layout.

[changeFocusKey] string

The key that should be pressed to change the focus.

[direction] "horizontal" | "vertical"

The direction of the layout.

[pageTitles] Array.<string>

The title of the first page.

[pageRatio] Array.<number>

The ratio of the pages. (in horizontal direction)

[fitHeight] boolean

If the height of the pages should be the same.

LayoutManager

Kind: global class

new LayoutManager(pages, options)

This class is a layout that has two pages.

change ratio

Param Type Description
pages Array.<PageBuilder>

The pages that should be shown.

options boolean

Layout options.

Example

const layout = new LayoutManager([page1, page2], pageOptions);

layoutManager.setPages(pages)

This function is used to update the layout pages.

Kind: instance method of LayoutManager

Param Type Description
pages Array.<PageBuilder>

The pages that should be shown.

Example

layout.updatePages([page1, page2])

Example

layout.updatePages([page1, page2, page3])

layoutManager.setPage(page, index)

This function is used to overwrite the page content.

Kind: instance method of LayoutManager

Param Type Description
page PageBuilder

the page to be added

index number

the index of the page

layoutManager.setTitle(title, index)

This function is used to update the page title.

Kind: instance method of LayoutManager

Param Type Description
title string

The title of the page.

index number

The index of the page.

Example

layout.setTitle("Page Title", 1)

layoutManager.setTitles(titles)

This function is used to update the page titles.

Kind: instance method of LayoutManager

Param Type Description
titles Array.<string>

The titles of the pages.

Example

layout.setTitles(["Page Title 1", "Page Title 2"])

layoutManager.setBorder(border)

This function is used to enable or disable the layout border.

Kind: instance method of LayoutManager

Param Type Description
border boolean

enable or disable the border

layoutManager.setSelected(selected)

This function is used to choose the page to be highlighted.

Kind: instance method of LayoutManager

Param Type Description
selected 0 | 1 | 2 | 3

0 for page1, 1 for page2

layoutManager.getSelected() ⇒ 0 | 1 | 2 | 3

This function is used to get the selected page.

Kind: instance method of LayoutManager
Returns: 0 | 1 | 2 | 3 -

0 for page1, 1 for page2, 2 for page3, 3 for page4


layoutManager.changeLayout() ⇒ void

This function is used to get switch the selected page. If the layout is a single layout, it will do nothing.

Kind: instance method of LayoutManager

layoutManager.decreaseRatio(quantity)

This function is used to decrease the row ratio between the pages in the selected row. This is propagated to the layout instance.

Kind: instance method of LayoutManager

Param Type Description
quantity quantity

The amount of aspect ratio to be decreased.

Example

layout.decreaseRowRatio(0.01)

layoutManager.increaseRatio(quantity)

This function is used to increase the row ratio between the pages in the selected row. This is propagated to the layout instance.

Kind: instance method of LayoutManager

Param Type Description
quantity quantity

The amount of aspect ratio to be increased.

Example

layout.increaseRowRatio(0.01)

layoutManager.draw() ⇒ void

This function is used to draw the layout to the screen.

Kind: instance method of LayoutManager
Example

layout.draw()

CM : ConsoleManager

the instance of ConsoleManager (singleton)

Kind: global constant

pageTitle : string

The application title.

Kind: global constant