How to use the ansi-escapes.cursorRestorePosition 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 derhuerst / cli-autocomplete / index.js View on Github external
let prompt = [
			ui.symbol(this.done, this.aborted),
			this.msg,
			ui.delimiter(this.completing),
			this.done && this.suggestions[this.cursor]
				? this.suggestions[this.cursor].title
				: this.transform(this.input)
		].join(' ')

		if (!this.done) {
			prompt += esc.cursorSavePosition
			for (let i = 0; i < this.suggestions.length; i++) {
				const s = this.suggestions[i]
				prompt += '\n' + (i === this.cursor ? chalk.cyan(s.title) : s.title)
			}
			prompt += esc.cursorRestorePosition
		}

		this.out.write(ui.clear(this.lastRendered) + prompt)
		this.lastRendered = prompt
	}
}
github alexkuz / nyan-progress-webpack-plugin / index.js View on Github external
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  ',
    'ggMMMMMMgwwwwwwg',
    ' gggggggggggg   '