# term-list

> interactive terminal lists

Latest version **0.2.1** (published 2013-11-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install term-list
pnpm add term-list
yarn add term-list
bun add term-list
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2013-11-21 |
| First published | 2013-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 125 |
| Maintainers | tjholowaychuk |
| Keywords | ansi, term, terminal, list, ui, interactive |

## Links

- npm: https://www.npmjs.com/package/term-list
- Repository: https://github.com/visionmedia/node-term-list
- Issues: https://github.com/visionmedia/node-term-list/issues
- npm.io page: https://npm.io/package/term-list

## Dependencies (2)

- [keypress](https://npm.io/package/keypress.md) ~0.2.1
- [term-canvas](https://npm.io/package/term-canvas.md) 0.0.5

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2013-11-21
- 0.2.0 — 2013-07-19
- 0.1.0 — 2013-07-18
- 0.0.1 — 2013-07-18

## README

# term-list

  Renders an interactive list to the terminal that users
  can navigate using the arrow keys. Developers can bind
  to "keypress" events to support removal or opening of items etc.

  ![interactive terminal list](https://dsz91cxz97a03.cloudfront.net/YNqOchbrMD-150x150.png)

## Installation

```
$ npm install term-list
```

## Example

  A fully interactive list demonstrating removal via backspace,
  and opening of the websites via the return key.

```js
var List = require('term-list');
var exec = require('child_process').exec;

var list = new List({ marker: '\033[36m› \033[0m', markerLength: 2 });
list.add('http://google.com', 'Google');
list.add('http://yahoo.com', 'Yahoo');
list.add('http://cloudup.com', 'Cloudup');
list.add('http://github.com', 'Github');
list.start();

list.on('keypress', function(key, item){
  switch (key.name) {
    case 'return':
      exec('open ' + item);
      list.stop();
      console.log('opening %s', item);
      break;
    case 'backspace':
      list.remove(list.selected);
      break;
  }
});

list.on('empty', function(){
  list.stop();
});
```

### API

  - [List()](#list)
  - [List.add()](#listaddidstringlabelstring)
  - [List.remove()](#listremoveidstring)
  - [List.at()](#listatinumber)
  - [List.select()](#listselectidstring)
  - [List.draw()](#listdraw)
  - [List.up()](#listup)
  - [List.down()](#listdown)
  - [List.stop()](#liststop)
  - [List.start()](#liststart)

### List()

  Initialize a new `List` with `opts`:
  
  - `marker` optional marker string defaulting to '› '
  - `markerLength` optional marker length, otherwise marker.length is used

### List.add(id:String, label:String)

  Add item `id` with `label`.

### List.remove(id:String)

  Remove item `id`.

### List.at(i:Number)

  Return item at `i`.

### List.select(id:String)

  Select item `id`.

### List.draw()

  Re-draw the list.

### List.up()

  Select the previous item if any.

### List.down()

  Select the next item if any.

### List.stop()

  Reset state and stop the list.

### List.start()

  Start the list.

## License

  MIT

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