How to use the ansi-escapes.cursorMove 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 ismaelgt / metaweather-cli / lib / report.js View on Github external
getFormattedDate(weather.applicable_date) +
    ansiEscapes.cursorNextLine +
    // Weather symbol
    ansiEscapes.cursorMove(xOffset + 2, 1) +
    ansiSymbols.getWeatherIcon(weather.weather_state_abbr) +
    ansiEscapes.cursorNextLine +
    // State name
    ansiEscapes.cursorMove(xOffset + 16, -5) +
    chalk.yellow(weather.weather_state_name) +
    ansiEscapes.cursorNextLine +
    // Max temp
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    'Max: ' + getFormattedTemp(weather.max_temp) +
    ansiEscapes.cursorNextLine +
    // Min temp
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    'Min: ' + getFormattedTemp(weather.min_temp) +
    ansiEscapes.cursorNextLine +
    // Wind
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    getFormattedWind(weather.wind_direction_compass, weather.wind_speed) +
    ansiEscapes.cursorNextLine +
    // Humidity
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    'Humidity: ' + weather.humidity + '%' +
    ansiEscapes.cursorNextLine +
    (column !== 2 ? ansiEscapes.cursorUp(7) : ansiEscapes.cursorDown(1))
  )
}
github ismaelgt / metaweather-cli / lib / report.js View on Github external
const getDayWeatherReport = (weather, column) => {
  const xOffset = (32 * column) - column

  return (
    // Date
    ansiEscapes.cursorMove(xOffset + 11, 0) +
    getFormattedDate(weather.applicable_date) +
    ansiEscapes.cursorNextLine +
    // Weather symbol
    ansiEscapes.cursorMove(xOffset + 2, 1) +
    ansiSymbols.getWeatherIcon(weather.weather_state_abbr) +
    ansiEscapes.cursorNextLine +
    // State name
    ansiEscapes.cursorMove(xOffset + 16, -5) +
    chalk.yellow(weather.weather_state_name) +
    ansiEscapes.cursorNextLine +
    // Max temp
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    'Max: ' + getFormattedTemp(weather.max_temp) +
    ansiEscapes.cursorNextLine +
    // Min temp
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    'Min: ' + getFormattedTemp(weather.min_temp) +
    ansiEscapes.cursorNextLine +
    // Wind
    ansiEscapes.cursorMove(xOffset + 16, 0) +
github ismaelgt / metaweather-cli / lib / report.js View on Github external
const getDayWeatherReport = (weather, column) => {
  const xOffset = (32 * column) - column

  return (
    // Date
    ansiEscapes.cursorMove(xOffset + 11, 0) +
    getFormattedDate(weather.applicable_date) +
    ansiEscapes.cursorNextLine +
    // Weather symbol
    ansiEscapes.cursorMove(xOffset + 2, 1) +
    ansiSymbols.getWeatherIcon(weather.weather_state_abbr) +
    ansiEscapes.cursorNextLine +
    // State name
    ansiEscapes.cursorMove(xOffset + 16, -5) +
    chalk.yellow(weather.weather_state_name) +
    ansiEscapes.cursorNextLine +
    // Max temp
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    'Max: ' + getFormattedTemp(weather.max_temp) +
    ansiEscapes.cursorNextLine +
    // Min temp
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    'Min: ' + getFormattedTemp(weather.min_temp) +
    ansiEscapes.cursorNextLine +
    // Wind
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    getFormattedWind(weather.wind_direction_compass, weather.wind_speed) +
    ansiEscapes.cursorNextLine +
    // Humidity
    ansiEscapes.cursorMove(xOffset + 16, 0) +
github nikersify / jay / source / prompt.ts View on Github external
afterCursor +
				' ' + (eager ? c.gray(`// ${eager}`) : '')

			debug('out')
			stdout.write(out)

			const offset = rl.cursor + stripAnsi(pre).length
			cursorPosition = [
				offset % cols,
				Math.floor(offset / cols)
			]

			const rowsToGoUp = Math.floor((stripAnsi(out).length - 1) / cols)

			debug(`cursorMove(0, ${-rowsToGoUp})`)
			stdout.write(ansiEscapes.cursorMove(0, -rowsToGoUp))

			rendered = out
		}
github nikersify / jay / source / prompt.ts View on Github external
const rerenderTime = time('rerender')

			clearPrompt()
			renderPrompt()

			if (scroller && menuItems.length > 1) {
				stdout.write('\n')
				renderMenu()
			}

			// Move cursor into proper position
			debug('cursorTo(0)')
			stdout.write(ansiEscapes.cursorTo(0))

			debug(`cursorMove(${cursorPosition})`)
			stdout.write(ansiEscapes.cursorMove(...cursorPosition))

			debug(rerenderTime())
		}
github ismaelgt / metaweather-cli / lib / report.js View on Github external
const getDayWeatherReport = (weather, column) => {
  const xOffset = (32 * column) - column

  return (
    // Date
    ansiEscapes.cursorMove(xOffset + 11, 0) +
    getFormattedDate(weather.applicable_date) +
    ansiEscapes.cursorNextLine +
    // Weather symbol
    ansiEscapes.cursorMove(xOffset + 2, 1) +
    ansiSymbols.getWeatherIcon(weather.weather_state_abbr) +
    ansiEscapes.cursorNextLine +
    // State name
    ansiEscapes.cursorMove(xOffset + 16, -5) +
    chalk.yellow(weather.weather_state_name) +
    ansiEscapes.cursorNextLine +
    // Max temp
    ansiEscapes.cursorMove(xOffset + 16, 0) +
    'Max: ' + getFormattedTemp(weather.max_temp) +
    ansiEscapes.cursorNextLine +
    // Min temp
    ansiEscapes.cursorMove(xOffset + 16, 0) +
github ismaelgt / metaweather-cli / lib / report.js View on Github external
const getSixDayWeatherReport = (weather) => {
  let report = ansiSymbols.reportFrame +
    ansiEscapes.cursorMove(0, -16)
  for (let i = 0; i < 6 && i < weather.length; ++i) {
    report += getDayWeatherReport(weather[i], i % 3)
  }
  return report
}
github nikersify / jay / source / prompt.ts View on Github external
const scrollCharFn = showScrollbarChar ?
					c.bgBlackBright :
					noop

				stdout.write(ansiEscapes.cursorMove(offset))
				stdout.write(
					c.bgWhite.black(
						lineStyleFn(
							line + scrollCharFn(' ')
						)
					) + '\n'
				)
			}

			stdout.write(ansiEscapes.cursorMove(0, -(scroller.end - scroller.start) - 2))
			stdout.write(ansiEscapes.cursorMove(0, -down))
			stdout.write(ansiEscapes.cursorTo(0))

			debug(menuTime())
		}
github nikersify / jay / source / prompt.ts View on Github external
function clearPrompt(): void {
			debug(`cursorMove(${-cursorPosition[0]}, ${-cursorPosition[1]})`)
			stdout.write(ansiEscapes.cursorMove(
				-cursorPosition[0],
				-cursorPosition[1]
			))

			debug('eraseDown')
			stdout.write(ansiEscapes.eraseDown)
		}
github nikersify / jay / source / prompt.ts View on Github external
selected ?
						c.bgBlackBright :
						noop

				const renderedRowNumber = i - scroller.start
				debug(`renderedRowNumber ${renderedRowNumber}`)
				const showScrollbarChar =
					scrollbar.offset <= renderedRowNumber &&
					renderedRowNumber < (scrollbar.offset + scrollbar.size) &&
					scrollbar.size !== menuItems.length

				const scrollCharFn = showScrollbarChar ?
					c.bgBlackBright :
					noop

				stdout.write(ansiEscapes.cursorMove(offset))
				stdout.write(
					c.bgWhite.black(
						lineStyleFn(
							line + scrollCharFn(' ')
						)
					) + '\n'
				)
			}

			stdout.write(ansiEscapes.cursorMove(0, -(scroller.end - scroller.start) - 2))
			stdout.write(ansiEscapes.cursorMove(0, -down))
			stdout.write(ansiEscapes.cursorTo(0))

			debug(menuTime())
		}