How to use the ansi-colors.unstyle function in ansi-colors

To help you get started, we’ve selected a few ansi-colors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jonschlinkert / tabstops / examples / support / prompt.js View on Github external
session.right();
    } else if (event.name === 'up') {
      session[event.shift === true ? 'shiftup' : 'up']();
    } else if (event.name === 'down') {
      session[event.shift === true ? 'shiftdown' : 'down']();
    } else if (item.readonly !== true) {
      // session.dispatch(input, event);
      if (event.name === 'backspace' || event.name === 'delete') {
        item.input = item.input.slice(0, -1);
      } else {
        item.input = item.input + input;
      }

      item.input = item.input.replace(/\r/g, '');
      item.input = item.input.replace(/\\?"/g, '\\"');
      session.values.set(item.key, colors.unstyle(item.input));
    }

    update(session.render());
  });
github enquirer / enquirer / test / prompt.multiselect.js View on Github external
prompt.once('run', async() => {
        let init = colors.unstyle([prompt.symbols.pointer, prompt.options.initial].join(' '));
        await prompt.render();
        try {
          let buf = colors.unstyle(prompt.state.buffer);
          assert(!buf.includes(init));
          prompt.submit();
          cb();
        } catch (err) {
          cb(err);
        }
      });
github enquirer / enquirer / test / prompt.js View on Github external
it('should use custom symbols', () => {
      prompt = new Prompt({
        message: 'prompt',
        symbols: {
          indicator: 'X',
          check: 'ok',
          prefix: '?',
          separator: '|>'
        }
      });

      assert.equal(colors.unstyle(prompt.symbols.separator), '|>');
      assert.equal(colors.unstyle(prompt.symbols.indicator), 'X');
      assert.equal(colors.unstyle(prompt.symbols.prefix), '?');
    });
  });
github stratosphereips / StratosphereLinuxIPS / modules / blessed / ips_timewindows.js View on Github external
tree.on('select',function(node){
  
  screen.key('w',function(ch,key){
    clipboardy.writeSync(color.unstyle(node.name));
    clipboardy.readSync();
  })
    clean_widgets()

    if(!node.name.includes('timewindow')){
      getIpInfo_box_ip(color.unstyle(node.name), 1);}
      
    else{
      ip  = color.unstyle(node.parent.name);
      timewindow = color.unstyle(node.name);
  
      redis_outtuples_timewindow.hgetall("profile_"+ip+"_"+timewindow, (err,reply)=>{
        var ips = [];
        timeline_reply_global = reply;
        map.innerMap.draw(null);
        getEvidence(reply['Evidence']);
        
        var obj_outTuples = JSON.parse(reply["OutTuples"]);
        var keys = Object.keys(obj_outTuples);
        async.each(keys, function(key,callback){        
          var outTuple_ip = key.split(':')[0];
          ips.push(outTuple_ip); 
          callback(null);  
        },function(err) {
      if( err ) {
        console.log('unable to create user');
github enquirer / enquirer / lib / prompt.js View on Github external
sections() {
    let { buffer, input, prompt } = this.state;
    prompt = colors.unstyle(prompt);
    let buf = colors.unstyle(buffer);
    let idx = buf.indexOf(prompt);
    let header = buf.slice(0, idx);
    let rest = buf.slice(idx);
    let lines = rest.split('\n');
    let first = lines[0];
    let last = lines[lines.length - 1];
    let promptLine = prompt + (input ? ' ' + input : '');
    let len = promptLine.length;
    let after = len < first.length ? first.slice(len + 1) : '';
    return { header, prompt: first, after, rest: lines.slice(1), last };
  }
github enquirer / enquirer / lib / ansi.js View on Github external
  let width = str => [...colors.unstyle(str)].length;
  let lines = input.split(/\r?\n/);
github enquirer / enquirer / recipes / form.js View on Github external
renderChoice(choice, index) {
    const len = this.longest + 1;
    let message = trim(choice.message).padStart(len, ' ') + ' ';
    let value = choice.value || choice.hint || '';
    let prefix = message;

    if (this.answered) {
      return prefix + colors.cyan(colors.unstyle(value));
    }

    if (this.cursor === index) {
      if (this.action && this.options.history) {
        let state = this.history(this.action, choice.name, choice.value);
        if (state.present) {
          this.store.set(choice.name, state);
          value = this.value = choice.value = state.present;
        }
      }
      prefix = colors.cyan(message);
    }

    return prefix + value + (choice.help || '');
  }
github jonschlinkert / tabstops / lib / nodes / TabstopPlaceholder.js View on Github external
return (data = {}) => {
      let init = this.initial;
      let value = this.tabstops.get(this.number);
      let state = { resolved: 'tabstop', value };

      if ((init && init.value === state.value) || !this.isValue(state.value)) {
        state.resolved = 'placeholder';
        state.value = this.placeholder(data, options);

        if (this.hasTextPlaceholder()) {
          this.tabstops.set(this.number, colors.unstyle(state.value));
        }

      } else {
        this.tabstops.set(this.number, colors.unstyle(state.value));
      }

      return this.format(state, options);
    };
  }
github enquirer / enquirer / lib / style / elements.js View on Github external
get off() {
      let on = colors.unstyle(this.on()).trim();
      return ' '.repeat(on.length);
    },
    get default() {
github stratosphereips / StratosphereLinuxIPS / modules / blessed / ips_timewindows.js View on Github external
screen.key('w',function(ch,key){
    clipboardy.writeSync(color.unstyle(node.name));
    clipboardy.readSync();
  })
    clean_widgets()

ansi-colors

Easily add ANSI colors to your text and symbols in the terminal. A faster drop-in replacement for chalk, kleur and turbocolor (without the dependencies and rendering bugs).

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis