@effect-tui/core 0.1.0-alpha.1
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/LICENSE +21 -0
- package/README.md +93 -0
- package/dist/anim.d.ts +4 -0
- package/dist/anim.d.ts.map +1 -0
- package/dist/anim.js +5 -0
- package/dist/anim.js.map +1 -0
- package/dist/ansi.d.ts +69 -0
- package/dist/ansi.d.ts.map +1 -0
- package/dist/ansi.js +72 -0
- package/dist/ansi.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +18 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +247 -0
- package/dist/keys.js.map +1 -0
- package/dist/layout/linearStack.d.ts +17 -0
- package/dist/layout/linearStack.d.ts.map +1 -0
- package/dist/layout/linearStack.js +86 -0
- package/dist/layout/linearStack.js.map +1 -0
- package/dist/motion-value.d.ts +58 -0
- package/dist/motion-value.d.ts.map +1 -0
- package/dist/motion-value.js +250 -0
- package/dist/motion-value.js.map +1 -0
- package/dist/present/display.d.ts +58 -0
- package/dist/present/display.d.ts.map +1 -0
- package/dist/present/display.js +168 -0
- package/dist/present/display.js.map +1 -0
- package/dist/present/writers/fullscreen.d.ts +19 -0
- package/dist/present/writers/fullscreen.d.ts.map +1 -0
- package/dist/present/writers/fullscreen.js +55 -0
- package/dist/present/writers/fullscreen.js.map +1 -0
- package/dist/present/writers/inline.d.ts +20 -0
- package/dist/present/writers/inline.d.ts.map +1 -0
- package/dist/present/writers/inline.js +92 -0
- package/dist/present/writers/inline.js.map +1 -0
- package/dist/render/buffer.d.ts +31 -0
- package/dist/render/buffer.d.ts.map +1 -0
- package/dist/render/buffer.js +183 -0
- package/dist/render/buffer.js.map +1 -0
- package/dist/render/color-utils.d.ts +18 -0
- package/dist/render/color-utils.d.ts.map +1 -0
- package/dist/render/color-utils.js +58 -0
- package/dist/render/color-utils.js.map +1 -0
- package/dist/render/diff.d.ts +30 -0
- package/dist/render/diff.d.ts.map +1 -0
- package/dist/render/diff.js +83 -0
- package/dist/render/diff.js.map +1 -0
- package/dist/render/measure.d.ts +15 -0
- package/dist/render/measure.d.ts.map +1 -0
- package/dist/render/measure.js +65 -0
- package/dist/render/measure.js.map +1 -0
- package/dist/render/palette.d.ts +46 -0
- package/dist/render/palette.d.ts.map +1 -0
- package/dist/render/palette.js +108 -0
- package/dist/render/palette.js.map +1 -0
- package/dist/render/surface.d.ts +77 -0
- package/dist/render/surface.d.ts.map +1 -0
- package/dist/render/surface.js +198 -0
- package/dist/render/surface.js.map +1 -0
- package/dist/runtime/backend_node.d.ts +36 -0
- package/dist/runtime/backend_node.d.ts.map +1 -0
- package/dist/runtime/backend_node.js +66 -0
- package/dist/runtime/backend_node.js.map +1 -0
- package/dist/spring-physics.d.ts +36 -0
- package/dist/spring-physics.d.ts.map +1 -0
- package/dist/spring-physics.js +113 -0
- package/dist/spring-physics.js.map +1 -0
- package/dist/spring.d.ts +73 -0
- package/dist/spring.d.ts.map +1 -0
- package/dist/spring.js +136 -0
- package/dist/spring.js.map +1 -0
- package/dist/ui/containers/canvas.d.ts +13 -0
- package/dist/ui/containers/canvas.d.ts.map +1 -0
- package/dist/ui/containers/canvas.js +16 -0
- package/dist/ui/containers/canvas.js.map +1 -0
- package/dist/ui/containers/geometry-reader.d.ts +17 -0
- package/dist/ui/containers/geometry-reader.d.ts.map +1 -0
- package/dist/ui/containers/geometry-reader.js +24 -0
- package/dist/ui/containers/geometry-reader.js.map +1 -0
- package/dist/ui/containers/hstack.d.ts +12 -0
- package/dist/ui/containers/hstack.d.ts.map +1 -0
- package/dist/ui/containers/hstack.js +28 -0
- package/dist/ui/containers/hstack.js.map +1 -0
- package/dist/ui/containers/scroll.d.ts +28 -0
- package/dist/ui/containers/scroll.d.ts.map +1 -0
- package/dist/ui/containers/scroll.js +97 -0
- package/dist/ui/containers/scroll.js.map +1 -0
- package/dist/ui/containers/shared.d.ts +12 -0
- package/dist/ui/containers/shared.d.ts.map +1 -0
- package/dist/ui/containers/shared.js +19 -0
- package/dist/ui/containers/shared.js.map +1 -0
- package/dist/ui/containers/vstack.d.ts +12 -0
- package/dist/ui/containers/vstack.d.ts.map +1 -0
- package/dist/ui/containers/vstack.js +28 -0
- package/dist/ui/containers/vstack.js.map +1 -0
- package/dist/ui/containers/zstack.d.ts +14 -0
- package/dist/ui/containers/zstack.d.ts.map +1 -0
- package/dist/ui/containers/zstack.js +36 -0
- package/dist/ui/containers/zstack.js.map +1 -0
- package/dist/ui/core/geometry-store.d.ts +22 -0
- package/dist/ui/core/geometry-store.d.ts.map +1 -0
- package/dist/ui/core/geometry-store.js +29 -0
- package/dist/ui/core/geometry-store.js.map +1 -0
- package/dist/ui/core/geometry.d.ts +34 -0
- package/dist/ui/core/geometry.d.ts.map +1 -0
- package/dist/ui/core/geometry.js +14 -0
- package/dist/ui/core/geometry.js.map +1 -0
- package/dist/ui/core/view.d.ts +25 -0
- package/dist/ui/core/view.d.ts.map +1 -0
- package/dist/ui/core/view.js +34 -0
- package/dist/ui/core/view.js.map +1 -0
- package/dist/ui/index.d.ts +44 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +39 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/inlinetext.d.ts +24 -0
- package/dist/ui/inlinetext.d.ts.map +1 -0
- package/dist/ui/inlinetext.js +131 -0
- package/dist/ui/inlinetext.js.map +1 -0
- package/dist/ui/install.d.ts +22 -0
- package/dist/ui/install.d.ts.map +1 -0
- package/dist/ui/install.js +66 -0
- package/dist/ui/install.js.map +1 -0
- package/dist/ui/markdown.d.ts +40 -0
- package/dist/ui/markdown.d.ts.map +1 -0
- package/dist/ui/markdown.js +351 -0
- package/dist/ui/markdown.js.map +1 -0
- package/dist/ui/modifiers/border.d.ts +33 -0
- package/dist/ui/modifiers/border.d.ts.map +1 -0
- package/dist/ui/modifiers/border.js +82 -0
- package/dist/ui/modifiers/border.js.map +1 -0
- package/dist/ui/modifiers/fill.d.ts +14 -0
- package/dist/ui/modifiers/fill.d.ts.map +1 -0
- package/dist/ui/modifiers/fill.js +25 -0
- package/dist/ui/modifiers/fill.js.map +1 -0
- package/dist/ui/modifiers/frame.d.ts +23 -0
- package/dist/ui/modifiers/frame.d.ts.map +1 -0
- package/dist/ui/modifiers/frame.js +54 -0
- package/dist/ui/modifiers/frame.js.map +1 -0
- package/dist/ui/modifiers/offset.d.ts +15 -0
- package/dist/ui/modifiers/offset.d.ts.map +1 -0
- package/dist/ui/modifiers/offset.js +21 -0
- package/dist/ui/modifiers/offset.js.map +1 -0
- package/dist/ui/modifiers/opacity.d.ts +15 -0
- package/dist/ui/modifiers/opacity.d.ts.map +1 -0
- package/dist/ui/modifiers/opacity.js +95 -0
- package/dist/ui/modifiers/opacity.js.map +1 -0
- package/dist/ui/modifiers/padding.d.ts +20 -0
- package/dist/ui/modifiers/padding.d.ts.map +1 -0
- package/dist/ui/modifiers/padding.js +36 -0
- package/dist/ui/modifiers/padding.js.map +1 -0
- package/dist/ui/modifiers/styled.d.ts +14 -0
- package/dist/ui/modifiers/styled.d.ts.map +1 -0
- package/dist/ui/modifiers/styled.js +26 -0
- package/dist/ui/modifiers/styled.js.map +1 -0
- package/dist/ui/primitives/rectangle.d.ts +15 -0
- package/dist/ui/primitives/rectangle.d.ts.map +1 -0
- package/dist/ui/primitives/rectangle.js +23 -0
- package/dist/ui/primitives/rectangle.js.map +1 -0
- package/dist/ui/primitives/spacer.d.ts +13 -0
- package/dist/ui/primitives/spacer.d.ts.map +1 -0
- package/dist/ui/primitives/spacer.js +16 -0
- package/dist/ui/primitives/spacer.js.map +1 -0
- package/dist/ui/primitives/text.d.ts +15 -0
- package/dist/ui/primitives/text.d.ts.map +1 -0
- package/dist/ui/primitives/text.js +79 -0
- package/dist/ui/primitives/text.js.map +1 -0
- package/dist/ui/primitives/wrapped-text.d.ts +30 -0
- package/dist/ui/primitives/wrapped-text.d.ts.map +1 -0
- package/dist/ui/primitives/wrapped-text.js +117 -0
- package/dist/ui/primitives/wrapped-text.js.map +1 -0
- package/dist/ui/shinytext.d.ts +66 -0
- package/dist/ui/shinytext.d.ts.map +1 -0
- package/dist/ui/shinytext.js +99 -0
- package/dist/ui/shinytext.js.map +1 -0
- package/dist/ui/text/layout.d.ts +35 -0
- package/dist/ui/text/layout.d.ts.map +1 -0
- package/dist/ui/text/layout.js +102 -0
- package/dist/ui/text/layout.js.map +1 -0
- package/dist/ui/textinput.d.ts +140 -0
- package/dist/ui/textinput.d.ts.map +1 -0
- package/dist/ui/textinput.js +402 -0
- package/dist/ui/textinput.js.map +1 -0
- package/dist/ui/view-constructors.d.ts +72 -0
- package/dist/ui/view-constructors.d.ts.map +1 -0
- package/dist/ui/view-constructors.js +74 -0
- package/dist/ui/view-constructors.js.map +1 -0
- package/package.json +57 -0
- package/src/anim.ts +5 -0
- package/src/ansi.ts +83 -0
- package/src/index.ts +21 -0
- package/src/keys.ts +302 -0
- package/src/layout/linearStack.ts +115 -0
- package/src/motion-value.ts +335 -0
- package/src/present/display.ts +206 -0
- package/src/present/writers/fullscreen.ts +58 -0
- package/src/present/writers/inline.ts +101 -0
- package/src/render/buffer.ts +200 -0
- package/src/render/color-utils.ts +60 -0
- package/src/render/diff.ts +95 -0
- package/src/render/measure.ts +74 -0
- package/src/render/palette.ts +113 -0
- package/src/render/surface.ts +238 -0
- package/src/runtime/backend_node.ts +80 -0
- package/src/spring-physics.ts +151 -0
- package/src/spring.ts +234 -0
- package/src/ui/__snapshots__/wrappedtext.test.ts.snap +57 -0
- package/src/ui/containers/canvas.ts +18 -0
- package/src/ui/containers/geometry-reader.ts +32 -0
- package/src/ui/containers/hstack.ts +33 -0
- package/src/ui/containers/scroll.ts +106 -0
- package/src/ui/containers/shared.ts +27 -0
- package/src/ui/containers/vstack.ts +34 -0
- package/src/ui/containers/zstack.ts +37 -0
- package/src/ui/core/geometry-store.ts +42 -0
- package/src/ui/core/geometry.ts +30 -0
- package/src/ui/core/view.ts +49 -0
- package/src/ui/index.ts +84 -0
- package/src/ui/inlinetext.ts +135 -0
- package/src/ui/install.ts +110 -0
- package/src/ui/markdown.test.ts +74 -0
- package/src/ui/markdown.ts +388 -0
- package/src/ui/modifiers/border.ts +100 -0
- package/src/ui/modifiers/fill.ts +28 -0
- package/src/ui/modifiers/frame.ts +74 -0
- package/src/ui/modifiers/offset.ts +23 -0
- package/src/ui/modifiers/opacity.ts +93 -0
- package/src/ui/modifiers/padding.ts +53 -0
- package/src/ui/modifiers/styled.ts +31 -0
- package/src/ui/primitives/rectangle.ts +25 -0
- package/src/ui/primitives/spacer.ts +18 -0
- package/src/ui/primitives/text.ts +85 -0
- package/src/ui/primitives/wrapped-text.ts +131 -0
- package/src/ui/shinytext.ts +159 -0
- package/src/ui/text/layout.ts +119 -0
- package/src/ui/textinput.ts +496 -0
- package/src/ui/view-constructors.ts +96 -0
- package/src/ui/wrappedtext.test.ts +138 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Kit Langton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @effect-tui/core
|
|
2
|
+
|
|
3
|
+
Low-level terminal UI primitives built with [Effect](https://effect.website).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @effect-tui/core effect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **CellBuffer** - Frame storage with glyph, style, and width-aware cells
|
|
14
|
+
- **Palette** - Style deduplication for ANSI output
|
|
15
|
+
- **Colors** - Color helpers (indexed, RGB, hex, grayscale)
|
|
16
|
+
- **Keys** - Raw TTY key decoding
|
|
17
|
+
- **Spring animations** - Analytical spring physics
|
|
18
|
+
|
|
19
|
+
## Core Concepts
|
|
20
|
+
|
|
21
|
+
### CellBuffer
|
|
22
|
+
|
|
23
|
+
A 2D grid of cells, each storing a codepoint, style ID, and width. Handles wide characters (CJK, emoji) correctly.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
const buffer = new CellBuffer(80, 24)
|
|
27
|
+
buffer.put(0, 0, "Hello", styleId) // Put string
|
|
28
|
+
buffer.drawCP(5, 0, 0x1F600, styleId) // Draw codepoint (emoji)
|
|
29
|
+
buffer.fillRect(0, 1, 10, 3, 32, styleId) // Fill rectangle
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Palette
|
|
33
|
+
|
|
34
|
+
Maps style objects to numeric IDs and generates ANSI escape sequences:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
const palette = new Palette()
|
|
38
|
+
const style = palette.id({ fg: Colors.green, bg: Colors.black })
|
|
39
|
+
const ansi = palette.sgr(style) // "\x1b[32;40m"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Colors
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
Colors.red // Named color (indexed)
|
|
46
|
+
Colors.rgb(255,0,0) // RGB
|
|
47
|
+
Colors.hex("#ff0000") // Hex
|
|
48
|
+
Colors.gray(12) // Grayscale (0-23)
|
|
49
|
+
Colors.idx(196) // 256-color index
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Basic Usage
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { CellBuffer, Surface, Colors } from "@effect-tui/core"
|
|
56
|
+
|
|
57
|
+
// Create a buffer
|
|
58
|
+
const buffer = new CellBuffer(80, 24)
|
|
59
|
+
buffer.put(0, 0, "Hello", { fg: Colors.green })
|
|
60
|
+
|
|
61
|
+
// Render to terminal
|
|
62
|
+
const surface = new Surface(process.stdout)
|
|
63
|
+
surface.render(buffer)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Spring Physics
|
|
67
|
+
|
|
68
|
+
Analytical spring equations (matches framer-motion):
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { Spring } from "@effect-tui/core"
|
|
72
|
+
|
|
73
|
+
// Create spring with target
|
|
74
|
+
const spring = Spring.init(0)
|
|
75
|
+
const animated = Spring.to(spring, 100, { visualDuration: 0.35, bounce: 0.2 })
|
|
76
|
+
|
|
77
|
+
// Tick each frame
|
|
78
|
+
const next = Spring.tick(animated, 16) // 16ms delta
|
|
79
|
+
const value = Spring.value(next) // Current position
|
|
80
|
+
const done = Spring.settled(next) // Animation complete?
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Parameters:**
|
|
84
|
+
- `visualDuration` - Time to reach ~99% of target (seconds)
|
|
85
|
+
- `bounce` - Overshoot amount (0 = no bounce, 0.5 = bouncy)
|
|
86
|
+
|
|
87
|
+
## Related
|
|
88
|
+
|
|
89
|
+
- [@effect-tui/react](https://github.com/kitlangton/effect-tui/tree/main/packages/effect-tui-react) - React renderer for terminal UIs
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT
|
package/dist/anim.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anim.d.ts","sourceRoot":"","sources":["../src/anim.ts"],"names":[],"mappings":"AAEA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA"}
|
package/dist/anim.js
ADDED
package/dist/anim.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anim.js","sourceRoot":"","sources":["../src/anim.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA"}
|
package/dist/ansi.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Basic ANSI codes and helpers */
|
|
2
|
+
export declare const ANSI: {
|
|
3
|
+
/** Reset all attributes */
|
|
4
|
+
readonly reset: "\u001B[0m";
|
|
5
|
+
/** Cursor control */
|
|
6
|
+
readonly cursor: {
|
|
7
|
+
/** Hide cursor */
|
|
8
|
+
readonly hide: "\u001B[?25l";
|
|
9
|
+
/** Show cursor */
|
|
10
|
+
readonly show: "\u001B[?25h";
|
|
11
|
+
/** Move cursor to home position (1,1) */
|
|
12
|
+
readonly home: "\u001B[H";
|
|
13
|
+
/** Move cursor to 1-based row/column */
|
|
14
|
+
readonly to: (row1: number, col1: number) => string;
|
|
15
|
+
/** Move cursor to 1-based column on current row */
|
|
16
|
+
readonly toCol: (col1: number) => string;
|
|
17
|
+
};
|
|
18
|
+
/** Screen control */
|
|
19
|
+
readonly screen: {
|
|
20
|
+
/** Enter alternate screen buffer */
|
|
21
|
+
readonly altEnter: "\u001B[?1049h";
|
|
22
|
+
/** Exit alternate screen buffer */
|
|
23
|
+
readonly altExit: "\u001B[?1049l";
|
|
24
|
+
/** Clear entire display */
|
|
25
|
+
readonly clear: "\u001B[2J";
|
|
26
|
+
/** Clear scrollback buffer */
|
|
27
|
+
readonly clearScrollback: "\u001B[3J";
|
|
28
|
+
};
|
|
29
|
+
/** Scrolling */
|
|
30
|
+
readonly scroll: {
|
|
31
|
+
/** Scroll up by n lines */
|
|
32
|
+
readonly up: (n: number) => string;
|
|
33
|
+
};
|
|
34
|
+
/** Device Status Reports / queries */
|
|
35
|
+
readonly report: {
|
|
36
|
+
/** Report Cursor Position (response: ESC [ row ; col R) */
|
|
37
|
+
readonly cursorPosition: "\u001B[6n";
|
|
38
|
+
};
|
|
39
|
+
/** Bracketed paste mode */
|
|
40
|
+
readonly paste: {
|
|
41
|
+
readonly bracketed: {
|
|
42
|
+
readonly on: "\u001B[?2004h";
|
|
43
|
+
readonly off: "\u001B[?2004l";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** Mouse reporting toggles */
|
|
47
|
+
readonly mouse: {
|
|
48
|
+
/** Enable button tracking and SGR coordinates */
|
|
49
|
+
readonly on: "\u001B[?1002h\u001B[?1006h";
|
|
50
|
+
/** Disable SGR coords and button tracking */
|
|
51
|
+
readonly off: "\u001B[?1006l\u001B[?1002l";
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/** Terminal session control utilities (compositions of ANSI primitives) */
|
|
55
|
+
export declare const Terminal: {
|
|
56
|
+
/** Enter full-screen mode: alternate screen + hide cursor */
|
|
57
|
+
readonly enterFullscreen: string;
|
|
58
|
+
/** Exit full-screen mode: reset + show cursor + exit alternate screen */
|
|
59
|
+
readonly exitFullscreen: string;
|
|
60
|
+
/** Clear screen and move cursor to home */
|
|
61
|
+
readonly clearAndHome: string;
|
|
62
|
+
/** Convenience shorthands for common toggles */
|
|
63
|
+
readonly bracketedPasteOn: "\u001B[?2004h";
|
|
64
|
+
readonly bracketedPasteOff: "\u001B[?2004l";
|
|
65
|
+
readonly mouseOn: "\u001B[?1002h\u001B[?1006h";
|
|
66
|
+
readonly mouseOff: "\u001B[?1006l\u001B[?1002l";
|
|
67
|
+
readonly reportCursorPosition: "\u001B[6n";
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=ansi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AAKA,mCAAmC;AACnC,eAAO,MAAM,IAAI;IACf,2BAA2B;;IAG3B,qBAAqB;;QAEnB,kBAAkB;;QAElB,kBAAkB;;QAElB,yCAAyC;;QAEzC,wCAAwC;4BAC7B,MAAM,QAAQ,MAAM;QAC/B,mDAAmD;+BACrC,MAAM;;IAGtB,qBAAqB;;QAEnB,oCAAoC;;QAEpC,mCAAmC;;QAEnC,2BAA2B;;QAE3B,8BAA8B;;;IAIhC,gBAAgB;;QAEd,2BAA2B;yBACnB,MAAM;;IAGhB,sCAAsC;;QAEpC,2DAA2D;;;IAI7D,2BAA2B;;;;;;;IAQ3B,8BAA8B;;QAE5B,iDAAiD;;QAEjD,6CAA6C;;;CAGvC,CAAA;AAEV,2EAA2E;AAC3E,eAAO,MAAM,QAAQ;IACnB,6DAA6D;;IAG7D,yEAAyE;;IAGzE,2CAA2C;;IAG3C,gDAAgD;;;;;;CAMxC,CAAA"}
|
package/dist/ansi.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// ANSI escape sequences and terminal control utilities
|
|
2
|
+
/** CSI prefix (ESC [) */
|
|
3
|
+
const CSI = "\x1b[";
|
|
4
|
+
/** Basic ANSI codes and helpers */
|
|
5
|
+
export const ANSI = {
|
|
6
|
+
/** Reset all attributes */
|
|
7
|
+
reset: `${CSI}0m`,
|
|
8
|
+
/** Cursor control */
|
|
9
|
+
cursor: {
|
|
10
|
+
/** Hide cursor */
|
|
11
|
+
hide: `${CSI}?25l`,
|
|
12
|
+
/** Show cursor */
|
|
13
|
+
show: `${CSI}?25h`,
|
|
14
|
+
/** Move cursor to home position (1,1) */
|
|
15
|
+
home: `${CSI}H`,
|
|
16
|
+
/** Move cursor to 1-based row/column */
|
|
17
|
+
to: (row1, col1) => `${CSI}${row1};${col1}H`,
|
|
18
|
+
/** Move cursor to 1-based column on current row */
|
|
19
|
+
toCol: (col1) => `${CSI}${col1}G`,
|
|
20
|
+
},
|
|
21
|
+
/** Screen control */
|
|
22
|
+
screen: {
|
|
23
|
+
/** Enter alternate screen buffer */
|
|
24
|
+
altEnter: `${CSI}?1049h`,
|
|
25
|
+
/** Exit alternate screen buffer */
|
|
26
|
+
altExit: `${CSI}?1049l`,
|
|
27
|
+
/** Clear entire display */
|
|
28
|
+
clear: `${CSI}2J`,
|
|
29
|
+
/** Clear scrollback buffer */
|
|
30
|
+
clearScrollback: `${CSI}3J`,
|
|
31
|
+
},
|
|
32
|
+
/** Scrolling */
|
|
33
|
+
scroll: {
|
|
34
|
+
/** Scroll up by n lines */
|
|
35
|
+
up: (n) => `${CSI}${n}S`,
|
|
36
|
+
},
|
|
37
|
+
/** Device Status Reports / queries */
|
|
38
|
+
report: {
|
|
39
|
+
/** Report Cursor Position (response: ESC [ row ; col R) */
|
|
40
|
+
cursorPosition: `${CSI}6n`,
|
|
41
|
+
},
|
|
42
|
+
/** Bracketed paste mode */
|
|
43
|
+
paste: {
|
|
44
|
+
bracketed: {
|
|
45
|
+
on: `${CSI}?2004h`,
|
|
46
|
+
off: `${CSI}?2004l`,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
/** Mouse reporting toggles */
|
|
50
|
+
mouse: {
|
|
51
|
+
/** Enable button tracking and SGR coordinates */
|
|
52
|
+
on: `${CSI}?1002h${CSI}?1006h`,
|
|
53
|
+
/** Disable SGR coords and button tracking */
|
|
54
|
+
off: `${CSI}?1006l${CSI}?1002l`,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
/** Terminal session control utilities (compositions of ANSI primitives) */
|
|
58
|
+
export const Terminal = {
|
|
59
|
+
/** Enter full-screen mode: alternate screen + hide cursor */
|
|
60
|
+
enterFullscreen: ANSI.screen.altEnter + ANSI.cursor.hide,
|
|
61
|
+
/** Exit full-screen mode: reset + show cursor + exit alternate screen */
|
|
62
|
+
exitFullscreen: ANSI.reset + ANSI.cursor.show + ANSI.screen.altExit,
|
|
63
|
+
/** Clear screen and move cursor to home */
|
|
64
|
+
clearAndHome: ANSI.screen.clear + ANSI.cursor.home,
|
|
65
|
+
/** Convenience shorthands for common toggles */
|
|
66
|
+
bracketedPasteOn: ANSI.paste.bracketed.on,
|
|
67
|
+
bracketedPasteOff: ANSI.paste.bracketed.off,
|
|
68
|
+
mouseOn: ANSI.mouse.on,
|
|
69
|
+
mouseOff: ANSI.mouse.off,
|
|
70
|
+
reportCursorPosition: ANSI.report.cursorPosition,
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=ansi.js.map
|
package/dist/ansi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,yBAAyB;AACzB,MAAM,GAAG,GAAG,OAAO,CAAA;AAEnB,mCAAmC;AACnC,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,2BAA2B;IAC3B,KAAK,EAAE,GAAG,GAAG,IAAI;IAEjB,qBAAqB;IACrB,MAAM,EAAE;QACN,kBAAkB;QAClB,IAAI,EAAE,GAAG,GAAG,MAAM;QAClB,kBAAkB;QAClB,IAAI,EAAE,GAAG,GAAG,MAAM;QAClB,yCAAyC;QACzC,IAAI,EAAE,GAAG,GAAG,GAAG;QACf,wCAAwC;QACxC,EAAE,EAAE,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,IAAI,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AAI,CAAC,MAAM,CAAC,IAAI;IAElD,gDAAgD;IAChD,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;IACzC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG;IAC3C,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE;IACtB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG;IACxB,oBAAoB,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc;CACxC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./render/surface.js";
|
|
2
|
+
export * from "./render/buffer.js";
|
|
3
|
+
export * from "./render/measure.js";
|
|
4
|
+
export * from "./anim.js";
|
|
5
|
+
export * from "./keys.js";
|
|
6
|
+
export { View } from "./ui/index.js";
|
|
7
|
+
export { ShinyText } from "./ui/index.js";
|
|
8
|
+
export { TextInput, TextInputState, editTextInput } from "./ui/index.js";
|
|
9
|
+
export { Markdown } from "./ui/index.js";
|
|
10
|
+
export type { TextInputStateLike, TextInputStatePlain, TextInputGeom, TextInputOptions } from "./ui/index.js";
|
|
11
|
+
export type { MarkdownOptions } from "./ui/index.js";
|
|
12
|
+
export { geometryStore } from "./ui/core/geometry-store.js";
|
|
13
|
+
export type { ViewId, Rect as GeometryRect, InputGeom } from "./ui/core/geometry-store.js";
|
|
14
|
+
export * from "./present/display.js";
|
|
15
|
+
export type { TerminalBackend } from "./runtime/backend_node.js";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AAGzB,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAC7G,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,YAAY,EAAE,MAAM,EAAE,IAAI,IAAI,YAAY,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAG1F,cAAc,sBAAsB,CAAA;AACpC,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Re-export core modules
|
|
2
|
+
export * from "./render/surface.js";
|
|
3
|
+
export * from "./render/buffer.js";
|
|
4
|
+
export * from "./render/measure.js";
|
|
5
|
+
export * from "./anim.js";
|
|
6
|
+
export * from "./keys.js";
|
|
7
|
+
// UI (canonical View and curated exports)
|
|
8
|
+
export { View } from "./ui/index.js";
|
|
9
|
+
export { ShinyText } from "./ui/index.js";
|
|
10
|
+
export { TextInput, TextInputState, editTextInput } from "./ui/index.js";
|
|
11
|
+
export { Markdown } from "./ui/index.js";
|
|
12
|
+
// Geometry store (last-known layout)
|
|
13
|
+
export { geometryStore } from "./ui/core/geometry-store.js";
|
|
14
|
+
// Renderers (optional public API)
|
|
15
|
+
export * from "./present/display.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AAEzB,0CAA0C;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,qCAAqC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAG3D,kCAAkC;AAClC,cAAc,sBAAsB,CAAA"}
|
package/dist/keys.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type KeyName = "up" | "down" | "left" | "right" | "enter" | "escape" | "tab" | "shift-tab" | "backspace" | "delete" | "home" | "end" | "pageup" | "pagedown" | "insert" | "return" | "space" | "char";
|
|
2
|
+
export type KeyMsg = {
|
|
3
|
+
type: "key";
|
|
4
|
+
name: KeyName;
|
|
5
|
+
text?: string;
|
|
6
|
+
ctrl?: boolean;
|
|
7
|
+
meta?: boolean;
|
|
8
|
+
shift?: boolean;
|
|
9
|
+
/** Optional phase; currently always "press" but left extensible. */
|
|
10
|
+
phase?: "press" | "repeat" | "release";
|
|
11
|
+
/** Set by renderer to allow handlers to stop further propagation. */
|
|
12
|
+
defaultPrevented?: boolean;
|
|
13
|
+
preventDefault?: () => void;
|
|
14
|
+
/** Source protocol (raw|csiu|modifyOther|kitty). */
|
|
15
|
+
source?: "raw" | "csiu" | "modify-other" | "kitty";
|
|
16
|
+
};
|
|
17
|
+
export declare function decodeKeys(buf: Buffer): Iterable<KeyMsg>;
|
|
18
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,GACf,IAAI,GACJ,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,GACR,KAAK,GACL,WAAW,GACX,WAAW,GACX,QAAQ,GACR,MAAM,GACN,KAAK,GACL,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,CAAA;AAEV,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,oEAAoE;IACpE,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;IACtC,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAC3B,oDAAoD;IACpD,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,CAAA;CACnD,CAAA;AAID,wBAAiB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CA+NzD"}
|
package/dist/keys.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// Minimal key decoder for Node raw input → semantic key messages.
|
|
2
|
+
const ESC = "\x1b";
|
|
3
|
+
export function* decodeKeys(buf) {
|
|
4
|
+
// Handle control characters (0x00-0x1F)
|
|
5
|
+
// These are generated by Ctrl+letter combinations
|
|
6
|
+
if (buf.length === 1 && buf[0] !== undefined && buf[0] < 0x20) {
|
|
7
|
+
const byte = buf[0];
|
|
8
|
+
// Special control characters with specific meanings
|
|
9
|
+
switch (byte) {
|
|
10
|
+
case 0x03: // Ctrl-C (ETX - End of Text)
|
|
11
|
+
yield { type: "key", name: "char", text: "c", ctrl: true };
|
|
12
|
+
return;
|
|
13
|
+
case 0x04: // Ctrl-D (EOT - End of Transmission)
|
|
14
|
+
yield { type: "key", name: "char", text: "d", ctrl: true };
|
|
15
|
+
return;
|
|
16
|
+
case 0x17: // Ctrl-W (ETB - End of Transmission Block)
|
|
17
|
+
yield { type: "key", name: "char", text: "w", ctrl: true };
|
|
18
|
+
return;
|
|
19
|
+
case 0x1a: // Ctrl-Z (SUB - Substitute)
|
|
20
|
+
yield { type: "key", name: "char", text: "z", ctrl: true };
|
|
21
|
+
return;
|
|
22
|
+
case 0x0c: // Ctrl-L (FF - Form Feed)
|
|
23
|
+
yield { type: "key", name: "char", text: "l", ctrl: true };
|
|
24
|
+
return;
|
|
25
|
+
case 0x09: // Tab (HT - Horizontal Tab)
|
|
26
|
+
yield { type: "key", name: "tab" };
|
|
27
|
+
return;
|
|
28
|
+
case 0x0d: // Enter (CR - Carriage Return)
|
|
29
|
+
yield { type: "key", name: "enter" };
|
|
30
|
+
return;
|
|
31
|
+
case 0x0a: // Line Feed (LF)
|
|
32
|
+
yield { type: "key", name: "enter" };
|
|
33
|
+
return;
|
|
34
|
+
case 0x08: // Backspace (BS)
|
|
35
|
+
yield { type: "key", name: "backspace" };
|
|
36
|
+
return;
|
|
37
|
+
case 0x1b: // Escape (ESC)
|
|
38
|
+
yield { type: "key", name: "escape" };
|
|
39
|
+
return;
|
|
40
|
+
default:
|
|
41
|
+
// Other control characters: convert back to letter
|
|
42
|
+
// Ctrl-A = 0x01, Ctrl-B = 0x02, etc.
|
|
43
|
+
if (byte >= 0x01 && byte <= 0x1a) {
|
|
44
|
+
const letter = String.fromCharCode(byte + 96); // 0x01 + 96 = 'a'
|
|
45
|
+
yield { type: "key", name: "char", text: letter, ctrl: true };
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// Unknown control character, emit raw
|
|
49
|
+
yield { type: "key", name: "char", text: String.fromCharCode(byte), ctrl: true };
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Handle 0x7F (DEL) separately as it's outside the control character range
|
|
55
|
+
if (buf.length === 1 && buf[0] === 0x7f) {
|
|
56
|
+
yield { type: "key", name: "backspace" };
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
let s = buf.toString("utf8");
|
|
60
|
+
// Handle one or more SGR mouse reports possibly coalesced in a single chunk.
|
|
61
|
+
// Format: ESC [ < Cb ; Cx ; Cy (M|m) — terminals vary on the trailing letter; accept any A-Z.
|
|
62
|
+
const sgrRe = /\x1b\x5b<(?<cb>\d+);(?<cx>\d+);(?<cy>\d+)(?<updown>[A-Za-z])/g;
|
|
63
|
+
let matchedAny = false;
|
|
64
|
+
for (const m of s.matchAll(sgrRe)) {
|
|
65
|
+
matchedAny = true;
|
|
66
|
+
const code = parseInt(m.groups?.cb ?? "0", 10);
|
|
67
|
+
if (code === 64) {
|
|
68
|
+
yield { type: "key", name: "pageup", meta: true };
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (code === 65) {
|
|
72
|
+
yield { type: "key", name: "pagedown", meta: true };
|
|
73
|
+
}
|
|
74
|
+
// ignore other mouse events
|
|
75
|
+
}
|
|
76
|
+
if (matchedAny) {
|
|
77
|
+
// Strip SGR mouse sequences so they never leak into the input as text
|
|
78
|
+
// Create a fresh regex since the global one was consumed by matchAll()
|
|
79
|
+
s = s.replace(/\x1b\x5b<(?<cb>\d+);(?<cx>\d+);(?<cy>\d+)(?<updown>[A-Za-z])/g, "");
|
|
80
|
+
if (s.length === 0)
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Legacy single SGR report path (when only one arrives)
|
|
84
|
+
const sgr = /^\x1b\[<(?<cb>\d+);(?<cx>\d+);(?<cy>\d+)(?<updown>[A-Za-z])$/.exec(s);
|
|
85
|
+
if (sgr?.groups) {
|
|
86
|
+
const code = parseInt(sgr.groups.cb ?? "0", 10);
|
|
87
|
+
if (code === 64) {
|
|
88
|
+
yield { type: "key", name: "pageup", meta: true };
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (code === 65) {
|
|
92
|
+
yield { type: "key", name: "pagedown", meta: true };
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Meta+Backspace (Option+Backspace on macOS terminals) — often ESC + DEL / BS
|
|
98
|
+
if (s === `${ESC}\x7f` || s === `${ESC}\b` || s === `${ESC}\x08`) {
|
|
99
|
+
yield { type: "key", name: "backspace", meta: true };
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// Alt/Meta + Enter (many terminals send ESC + CR/LF)
|
|
103
|
+
if (s === `${ESC}\r` || s === `${ESC}\n`) {
|
|
104
|
+
yield { type: "key", name: "enter", meta: true };
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// modifyOtherKeys (xterm / some terminals): CSI 27;modifier;code~
|
|
108
|
+
const moo = /^\x1b\[27;(?<mod>\d+);(?<code>\d+)~$/.exec(s);
|
|
109
|
+
if (moo?.groups) {
|
|
110
|
+
const mod = parseInt(moo.groups.mod ?? "1", 10) - 1;
|
|
111
|
+
const code = parseInt(moo.groups.code ?? "0", 10);
|
|
112
|
+
const shift = !!(mod & 1);
|
|
113
|
+
const alt = !!(mod & 2);
|
|
114
|
+
const ctrl = !!(mod & 4);
|
|
115
|
+
const meta = !!(mod & 8) || alt;
|
|
116
|
+
const key = fromCharCode(code, { shift, ctrl, meta, source: "modify-other" });
|
|
117
|
+
if (key) {
|
|
118
|
+
yield key;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// CSI-u (modern modifyOtherKeys): CSI <code> ; <modifier> u
|
|
123
|
+
const csiu = /^\x1b\[(?<code>\d+);(?<mod>\d+)u$/.exec(s);
|
|
124
|
+
if (csiu?.groups) {
|
|
125
|
+
const mod = parseInt(csiu.groups.mod ?? "1", 10) - 1;
|
|
126
|
+
const code = parseInt(csiu.groups.code ?? "0", 10);
|
|
127
|
+
const shift = !!(mod & 1);
|
|
128
|
+
const alt = !!(mod & 2);
|
|
129
|
+
const ctrl = !!(mod & 4);
|
|
130
|
+
const meta = !!(mod & 8) || alt;
|
|
131
|
+
const key = fromCharCode(code, { shift, ctrl, meta, source: "csiu" });
|
|
132
|
+
if (key) {
|
|
133
|
+
yield key;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Escape (lone ESC) - handle after meta combinations
|
|
138
|
+
if (s === ESC) {
|
|
139
|
+
yield { type: "key", name: "escape" };
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// Single printable
|
|
143
|
+
if (s.length === 1 && s !== ESC && s !== "\x7f") {
|
|
144
|
+
if (s === " ") {
|
|
145
|
+
yield { type: "key", name: "space", text: " " };
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (s >= " ") {
|
|
149
|
+
yield { type: "key", name: "char", text: s };
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Common escapes
|
|
154
|
+
switch (s) {
|
|
155
|
+
case `${ESC}[A`:
|
|
156
|
+
yield { type: "key", name: "up" };
|
|
157
|
+
return;
|
|
158
|
+
case `${ESC}[B`:
|
|
159
|
+
yield { type: "key", name: "down" };
|
|
160
|
+
return;
|
|
161
|
+
case `${ESC}[C`:
|
|
162
|
+
yield { type: "key", name: "right" };
|
|
163
|
+
return;
|
|
164
|
+
case `${ESC}[D`:
|
|
165
|
+
yield { type: "key", name: "left" };
|
|
166
|
+
return;
|
|
167
|
+
case `${ESC}[1;3C`:
|
|
168
|
+
yield { type: "key", name: "right", meta: true };
|
|
169
|
+
return;
|
|
170
|
+
case `${ESC}[1;3D`:
|
|
171
|
+
yield { type: "key", name: "left", meta: true };
|
|
172
|
+
return;
|
|
173
|
+
case `${ESC}OP`: // F1 (ignored)
|
|
174
|
+
return;
|
|
175
|
+
case `${ESC}[H`:
|
|
176
|
+
yield { type: "key", name: "home" };
|
|
177
|
+
return;
|
|
178
|
+
case `${ESC}[F`:
|
|
179
|
+
yield { type: "key", name: "end" };
|
|
180
|
+
return;
|
|
181
|
+
case `${ESC}[5~`:
|
|
182
|
+
yield { type: "key", name: "pageup" };
|
|
183
|
+
return;
|
|
184
|
+
case `${ESC}[6~`:
|
|
185
|
+
yield { type: "key", name: "pagedown" };
|
|
186
|
+
return;
|
|
187
|
+
case `${ESC}[2~`:
|
|
188
|
+
yield { type: "key", name: "insert" };
|
|
189
|
+
return;
|
|
190
|
+
case `${ESC}[3~`:
|
|
191
|
+
yield { type: "key", name: "delete" };
|
|
192
|
+
return;
|
|
193
|
+
case `${ESC}[3;3~`: // Meta+Delete (best-effort for some terminals)
|
|
194
|
+
yield { type: "key", name: "delete", meta: true };
|
|
195
|
+
return;
|
|
196
|
+
case `${ESC}[Z`:
|
|
197
|
+
yield { type: "key", name: "shift-tab", shift: true };
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// Alt/Meta + char (ESC <char>)
|
|
201
|
+
if (s.length === 2 && s[0] === ESC && s[1] && s[1] >= " ") {
|
|
202
|
+
const ch = s[1];
|
|
203
|
+
if (ch === " ") {
|
|
204
|
+
yield { type: "key", name: "space", text: " ", meta: true };
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
yield { type: "key", name: "char", text: ch, meta: true };
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
// Fallback: emit printable chars individually
|
|
211
|
+
for (const ch of s) {
|
|
212
|
+
if (ch >= " ")
|
|
213
|
+
yield { type: "key", name: "char", text: ch };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function fromCharCode(code, mods) {
|
|
217
|
+
const { shift, ctrl, meta, source } = mods;
|
|
218
|
+
const common = {
|
|
219
|
+
type: "key",
|
|
220
|
+
ctrl,
|
|
221
|
+
meta,
|
|
222
|
+
shift,
|
|
223
|
+
phase: "press",
|
|
224
|
+
source,
|
|
225
|
+
};
|
|
226
|
+
switch (code) {
|
|
227
|
+
case 13:
|
|
228
|
+
return { ...common, name: "enter" };
|
|
229
|
+
case 27:
|
|
230
|
+
return { ...common, name: "escape" };
|
|
231
|
+
case 9:
|
|
232
|
+
return { ...common, name: "tab" };
|
|
233
|
+
case 32:
|
|
234
|
+
return { ...common, name: "space", text: " " };
|
|
235
|
+
case 127:
|
|
236
|
+
case 8:
|
|
237
|
+
return { ...common, name: "backspace" };
|
|
238
|
+
}
|
|
239
|
+
if (code >= 0 && code < 32) {
|
|
240
|
+
// Control character -> map to letter when possible
|
|
241
|
+
const letter = String.fromCharCode(code + 96);
|
|
242
|
+
return { ...common, name: "char", text: letter, ctrl: true };
|
|
243
|
+
}
|
|
244
|
+
const ch = String.fromCharCode(code);
|
|
245
|
+
return { ...common, name: "char", text: ch };
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=keys.js.map
|
package/dist/keys.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAsClE,MAAM,GAAG,GAAG,MAAM,CAAA;AAElB,MAAM,SAAS,CAAC,CAAC,UAAU,CAAC,GAAW;IACrC,wCAAwC;IACxC,kDAAkD;IAClD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;QAC9D,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;QAEnB,oDAAoD;QACpD,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,IAAI,EAAE,6BAA6B;gBACtC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;gBAC1D,OAAM;YACR,KAAK,IAAI,EAAE,qC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AAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAC9D,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;AAC9C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Axis = "horizontal" | "vertical";
|
|
2
|
+
export type Size = {
|
|
3
|
+
w: number;
|
|
4
|
+
h: number;
|
|
5
|
+
};
|
|
6
|
+
export type Rect = {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
w: number;
|
|
10
|
+
h: number;
|
|
11
|
+
};
|
|
12
|
+
export type HAlign = "leading" | "center" | "trailing";
|
|
13
|
+
export type VAlign = "top" | "center" | "bottom";
|
|
14
|
+
/** flexBase[i] = null for fixed, or the child's base main-size for flexible. */
|
|
15
|
+
export declare function measureLinear(axis: Axis, maxW: number, maxH: number, spacing: number, sizes: Size[], flexBase: (number | null)[]): Size;
|
|
16
|
+
export declare function layoutLinear(axis: Axis, rect: Rect, spacing: number, crossAlign: HAlign | VAlign, sizes: Size[], flexBase: (number | null)[]): Rect[];
|
|
17
|
+
//# sourceMappingURL=linearStack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linearStack.d.ts","sourceRoot":"","sources":["../../src/layout/linearStack.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,IAAI,GAAG,YAAY,GAAG,UAAU,CAAA;AAC5C,MAAM,MAAM,IAAI,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAC3C,MAAM,MAAM,IAAI,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACjE,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAA;AACtD,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEhD,gFAAgF;AAChF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,IAAI,EAAE,EACb,QAAQ,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAC1B,IAAI,CAwBN;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,MAAM,EAC3B,KAAK,EAAE,IAAI,EAAE,EACb,QAAQ,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAC1B,IAAI,EAAE,CAiER"}
|