How to use the ansi-escapes.clearScreen 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 rjrodger / sneeze / sneeze.js View on Github external
function render() {
    var size_host = 4
    var size_meta = 4
    var size_tag = 3

    sortedmembers.forEach(function(m) {
      size_host = Math.max(size_host, m.host.length)
      size_meta = Math.max(size_meta, m.meta.length)
      size_tag = Math.max(size_tag, m.tag.length)
    })

    var nm = sortedmembers.length

    w(AE.clearScreen)
    w(AE.cursorHide)
    w(AE.cursorUp(nm + 2))
    w(AE.eraseDown)

    console.log(
      head(
        [
          Pad('host', size_host),
          Pad(2, 'a'),
          Pad(2, 'r'),
          Pad(2, 's'),
          Pad(8, 'time'),
          Pad('tag', size_tag),
          Pad('meta', size_meta),
          'id'
        ].join(' ')
github react-display-window / react-display-window / src / cli / webpack.config.js View on Github external
customSummary: () => {
          if (outDir != null) {
            console.log(chalk.bold('Finished'), chalk.green('✔︎'));
          }
          else {
            process.stdout.write(ansiEscapes.clearScreen);
            process.stdout.write(initialMessage(port, []).join('\n'));
          }
        },
      })),
github jest-community / jest-watch-typeahead / src / shared / pattern_prompt.js View on Github external
run(onSuccess: Function, onCancel: Function, options?: { header: string }) {
    this._pipe.write(ansiEscapes.cursorHide);
    this._pipe.write(ansiEscapes.clearScreen);

    if (options && options.header) {
      this._pipe.write(`${options.header}\n`);
      this._currentUsageRows = usageRows + options.header.split('\n').length;
    } else {
      this._currentUsageRows = usageRows;
    }

    this._pipe.write(usage(this._entityName));
    this._pipe.write(ansiEscapes.cursorShow);

    this._prompt.enter(this._onChange.bind(this), onSuccess, onCancel);
  }
github rnegron / noticias-pr-cli / lib / exit.js View on Github external
module.exports = () => {
  process.stdout.write(ansiEscapes.clearScreen);
  process.exit(0);
};
github jest-community / jest-runner-eslint / src / watchPlugin / index.js View on Github external
async run() {
    try {
      this._println(ansiEscapes.clearScreen);
      const {
        rules: ruleOverrides = [],
        fix: fixOverride,
      } = getConfigOverrides();

      if (Object.keys(ruleOverrides).length) {
        this._println(chalk.bold('Current rule overrides'));
        Object.keys(ruleOverrides).forEach(name => {
          const value = ruleOverrides[name];
          this._println(
            `  ${name} ${chalk.dim.italic(`(${FROM_RULE_VALUES[value]})`)}`,
          );
        });
        this._println();
      }
github derhuerst / sms-cli / ui.js View on Github external
render: function (first) {
		if (first) this.out.write('\n'.repeat(height))
		if (this.querying) return

		let out = esc.clearScreen + esc.cursorTo(0, 0)
			+ this.renderStatus() + '\n'

		if (this.messages.length === 0) {
		} else if (this.message) {
			out += this.renderMessage()
		} else {
			out += this.renderMessages()
		}

		out += '\n' + this.renderBindings()
		this.out.write(out + esc.cursorHide)
	}
}
github voidcosmos / npkill / src / controller2.ts View on Github external
private clear() {
    this.print(ansiEscapes.clearScreen);
  }
github freewheel / dashflow / lib / interactive_shell.js View on Github external
});

  const dataListeners = process.stdin.listeners("data");

  dataListeners.forEach(listener => {
    process.stdin.removeListener("data", listener);
  });

  process.stdout.write(ansiEscapes.clearScreen);

  process.stdin.resume();

  try {
    await callback();

    process.stdout.write(ansiEscapes.clearScreen);
  } catch (err) {
    process.stderr.write(err.message + "\n");
    process.stderr.write(err.stack + "\n");
  }

  sigIntListeners.forEach(listener => {
    process.on("SIGINT", listener);
  });

  dataListeners.forEach(listener => {
    process.stdin.on("data", listener);
  });
}
github Akryum / monorepo-run / src / util / ansi.js View on Github external
const ansiEscapes = require('ansi-escapes')

const ESC = '\u001B['

const escapeSeqReg = /[-/\\^$*+?.()|[\]{}]/g

exports.escapeAnsiEscapeSeq = (s) => {
  return s.replace(escapeSeqReg, '\\$&')
}

const ansiEscapeSeqsReg = new RegExp([
  ansiEscapes.clearScreen,
  ansiEscapes.eraseLine,
  ansiEscapes.eraseStartLine,
  ansiEscapes.eraseEndLine,
  `${ESC}0K`,
  `${ESC}0J`,
  ...(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, '')