vt100.js 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# vt100.js
|
|
2
|
+
|
|
3
|
+
Pure TypeScript VT100 terminal emulator. Zero dependencies, headless, fast.
|
|
4
|
+
|
|
5
|
+
Part of the [vterm](https://github.com/beorn/vterm) monorepo.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Full VT100/ANSI escape sequence parsing
|
|
10
|
+
- SGR attributes (bold, italic, underline styles, colors, strikethrough, etc.)
|
|
11
|
+
- 16-color, 256-color, and 24-bit truecolor support
|
|
12
|
+
- Cursor movement, save/restore (DECSC/DECRC)
|
|
13
|
+
- Screen modes (alternate screen, auto-wrap, origin mode, etc.)
|
|
14
|
+
- Scroll regions (DECSTBM) with content preservation
|
|
15
|
+
- Scrollback buffer with configurable limit
|
|
16
|
+
- Insert/delete characters and lines
|
|
17
|
+
- Wide character support (CJK, emoji)
|
|
18
|
+
- Zero dependencies — works in Bun, Node.js, and browsers
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install vt100.js
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { createVt100Screen } from "vt100.js"
|
|
30
|
+
|
|
31
|
+
const screen = createVt100Screen({ cols: 80, rows: 24 })
|
|
32
|
+
screen.process(new TextEncoder().encode("Hello, \x1b[1mBold\x1b[0m World!"))
|
|
33
|
+
|
|
34
|
+
console.log(screen.getText()) // "Hello, Bold World!"
|
|
35
|
+
console.log(screen.getCell(0, 7).bold) // true
|
|
36
|
+
console.log(screen.getCursorPosition()) // { x: 18, y: 0 }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
### `createVt100Screen(options)`
|
|
42
|
+
|
|
43
|
+
| Option | Type | Default | Description |
|
|
44
|
+
| ----------------- | -------- | -------- | -------------------- |
|
|
45
|
+
| `cols` | `number` | required | Terminal width |
|
|
46
|
+
| `rows` | `number` | required | Terminal height |
|
|
47
|
+
| `scrollbackLimit` | `number` | `1000` | Max scrollback lines |
|
|
48
|
+
|
|
49
|
+
### Screen methods
|
|
50
|
+
|
|
51
|
+
| Method | Description |
|
|
52
|
+
| ------------------------------ | ---------------------------------- |
|
|
53
|
+
| `process(data: Uint8Array)` | Feed raw terminal data |
|
|
54
|
+
| `getText()` | Get all text (scrollback + screen) |
|
|
55
|
+
| `getTextRange(sr, sc, er, ec)` | Get text in a range |
|
|
56
|
+
| `getLine(row)` | Get cells for a row |
|
|
57
|
+
| `getCell(row, col)` | Get a single cell |
|
|
58
|
+
| `getCursorPosition()` | Get cursor `{ x, y }` |
|
|
59
|
+
| `getCursorVisible()` | Check cursor visibility |
|
|
60
|
+
| `getMode(mode)` | Check terminal mode |
|
|
61
|
+
| `getTitle()` | Get window title |
|
|
62
|
+
| `getScrollbackLength()` | Number of scrollback lines |
|
|
63
|
+
| `getViewportOffset()` | Current viewport scroll offset |
|
|
64
|
+
| `scrollViewport(delta)` | Scroll viewport |
|
|
65
|
+
| `resize(cols, rows)` | Resize terminal |
|
|
66
|
+
| `reset()` | Reset to initial state |
|
|
67
|
+
|
|
68
|
+
### Cell properties
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
interface ScreenCell {
|
|
72
|
+
char: string
|
|
73
|
+
fg: CellColor | null // { r, g, b }
|
|
74
|
+
bg: CellColor | null
|
|
75
|
+
bold: boolean
|
|
76
|
+
faint: boolean
|
|
77
|
+
italic: boolean
|
|
78
|
+
underline: "none" | "single" | "double" | "curly" | "dotted" | "dashed"
|
|
79
|
+
strikethrough: boolean
|
|
80
|
+
inverse: boolean
|
|
81
|
+
hidden: boolean
|
|
82
|
+
wide: boolean
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## See also
|
|
87
|
+
|
|
88
|
+
- [vterm.js](../vterm/) — full-featured modern emulator (100% terminfo.dev coverage)
|
|
89
|
+
- [Termless](https://termless.dev) — headless terminal testing
|
|
90
|
+
- [Terminfo.dev](https://terminfo.dev) — terminal feature support tables
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT
|