"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/gauge/plumbing.js" (8 Mar 2017, 1228 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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.eraseLine() + consoleControl.gotoSOL()
   47 }