finki-main
main
|
Last change
on this file since 81bc7da was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago |
|
Initial commit
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | 'use strict'
|
|---|
| 2 | var consoleControl = require('console-control-strings')
|
|---|
| 3 | var renderTemplate = require('./render-template.js')
|
|---|
| 4 | var validate = require('aproba')
|
|---|
| 5 |
|
|---|
| 6 | var Plumbing = module.exports = function (theme, template, width) {
|
|---|
| 7 | if (!width) {
|
|---|
| 8 | width = 80
|
|---|
| 9 | }
|
|---|
| 10 | validate('OAN', [theme, template, width])
|
|---|
| 11 | this.showing = false
|
|---|
| 12 | this.theme = theme
|
|---|
| 13 | this.width = width
|
|---|
| 14 | this.template = template
|
|---|
| 15 | }
|
|---|
| 16 | Plumbing.prototype = {}
|
|---|
| 17 |
|
|---|
| 18 | Plumbing.prototype.setTheme = function (theme) {
|
|---|
| 19 | validate('O', [theme])
|
|---|
| 20 | this.theme = theme
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | Plumbing.prototype.setTemplate = function (template) {
|
|---|
| 24 | validate('A', [template])
|
|---|
| 25 | this.template = template
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | Plumbing.prototype.setWidth = function (width) {
|
|---|
| 29 | validate('N', [width])
|
|---|
| 30 | this.width = width
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | Plumbing.prototype.hide = function () {
|
|---|
| 34 | return consoleControl.gotoSOL() + consoleControl.eraseLine()
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | Plumbing.prototype.hideCursor = consoleControl.hideCursor
|
|---|
| 38 |
|
|---|
| 39 | Plumbing.prototype.showCursor = consoleControl.showCursor
|
|---|
| 40 |
|
|---|
| 41 | Plumbing.prototype.show = function (status) {
|
|---|
| 42 | var values = Object.create(this.theme)
|
|---|
| 43 | for (var key in status) {
|
|---|
| 44 | values[key] = status[key]
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | return renderTemplate(this.width, this.template, values).trim() +
|
|---|
| 48 | consoleControl.color('reset') +
|
|---|
| 49 | consoleControl.eraseLine() + consoleControl.gotoSOL()
|
|---|
| 50 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.