source: trip-planner-front/node_modules/gauge/plumbing.js@ 6a3a178

Last change on this file since 6a3a178 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'
2var consoleControl = require('console-control-strings')
3var renderTemplate = require('./render-template.js')
4var validate = require('aproba')
5
6var 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}
14Plumbing.prototype = {}
15
16Plumbing.prototype.setTheme = function (theme) {
17 validate('O', [theme])
18 this.theme = theme
19}
20
21Plumbing.prototype.setTemplate = function (template) {
22 validate('A', [template])
23 this.template = template
24}
25
26Plumbing.prototype.setWidth = function (width) {
27 validate('N', [width])
28 this.width = width
29}
30
31Plumbing.prototype.hide = function () {
32 return consoleControl.gotoSOL() + consoleControl.eraseLine()
33}
34
35Plumbing.prototype.hideCursor = consoleControl.hideCursor
36
37Plumbing.prototype.showCursor = consoleControl.showCursor
38
39Plumbing.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.