How to use the ansi-escapes.eraseEndLine function in ansi-escapes

To help you get started, we’ve selected a few ansi-escapes 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 Akryum / monorepo-run / src / util / ansi.js View on Github external
...(genSeq(ansiEscapes.cursorTo, 0, 10)),
  ...(genSeq2(ansiEscapes.cursorTo, 0, 10, 0, 10)),
  ...(genSeq(ansiEscapes.cursorMove, -10, 10)),
  ...(genSeq2(ansiEscapes.cursorMove, -10, 10, -10, 10)),
  ...(genSeq(ansiEscapes.cursorUp, -10, 10)),
  ...(genSeq(ansiEscapes.cursorDown, -10, 10)),
  ...(genSeq(ansiEscapes.cursorForward, -10, 10)),
  ...(genSeq(ansiEscapes.cursorBackward, -10, 10)),
].map(e => `(${exports.escapeAnsiEscapeSeq(e)})`).join('|'), 'g')

exports.stripAnsiEscapeSeqs = (s) => s.replace(ansiEscapeSeqsReg, '')

const eraseLineEscapeSeqsReg = new RegExp([
  ansiEscapes.eraseLine,
  ansiEscapes.eraseStartLine,
  ansiEscapes.eraseEndLine,
  `${ESC}0K`,
  ...(genSeq(ansiEscapes.cursorTo, 0, 10)),
].map(e => `(${exports.escapeAnsiEscapeSeq(e)})`).join('|'), 'g')

exports.countEraseLineEscapeSeqs = (str) => {
  return ((str || '').match(eraseLineEscapeSeqsReg) || []).length
}

function genSeq (fn, from, to) {
  const result = []
  for (let i = from; i <= to; i++) {
    result.push(fn(i))
  }
  return result
}
github heapwolf / cdir / cdir.js View on Github external
process.nextTick(function() {

    up();
    write(ansi.eraseEndLine + '\r');
    write(ansi.eraseEndLine + '\r\n');
    var dobj = decycle(obj);

    constructMeta(getType(dobj), 0, dobj);
    renderMeta();

  });
github jdxcode / password-prompt / index.js View on Github external
function backspace () {
        if (input.length === 0) return
        input = input.substr(0, input.length - 1)
        stderr.write(ansi.cursorBackward(1))
        stderr.write(ansi.eraseEndLine)
      }
github avajs / ava / lib / worker / fake-tty.js View on Github external
clearLine(dir, callback) {
		assertCallback(callback);

		switch (dir) {
			case -1:
				return this.write(ansiEscapes.eraseStartLine, callback);
			case 1:
				return this.write(ansiEscapes.eraseEndLine, callback);
			default:
				return this.write(ansiEscapes.eraseLine, callback);
		}
	},
github alexkuz / nyan-progress-webpack-plugin / index.js View on Github external
var inverse = AnsiStyles.inverse;

var red = AnsiStyles.red;
var yellow = AnsiStyles.yellow;
var green = AnsiStyles.green;
var blue = AnsiStyles.blue;
var magenta = AnsiStyles.magenta;

var bgRed = AnsiStyles.bgRed;
var bgYellow = AnsiStyles.bgYellow;
var bgGreen = AnsiStyles.bgGreen;
var bgBlue = AnsiStyles.bgBlue;

var cursorUp = AnsiEscapes.cursorUp;
var cursorDown = AnsiEscapes.cursorDown;
var eraseEndLine = AnsiEscapes.eraseEndLine;
var cursorSavePosition = AnsiEscapes.cursorSavePosition;
var cursorRestorePosition = AnsiEscapes.cursorRestorePosition;

var width = 50;
var stdoutLineCount = 0;

var nyanTemplate = {
  ascii: [
    ' ,--------,     ',
    ' │▗▝ ▞ ▝ ˄---˄  ',
    '~│ ▞  ▞ ❬.◕‿‿◕.❭',
    ' `w-w---- w w   '
  ],
  colors: [
    ' ggggggggggg    ',
    ' gMMMMMMMggggg  ',
github heapwolf / cdir / cdir.js View on Github external
process.nextTick(function() {

    up();
    write(ansi.eraseEndLine + '\r');
    write(ansi.eraseEndLine + '\r\n');
    var dobj = decycle(obj);

    constructMeta(getType(dobj), 0, dobj);
    renderMeta();

  });
github heroku / heroku-cli-util / lib / prompt.js View on Github external
function backspace () {
      if (input.length === 0) return
      input = input.substr(0, input.length - 1)
      stderr.write(ansi.cursorBackward(1))
      stderr.write(ansi.eraseEndLine)
    }
github heroku / heroku-cli-util / lib / prompt.js View on Github external
function backspace () {
      if (input.length === 0) return
      input = input.substr(0, input.length - 1)
      stderr.write(ansi.cursorBackward(1))
      stderr.write(ansi.eraseEndLine)
    }