- ConsoleManager ⇐
EventEmitter
- Screen :
Screen The screen instance
- logLocation :
number|'popup' Choose where the logs are displayed: number (0,1) - to pot them on one of the two layouts, string ("popup") - to put them on a CustomPopup that can be displayed on the window.
- stdOut :
PageBuilder The logs page
- changeLayoutKey :
string The key or combination to switch the selected page
- homePage :
Array.<PageBuilder> The main application
- layout :
LayoutManager The layout instance
- KeyListenerArgs :
Object This type is used to define the parameters of the KeyListener event (keypress).
- ConsoleGuiOptions :
Object This type is used to define the ConsoleGui options.
This type is used to define the parameters of the KeyListener event (keypress).
Kind: global interface
Properties
| Name | Type | Description |
|---|---|---|
| name | string |
The name of the key pressed. |
| ctrl | boolean |
If the ctrl key is pressed. |
| shift | boolean |
If the shift key is pressed. |
| alt | boolean |
If the alt key is pressed. |
| meta | boolean |
If the meta key is pressed. |
| sequence | boolean |
If the sequence of keys is pressed. |
This type is used to define the ConsoleGui options.
Kind: global interface
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [title] | string |
The title of the ConsoleGui. |
|
| [logLocation] | 0 | 1 | 2 | 3 | "popup" |
The location of the logs. |
|
| [showLogKey] | string |
The key to show the log. |
|
| [logPageSize] | number |
The size of the log page. |
|
| [layoutOptions] | LayoutOptions |
The options of the layout. |
|
| [enableMouse] | boolean |
If the mouse should be enabled. |
|
| [overrideConsole] | boolean |
true |
If the console.log |
| [focusKey] | string |
""tab"" |
The key to focus the next widget. |
Kind: global class
Extends: EventEmitter
- ConsoleManager ⇐
EventEmitter- new ConsoleManager(options)
- .setLayoutOptions(options, [update])
- .updateLayout()
- .getLayoutOptions() ⇒
LayoutOptions - .getLogPageSize() ⇒
number - .setLogPageSize(size) ⇒
void - .unfocusOtherWidgets(widget)
- .addGenericListeners()
- .setKeyListener(id, manageFunction)
- .removeKeyListener(id)
- .setMouseListener(id, manageFunction)
- .removeMouseListener(id)
- .registerPopup(popup)
- .unregisterPopup(id)
- .registerControl(control)
- .unregisterControl(id)
.setHomePage(page)- .setPage(page, [pageNumber], [title])
- .setPages(pages, [titles])
- .refresh()
- .showLogPopup() ⇒
- .log(message)
- .error(message)
- .warn(message)
- .info(message)
- .updateLogsConsole(resetCursor)
- .overrideConsole()
This class is used to manage the console GUI and all the widgets. This is a singleton class, so you can use it like this: const CM = new ConsoleManager() Emits the following events:
- "keypressed" to propagate the key pressed event to the application
- "layoutratiochanged" when the layout ratio is changed
- "exit" when the user wants to exit the application
| Param | Type | Description |
|---|---|---|
| options | object |
The options of the ConsoleManager. |
Example
const CM = new ConsoleManager({ logPageSize: 10, layoutBorder: true, changeLayoutKey: 'ctrl+l', title: 'Console Application' })This method is used to change the layout options. if update is true, the layout will be updated.
Kind: instance method of ConsoleManager
| Param | Type | Default |
|---|---|---|
| options | LayoutOptions |
|
| [update] | boolean |
true |
Example
CM.setLayoutOptions({ showTitle: true, boxed: true, boxColor: 'cyan', boxStyle: 'bold', changeFocusKey: 'ctrl+l', type: 'double', direction: 'vertical' })Example
CM.setLayoutOptions({ ...CM.getLayoutOptions(), type: "quad" })This method is used to update the layout
Kind: instance method of ConsoleManager
This method is used to get the layout options.
Kind: instance method of ConsoleManager
Returns: LayoutOptions -
The layout options.
Example
CM.getLayoutOptions()Example
CM.getLayoutOptions().boxedThis method is used to get the log page size.
Kind: instance method of ConsoleManager
Returns: number -
The log page size.
Example
CM.getLogPageSize()This method is used to set the log page size.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| size | number |
The new log page size. |
Example
CM.setLogPageSize(10)This method is used to remove focus from other widgets.
Kind: instance method of ConsoleManager
| Param | Type |
|---|---|
| widget | string |
This function is used to make the ConsoleManager handle the key events when no widgets are showed. Inside this function are defined all the keys that can be pressed and the actions to do when they are pressed.
Kind: instance method of ConsoleManager
This function is used to set a key listener for a specific widget. The event listener is stored in the eventListenersContainer object.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| id | string |
The id of the widget. |
| manageFunction | function |
The function to call when the key is pressed. |
Example
CM.setKeyListener('inputPopup', popup.keyListener)This function is used to remove a key listener for a specific widget. The event listener is removed from the eventListenersContainer object.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| id | string |
The id of the widget. |
Example
CM.removeKeyListener('inputPopup')This function is used to set a mouse listener for a specific widget. The event listener is stored in the eventListenersContainer object.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| id | string |
The id of the widget. |
| manageFunction | function |
The function to call when the key is pressed. |
Example
CM.setMouseListener('inputPopup', popup.mouseListener)This function is used to remove a mouse listener for a specific widget. The event listener is removed from the eventListenersContainer object.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| id | string |
The id of the widget. |
Example
CM.removeMouseListener('inputPopup')This function is used to register a popup. The popup is stored in the popupCollection object. That is called by the popups in show().
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| popup | popup |
The popup to register. |
This function is used to unregister a popup. The popup is removed from the popupCollection object. That is called by the popups in hide().
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| id | string |
The id of the popup. |
This function is used to register a control. The control is stored in the controlCollection object. That is called by the controls in show().
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| control | control |
The control to register. |
This function is used to unregister a control. The control is removed from the controlCollection object. That is called by the controls in hide().
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| id | string |
The id of the control. |
Deprecated
This function is used to set the home page. It also refresh the screen.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| page | PageBuilder |
The page to set as home page. |
Example
CM.setHomePage(p)This function is used to set a page of layout. It also refresh the screen.
Kind: instance method of ConsoleManager
| Param | Type | Default | Description |
|---|---|---|---|
| page | PageBuilder |
The page to set as home page. |
|
| [pageNumber] | number |
0 |
The page number to set. 0 is the first page, 1 is the second page. |
| [title] | string | null |
null |
The title of the page to overwrite the default title. Default is null. |
Example
CM.setPage(p, 0)This function is used to set both pages of layout. It also refresh the screen.
Kind: instance method of ConsoleManager
| Param | Type | Default | Description |
|---|---|---|---|
| pages | Array.<PageBuilder> |
The page to set as home page. |
|
| [titles] | Array.<string> | null |
|
The titles of the page to overwrite the default titles. Default is null. |
Example
CM.setPages([p1, p2], 0)This function is used to refresh the screen. It do the following sequence: Clear the screen, draw layout, draw widgets and finally print the screen to the stdOut.
Kind: instance method of ConsoleManager
Example
CM.refresh()This function is used to show a popup containing all the stdOut of the console.
Kind: instance method of ConsoleManager
Returns:
the instance of the generated popup.
Example
CM.showLogPopup()This function is used to log a message. It is used to log messages in the log page. Don't add colors to the message.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| message | string |
The message to log. |
Example
CM.log("Hello world")This function is used to log an error message. It is used to log red messages in the log page. Don't add colors to the message.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| message | string |
The message to log. |
Example
CM.error("Anomaly detected")This function is used to log a warning message. It is used to log yellow messages in the log page. Don't add colors to the message.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| message | string |
The message to log. |
Example
CM.warn("Anomaly detected")This function is used to log an info message. It is used to log blue messages in the log page. Don't add colors to the message.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| message | string |
The message to log. |
Example
CM.info("Anomaly detected")This function is used to update the logs console. It is called by the log functions.
Kind: instance method of ConsoleManager
| Param | Type | Description |
|---|---|---|
| resetCursor | boolean |
If true, the log scroll index is resetted. |
This function is used to override the console.log, console.error, console.warn and console.info functions.
Kind: instance method of ConsoleManager
Since: 1.1.42
Example
CM.overrideConsole()Example
console.log("Hello world") // Will be logged in the log page.Example
console.error("Anomaly detected") // Will be logged in the log page.Example
console.warn("Anomaly detected") // Will be logged in the log page.Example
console.info("Anomaly detected") // Will be logged in the log page.Example
console.debug("Anomaly detected") // Will be logged in the log page.Screen : Screen
The screen instance
Choose where the logs are displayed: number (0,1) - to pot them on one of the two layouts, string ("popup") - to put them on a CustomPopup that can be displayed on the window.
The logs page
The key or combination to switch the selected page
The main application
The layout instance
Kind: global constant