# tty-window

> This package allows you to create a fixed 'render window' in a TTY, to show status and progress info alongside spooling logs.

Latest version **0.2.0** (published 2022-05-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install tty-window
pnpm add tty-window
yarn add tty-window
bun add tty-window
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-05-21 |
| First published | 2021-12-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 79.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gordon Leigh |
| Maintainers | gordonmleigh |

## Links

- npm: https://www.npmjs.com/package/tty-window
- Repository: https://github.com/gordonmleigh/tty-window
- Homepage: https://github.com/gordonmleigh/tty-window#readme
- Issues: https://github.com/gordonmleigh/tty-window/issues
- npm.io page: https://npm.io/package/tty-window

## Dependencies (1)

- [lodash.throttle](https://npm.io/package/lodash.throttle.md) ^4.1.1

## Recent versions

- 0.2.0 (latest) — 2022-05-21
- 0.1.1 — 2021-12-12
- 0.1.0 — 2021-12-12

## README

# tty-window

This package allows you to create a fixed "render window" in a TTY, to show status and progress info alongside spooling logs.

The contents of the render window will only be visible if the output is a TTY.

![demo](demo.gif)

## Example

```ts
const window = new TtyRenderWindow({
  // defaults:
  disableWordWrap = true, // emits VT-100 codes to prevent long lines wrapping
  fps = 15, // frames per second throttling for the render function
  stream = process.stdout,
});

const row1 = new TextRow("row 1");
const row2 = new TextRow("row 2");

// add the rows to the window – this will schedule a render
window.add(row1);
window.add(row2);

// log a message to the console as normal. This will be logged even if the
// output is not a TTY. A render will be scheduled to output the render window
// at the end of the new output
window.interrupt("log message");

// change the text of row1. A render will be scheduled automatically.
row1.text = "hello world";

// output a log and remove the row (the log will be output even in non-TTY)
row1.ended = "Done!";

// just remove the row without outputting anything. This will result in an empty
// line at the end of the output until something else is written
row2.ended = true;

// ALTERNATIVELY:
window.remove(row1, "Done!");
window.remove(row2);
```

---
_Source: https://npm.io/package/tty-window · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
