Last change
on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years 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) width = 80
|
---|
8 | validate('OAN', [theme, template, width])
|
---|
9 | this.showing = false
|
---|
10 | this.theme = theme
|
---|
11 | this.width = width
|
---|
12 | this.template = template
|
---|
13 | }
|
---|
14 | Plumbing.prototype = {}
|
---|
15 |
|
---|
16 | Plumbing.prototype.setTheme = function (theme) {
|
---|
17 | validate('O', [theme])
|
---|
18 | this.theme = theme
|
---|
19 | }
|
---|
20 |
|
---|
21 | Plumbing.prototype.setTemplate = function (template) {
|
---|
22 | validate('A', [template])
|
---|
23 | this.template = template
|
---|
24 | }
|
---|
25 |
|
---|
26 | Plumbing.prototype.setWidth = function (width) {
|
---|
27 | validate('N', [width])
|
---|
28 | this.width = width
|
---|
29 | }
|
---|
30 |
|
---|
31 | Plumbing.prototype.hide = function () {
|
---|
32 | return consoleControl.gotoSOL() + consoleControl.eraseLine()
|
---|
33 | }
|
---|
34 |
|
---|
35 | Plumbing.prototype.hideCursor = consoleControl.hideCursor
|
---|
36 |
|
---|
37 | Plumbing.prototype.showCursor = consoleControl.showCursor
|
---|
38 |
|
---|
39 | Plumbing.prototype.show = function (status) {
|
---|
40 | var values = Object.create(this.theme)
|
---|
41 | for (var key in status) {
|
---|
42 | values[key] = status[key]
|
---|
43 | }
|
---|
44 |
|
---|
45 | return renderTemplate(this.width, this.template, values).trim() +
|
---|
46 | consoleControl.color('reset') +
|
---|
47 | consoleControl.eraseLine() + consoleControl.gotoSOL()
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.