UNPKG

balena-cli

Version:

The official balena Command Line Interface

44 lines 1.44 kB
"use strict"; const windowSize = {}; const updateWindowSize = () => { var _a; const size = (_a = require('window-size')) === null || _a === void 0 ? void 0 : _a.get(); windowSize.width = size === null || size === void 0 ? void 0 : size.width; windowSize.height = size === null || size === void 0 ? void 0 : size.height; }; process.stdout.on('resize', updateWindowSize); module.exports = (stream = process.stdout) => { updateWindowSize(); const currentWindowSize = () => { return { width: windowSize.width, height: windowSize.height, }; }; const hideCursor = () => stream.write('\u001B[?25l'); const showCursor = () => stream.write('\u001B[?25h'); const cursorUp = (rows = 0) => stream.write(`\u001B[${rows}A`); const cursorDown = (rows = 0) => stream.write(`\u001B[${rows}B`); const write = (str) => stream.write(str); const writeLine = (str) => stream.write(`${str}\n`); const clearLine = () => stream.write('\u001B[2K\r'); const replaceLine = (str) => { clearLine(); return write(str); }; const deleteToEnd = () => stream.write('\u001b[0J'); return { stream, currentWindowSize, hideCursor, showCursor, cursorUp, cursorDown, write, writeLine, clearLine, replaceLine, deleteToEnd, }; }; //# sourceMappingURL=tty.js.map