@compilr-dev/cli 0.4.0 → 0.5.0
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 +30 -12
- package/dist/agent.d.ts +74 -1
- package/dist/agent.js +259 -76
- package/dist/anchors/index.d.ts +9 -0
- package/dist/anchors/index.js +9 -0
- package/dist/anchors/project-anchors.d.ts +79 -0
- package/dist/anchors/project-anchors.js +202 -0
- package/dist/commands/handler-types.d.ts +68 -0
- package/dist/commands/handler-types.js +8 -0
- package/dist/commands/handlers/agent-commands.d.ts +13 -0
- package/dist/commands/handlers/agent-commands.js +305 -0
- package/dist/commands/handlers/design-commands.d.ts +15 -0
- package/dist/commands/handlers/design-commands.js +334 -0
- package/dist/commands/handlers/index.d.ts +20 -0
- package/dist/commands/handlers/index.js +43 -0
- package/dist/commands/handlers/overlay-commands.d.ts +21 -0
- package/dist/commands/handlers/overlay-commands.js +287 -0
- package/dist/commands/handlers/project-commands.d.ts +11 -0
- package/dist/commands/handlers/project-commands.js +167 -0
- package/dist/commands/handlers/simple-commands.d.ts +19 -0
- package/dist/commands/handlers/simple-commands.js +144 -0
- package/dist/commands/index.d.ts +2 -1
- package/dist/commands/registry.d.ts +50 -0
- package/dist/commands/registry.js +75 -0
- package/dist/commands-v2/handlers/context.d.ts +13 -0
- package/dist/commands-v2/handlers/context.js +348 -0
- package/dist/commands-v2/handlers/core.d.ts +13 -0
- package/dist/commands-v2/handlers/core.js +165 -0
- package/dist/commands-v2/handlers/debug.d.ts +11 -0
- package/dist/commands-v2/handlers/debug.js +159 -0
- package/dist/commands-v2/handlers/index.d.ts +12 -0
- package/dist/commands-v2/handlers/index.js +24 -0
- package/dist/commands-v2/handlers/project.d.ts +22 -0
- package/dist/commands-v2/handlers/project.js +814 -0
- package/dist/commands-v2/handlers/settings.d.ts +15 -0
- package/dist/commands-v2/handlers/settings.js +235 -0
- package/dist/commands-v2/index.d.ts +13 -0
- package/dist/commands-v2/index.js +15 -0
- package/dist/commands-v2/registry.d.ts +37 -0
- package/dist/commands-v2/registry.js +80 -0
- package/dist/commands-v2/types.d.ts +75 -0
- package/dist/commands-v2/types.js +7 -0
- package/dist/commands.js +110 -7
- package/dist/index.js +288 -29
- package/dist/input-handlers/index.d.ts +7 -0
- package/dist/input-handlers/index.js +7 -0
- package/dist/input-handlers/memory-handler.d.ts +26 -0
- package/dist/input-handlers/memory-handler.js +68 -0
- package/dist/repl-helpers.d.ts +63 -0
- package/dist/repl-helpers.js +318 -0
- package/dist/repl-v2.d.ts +155 -0
- package/dist/repl-v2.js +774 -0
- package/dist/repl.d.ts +32 -4
- package/dist/repl.js +250 -977
- package/dist/settings/index.d.ts +23 -0
- package/dist/settings/index.js +48 -0
- package/dist/settings/paths.d.ts +110 -0
- package/dist/settings/paths.js +264 -0
- package/dist/templates/compilr-md.js +7 -4
- package/dist/templates/index.js +3 -4
- package/dist/themes/colors.js +3 -1
- package/dist/themes/registry.d.ts +5 -36
- package/dist/themes/registry.js +11 -95
- package/dist/themes/types.d.ts +3 -38
- package/dist/themes/types.js +2 -2
- package/dist/tools/anchor-tools.d.ts +31 -0
- package/dist/tools/anchor-tools.js +255 -0
- package/dist/tools/backlog-wrappers.d.ts +54 -0
- package/dist/tools/backlog-wrappers.js +338 -0
- package/dist/tools/backlog.js +1 -1
- package/dist/tools/db-tools.d.ts +65 -0
- package/dist/tools/db-tools.js +19 -0
- package/dist/tools/document-db.d.ts +43 -0
- package/dist/tools/document-db.js +220 -0
- package/dist/tools/project-db.d.ts +102 -0
- package/dist/tools/project-db.js +370 -0
- package/dist/tools/workitem-db.d.ts +103 -0
- package/dist/tools/workitem-db.js +549 -0
- package/dist/tools.js +13 -3
- package/dist/ui/agents-overlay-v2.d.ts +43 -0
- package/dist/ui/agents-overlay-v2.js +809 -0
- package/dist/ui/agents-overlay.d.ts +5 -5
- package/dist/ui/agents-overlay.js +782 -420
- package/dist/ui/anchors-overlay.d.ts +12 -0
- package/dist/ui/anchors-overlay.js +775 -0
- package/dist/ui/arch-type-overlay.d.ts +1 -6
- package/dist/ui/arch-type-overlay.js +175 -203
- package/dist/ui/ask-user-overlay-v2.d.ts +26 -0
- package/dist/ui/ask-user-overlay-v2.js +555 -0
- package/dist/ui/ask-user-overlay.d.ts +2 -2
- package/dist/ui/ask-user-overlay.js +443 -535
- package/dist/ui/ask-user-simple-overlay-v2.d.ts +25 -0
- package/dist/ui/ask-user-simple-overlay-v2.js +215 -0
- package/dist/ui/ask-user-simple-overlay.d.ts +2 -2
- package/dist/ui/ask-user-simple-overlay.js +182 -209
- package/dist/ui/backlog-overlay.d.ts +16 -1
- package/dist/ui/backlog-overlay.js +525 -659
- package/dist/ui/base/index.d.ts +26 -0
- package/dist/ui/base/index.js +33 -0
- package/dist/ui/base/inline-overlay-utils.d.ts +217 -0
- package/dist/ui/base/inline-overlay-utils.js +320 -0
- package/dist/ui/base/inline-overlay.d.ts +159 -0
- package/dist/ui/base/inline-overlay.js +257 -0
- package/dist/ui/base/key-utils.d.ts +15 -0
- package/dist/ui/base/key-utils.js +30 -0
- package/dist/ui/base/overlay-base-v2.d.ts +193 -0
- package/dist/ui/base/overlay-base-v2.js +246 -0
- package/dist/ui/base/overlay-base.d.ts +156 -0
- package/dist/ui/base/overlay-base.js +238 -0
- package/dist/ui/base/overlay-lifecycle.d.ts +65 -0
- package/dist/ui/base/overlay-lifecycle.js +159 -0
- package/dist/ui/base/overlay-types.d.ts +185 -0
- package/dist/ui/base/overlay-types.js +7 -0
- package/dist/ui/base/render-utils.d.ts +8 -0
- package/dist/ui/base/render-utils.js +11 -0
- package/dist/ui/base/screen-stack.d.ts +148 -0
- package/dist/ui/base/screen-stack.js +184 -0
- package/dist/ui/base/tabbed-list-overlay-v2.d.ts +103 -0
- package/dist/ui/base/tabbed-list-overlay-v2.js +317 -0
- package/dist/ui/base/tabbed-list-overlay.d.ts +153 -0
- package/dist/ui/base/tabbed-list-overlay.js +369 -0
- package/dist/ui/commands-overlay-v2.d.ts +33 -0
- package/dist/ui/commands-overlay-v2.js +441 -0
- package/dist/ui/commands-overlay.d.ts +7 -2
- package/dist/ui/commands-overlay.js +384 -355
- package/dist/ui/config-overlay.d.ts +5 -4
- package/dist/ui/config-overlay.js +243 -513
- package/dist/ui/conversation.d.ts +75 -4
- package/dist/ui/conversation.js +374 -161
- package/dist/ui/docs-overlay.d.ts +17 -0
- package/dist/ui/docs-overlay.js +303 -0
- package/dist/ui/ephemeral.d.ts +1 -1
- package/dist/ui/ephemeral.js +1 -1
- package/dist/ui/features/index.d.ts +34 -0
- package/dist/ui/features/index.js +34 -0
- package/dist/ui/features/input-feature.d.ts +85 -0
- package/dist/ui/features/input-feature.js +238 -0
- package/dist/ui/features/list-feature.d.ts +155 -0
- package/dist/ui/features/list-feature.js +244 -0
- package/dist/ui/features/pagination-feature.d.ts +154 -0
- package/dist/ui/features/pagination-feature.js +238 -0
- package/dist/ui/features/search-feature.d.ts +148 -0
- package/dist/ui/features/search-feature.js +185 -0
- package/dist/ui/features/tab-feature.d.ts +194 -0
- package/dist/ui/features/tab-feature.js +307 -0
- package/dist/ui/footer-v2.d.ts +222 -0
- package/dist/ui/footer-v2.js +1349 -0
- package/dist/ui/footer.d.ts +107 -0
- package/dist/ui/footer.js +359 -67
- package/dist/ui/guardrail-overlay.d.ts +29 -0
- package/dist/ui/guardrail-overlay.js +145 -0
- package/dist/ui/help-overlay-v2.d.ts +34 -0
- package/dist/ui/help-overlay-v2.js +309 -0
- package/dist/ui/help-overlay.d.ts +16 -0
- package/dist/ui/help-overlay.js +316 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -3
- package/dist/ui/init-overlay-v2.d.ts +34 -0
- package/dist/ui/init-overlay-v2.js +600 -0
- package/dist/ui/init-overlay.d.ts +12 -2
- package/dist/ui/init-overlay.js +349 -270
- package/dist/ui/input-prompt-v2.d.ts +1 -0
- package/dist/ui/input-prompt-v2.js +14 -6
- package/dist/ui/input-prompt.d.ts +116 -33
- package/dist/ui/input-prompt.js +536 -337
- package/dist/ui/iteration-limit-overlay-v2.d.ts +21 -0
- package/dist/ui/iteration-limit-overlay-v2.js +114 -0
- package/dist/ui/iteration-limit-overlay.d.ts +2 -2
- package/dist/ui/iteration-limit-overlay.js +92 -128
- package/dist/ui/keys-overlay-v2.d.ts +41 -0
- package/dist/ui/keys-overlay-v2.js +248 -0
- package/dist/ui/keys-overlay.d.ts +1 -0
- package/dist/ui/keys-overlay.js +203 -141
- package/dist/ui/line-utils.d.ts +88 -0
- package/dist/ui/line-utils.js +150 -0
- package/dist/ui/live-region.d.ts +161 -0
- package/dist/ui/live-region.js +387 -0
- package/dist/ui/mascot/expressions.d.ts +32 -0
- package/dist/ui/mascot/expressions.js +213 -0
- package/dist/ui/mascot/index.d.ts +8 -0
- package/dist/ui/mascot/index.js +8 -0
- package/dist/ui/mascot/renderer.d.ts +19 -0
- package/dist/ui/mascot/renderer.js +97 -0
- package/dist/ui/mascot-overlay-v2.d.ts +41 -0
- package/dist/ui/mascot-overlay-v2.js +138 -0
- package/dist/ui/mascot-overlay.d.ts +21 -0
- package/dist/ui/mascot-overlay.js +146 -0
- package/dist/ui/model-overlay-v2.d.ts +49 -0
- package/dist/ui/model-overlay-v2.js +118 -0
- package/dist/ui/model-overlay.d.ts +27 -0
- package/dist/ui/model-overlay.js +221 -0
- package/dist/ui/model-warning-overlay.js +3 -5
- package/dist/ui/new-overlay.d.ts +34 -0
- package/dist/ui/new-overlay.js +604 -0
- package/dist/ui/overlay/impl/agents-overlay-v2.d.ts +45 -0
- package/dist/ui/overlay/impl/agents-overlay-v2.js +825 -0
- package/dist/ui/overlay/impl/anchors-overlay-v2.d.ts +47 -0
- package/dist/ui/overlay/impl/anchors-overlay-v2.js +783 -0
- package/dist/ui/overlay/impl/arch-type-overlay-v2.d.ts +37 -0
- package/dist/ui/overlay/impl/arch-type-overlay-v2.js +240 -0
- package/dist/ui/overlay/impl/ask-user-overlay-v2.d.ts +72 -0
- package/dist/ui/overlay/impl/ask-user-overlay-v2.js +584 -0
- package/dist/ui/overlay/impl/ask-user-simple-overlay-v2.d.ts +46 -0
- package/dist/ui/overlay/impl/ask-user-simple-overlay-v2.js +204 -0
- package/dist/ui/overlay/impl/backlog-overlay-v2.d.ts +49 -0
- package/dist/ui/overlay/impl/backlog-overlay-v2.js +642 -0
- package/dist/ui/overlay/impl/commands-overlay-v2.d.ts +33 -0
- package/dist/ui/overlay/impl/commands-overlay-v2.js +441 -0
- package/dist/ui/overlay/impl/config-overlay-v2.d.ts +100 -0
- package/dist/ui/overlay/impl/config-overlay-v2.js +654 -0
- package/dist/ui/overlay/impl/dashboard-overlay-v2.d.ts +55 -0
- package/dist/ui/overlay/impl/dashboard-overlay-v2.js +359 -0
- package/dist/ui/overlay/impl/docs-overlay-v2.d.ts +45 -0
- package/dist/ui/overlay/impl/docs-overlay-v2.js +114 -0
- package/dist/ui/overlay/impl/document-detail-overlay-v2.d.ts +77 -0
- package/dist/ui/overlay/impl/document-detail-overlay-v2.js +1071 -0
- package/dist/ui/overlay/impl/guardrail-overlay-v2.d.ts +43 -0
- package/dist/ui/overlay/impl/guardrail-overlay-v2.js +114 -0
- package/dist/ui/overlay/impl/help-overlay-v2.d.ts +34 -0
- package/dist/ui/overlay/impl/help-overlay-v2.js +309 -0
- package/dist/ui/overlay/impl/init-overlay-v2.d.ts +77 -0
- package/dist/ui/overlay/impl/init-overlay-v2.js +593 -0
- package/dist/ui/overlay/impl/init-setup-overlay-v2.d.ts +25 -0
- package/dist/ui/overlay/impl/init-setup-overlay-v2.js +97 -0
- package/dist/ui/overlay/impl/iteration-limit-overlay-v2.d.ts +35 -0
- package/dist/ui/overlay/impl/iteration-limit-overlay-v2.js +105 -0
- package/dist/ui/overlay/impl/keys-overlay-v2.d.ts +41 -0
- package/dist/ui/overlay/impl/keys-overlay-v2.js +248 -0
- package/dist/ui/overlay/impl/mascot-overlay-v2.d.ts +41 -0
- package/dist/ui/overlay/impl/mascot-overlay-v2.js +138 -0
- package/dist/ui/overlay/impl/model-overlay-v2.d.ts +49 -0
- package/dist/ui/overlay/impl/model-overlay-v2.js +118 -0
- package/dist/ui/overlay/impl/model-warning-overlay-v2.d.ts +46 -0
- package/dist/ui/overlay/impl/model-warning-overlay-v2.js +132 -0
- package/dist/ui/overlay/impl/new-overlay-v2.d.ts +77 -0
- package/dist/ui/overlay/impl/new-overlay-v2.js +593 -0
- package/dist/ui/overlay/impl/permission-overlay-v2.d.ts +36 -0
- package/dist/ui/overlay/impl/permission-overlay-v2.js +380 -0
- package/dist/ui/overlay/impl/projects-overlay-v2.d.ts +36 -0
- package/dist/ui/overlay/impl/projects-overlay-v2.js +499 -0
- package/dist/ui/overlay/impl/theme-overlay-v2.d.ts +42 -0
- package/dist/ui/overlay/impl/theme-overlay-v2.js +135 -0
- package/dist/ui/overlay/impl/tools-overlay-v2.d.ts +47 -0
- package/dist/ui/overlay/impl/tools-overlay-v2.js +218 -0
- package/dist/ui/overlay/impl/tutorial-overlay-v2.d.ts +31 -0
- package/dist/ui/overlay/impl/tutorial-overlay-v2.js +1035 -0
- package/dist/ui/overlay/impl/workflow-overlay-v2.d.ts +80 -0
- package/dist/ui/overlay/impl/workflow-overlay-v2.js +637 -0
- package/dist/ui/overlay/index.d.ts +33 -0
- package/dist/ui/overlay/index.js +35 -0
- package/dist/ui/overlay/key-utils.d.ts +6 -0
- package/dist/ui/overlay/key-utils.js +6 -0
- package/dist/ui/overlay/overlay-types.d.ts +128 -0
- package/dist/ui/overlay/overlay-types.js +22 -0
- package/dist/ui/overlay/types.d.ts +135 -0
- package/dist/ui/overlay/types.js +22 -0
- package/dist/ui/overlays/help-overlay-v2.d.ts +28 -0
- package/dist/ui/overlays/help-overlay-v2.js +198 -0
- package/dist/ui/overlays/index.d.ts +11 -0
- package/dist/ui/overlays/index.js +11 -0
- package/dist/ui/overlays.d.ts +0 -4
- package/dist/ui/overlays.js +0 -444
- package/dist/ui/permission-overlay-v2.d.ts +36 -0
- package/dist/ui/permission-overlay-v2.js +380 -0
- package/dist/ui/permission-overlay.d.ts +1 -1
- package/dist/ui/permission-overlay.js +186 -298
- package/dist/ui/projects-overlay.d.ts +19 -0
- package/dist/ui/projects-overlay.js +484 -0
- package/dist/ui/providers/types.d.ts +178 -0
- package/dist/ui/providers/types.js +9 -0
- package/dist/ui/render-modes.d.ts +36 -0
- package/dist/ui/render-modes.js +44 -0
- package/dist/ui/startup-menu.d.ts +36 -0
- package/dist/ui/startup-menu.js +236 -0
- package/dist/ui/subagent-renderer.d.ts +117 -0
- package/dist/ui/subagent-renderer.js +334 -0
- package/dist/ui/terminal-codes.d.ts +94 -0
- package/dist/ui/terminal-codes.js +124 -0
- package/dist/ui/terminal-renderer.d.ts +221 -0
- package/dist/ui/terminal-renderer.js +751 -0
- package/dist/ui/terminal-ui.d.ts +463 -0
- package/dist/ui/terminal-ui.js +2296 -0
- package/dist/ui/terminal.d.ts +20 -0
- package/dist/ui/terminal.js +72 -0
- package/dist/ui/theme-overlay-v2.d.ts +42 -0
- package/dist/ui/theme-overlay-v2.js +135 -0
- package/dist/ui/theme-overlay.d.ts +24 -0
- package/dist/ui/theme-overlay.js +127 -0
- package/dist/ui/todo-zone.js +53 -25
- package/dist/ui/tool-formatters.d.ts +16 -0
- package/dist/ui/tool-formatters.js +516 -0
- package/dist/ui/tools-overlay-v2.d.ts +47 -0
- package/dist/ui/tools-overlay-v2.js +218 -0
- package/dist/ui/tools-overlay.d.ts +10 -2
- package/dist/ui/tools-overlay.js +172 -220
- package/dist/ui/tutorial-overlay-v2.d.ts +31 -0
- package/dist/ui/tutorial-overlay-v2.js +1035 -0
- package/dist/ui/tutorial-overlay.d.ts +1 -0
- package/dist/ui/tutorial-overlay.js +400 -302
- package/dist/ui/workflow-overlay.d.ts +22 -0
- package/dist/ui/workflow-overlay.js +636 -0
- package/dist/utils/debug-log.d.ts +28 -0
- package/dist/utils/debug-log.js +57 -0
- package/dist/utils/model-tiers.js +1 -1
- package/dist/utils/path-safety.d.ts +56 -0
- package/dist/utils/path-safety.js +239 -0
- package/dist/workflow/guided-mode-injector.d.ts +42 -0
- package/dist/workflow/guided-mode-injector.js +191 -0
- package/dist/workflow/index.d.ts +8 -0
- package/dist/workflow/index.js +8 -0
- package/dist/workflow/step-criteria.d.ts +62 -0
- package/dist/workflow/step-criteria.js +150 -0
- package/dist/workflow/step-tracker.d.ts +92 -0
- package/dist/workflow/step-tracker.js +141 -0
- package/package.json +12 -5
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base UI Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for consistent overlay behavior.
|
|
5
|
+
*
|
|
6
|
+
* Components:
|
|
7
|
+
* - key-utils: Key detection functions
|
|
8
|
+
* - overlay-types: Core interfaces and types
|
|
9
|
+
* - overlay-lifecycle: Lifecycle management
|
|
10
|
+
* - overlay-base: BaseOverlay abstract class
|
|
11
|
+
* - screen-stack: Navigation stack for multi-screen overlays
|
|
12
|
+
*/
|
|
13
|
+
export * from './key-utils.js';
|
|
14
|
+
export * from './overlay-types.js';
|
|
15
|
+
export { OverlayLifecycle, setupOverlay } from './overlay-lifecycle.js';
|
|
16
|
+
export type { KeyHandler } from './overlay-lifecycle.js';
|
|
17
|
+
export { BaseOverlay } from './overlay-base.js';
|
|
18
|
+
export { BaseScreen, ScreenStack, stay, pushScreen, popScreen, closeOverlay, } from './screen-stack.js';
|
|
19
|
+
export { renderBorder, wrapText, truncate, truncateAnsi, normalizeText, padToHeight, emptyLines, } from './render-utils.js';
|
|
20
|
+
export { TabbedListOverlay } from './tabbed-list-overlay.js';
|
|
21
|
+
export type { TabbedListConfig, TabbedListState } from './tabbed-list-overlay.js';
|
|
22
|
+
export { BaseOverlayV2 } from './overlay-base-v2.js';
|
|
23
|
+
export { TabbedListOverlayV2 } from './tabbed-list-overlay-v2.js';
|
|
24
|
+
export type { TabbedListConfigV2, TabbedListStateV2, } from './tabbed-list-overlay-v2.js';
|
|
25
|
+
export { createInlineOverlayContext, inlineSetup, inlineCleanup, inlineCleanupWithSummary, inlineClearPrevious, inlinePadLines, inlineRenderLines, inlineRender, inlineUpdateContext, isEscapeKey, isCtrlCKey, isEnterKey, isBackspaceKey, isUpArrowKey, isDownArrowKey, isLeftArrowKey, isRightArrowKey, isTabKey, isSpaceKey, isPrintableChar, getPrintableChar, isNumberKey, getNumberKey, getNumberKeyIndex, } from './inline-overlay-utils.js';
|
|
26
|
+
export type { InlineOverlayContext } from './inline-overlay-utils.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base UI Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for consistent overlay behavior.
|
|
5
|
+
*
|
|
6
|
+
* Components:
|
|
7
|
+
* - key-utils: Key detection functions
|
|
8
|
+
* - overlay-types: Core interfaces and types
|
|
9
|
+
* - overlay-lifecycle: Lifecycle management
|
|
10
|
+
* - overlay-base: BaseOverlay abstract class
|
|
11
|
+
* - screen-stack: Navigation stack for multi-screen overlays
|
|
12
|
+
*/
|
|
13
|
+
// Key detection utilities
|
|
14
|
+
export * from './key-utils.js';
|
|
15
|
+
// Core types and interfaces
|
|
16
|
+
export * from './overlay-types.js';
|
|
17
|
+
// Lifecycle management
|
|
18
|
+
export { OverlayLifecycle, setupOverlay } from './overlay-lifecycle.js';
|
|
19
|
+
// Base overlay class
|
|
20
|
+
export { BaseOverlay } from './overlay-base.js';
|
|
21
|
+
// Screen stack for multi-screen overlays
|
|
22
|
+
export { BaseScreen, ScreenStack, stay, pushScreen, popScreen, closeOverlay, } from './screen-stack.js';
|
|
23
|
+
// Render utilities
|
|
24
|
+
export { renderBorder, wrapText, truncate, truncateAnsi, normalizeText, padToHeight, emptyLines, } from './render-utils.js';
|
|
25
|
+
// Tabbed list overlay base
|
|
26
|
+
export { TabbedListOverlay } from './tabbed-list-overlay.js';
|
|
27
|
+
// V2 Overlay base classes (new Overlay interface)
|
|
28
|
+
export { BaseOverlayV2 } from './overlay-base-v2.js';
|
|
29
|
+
export { TabbedListOverlayV2 } from './tabbed-list-overlay-v2.js';
|
|
30
|
+
// Inline overlay utilities (for in-conversation overlays)
|
|
31
|
+
export { createInlineOverlayContext, inlineSetup, inlineCleanup, inlineCleanupWithSummary, inlineClearPrevious, inlinePadLines, inlineRenderLines, inlineRender, inlineUpdateContext,
|
|
32
|
+
// Key detection (also available from key-utils)
|
|
33
|
+
isEscapeKey, isCtrlCKey, isEnterKey, isBackspaceKey, isUpArrowKey, isDownArrowKey, isLeftArrowKey, isRightArrowKey, isTabKey, isSpaceKey, isPrintableChar, getPrintableChar, isNumberKey, getNumberKey, getNumberKeyIndex, } from './inline-overlay-utils.js';
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline Overlay Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for "in-conversation" overlays that render above the footer.
|
|
5
|
+
* These overlays differ from full-screen overlays (BaseOverlay) in that they:
|
|
6
|
+
* - Render inline within the conversation
|
|
7
|
+
* - Use line-based clearing (clearLinesAbove) instead of full screen clear
|
|
8
|
+
* - Track line counts to prevent ghost lines and cursor drift
|
|
9
|
+
*
|
|
10
|
+
* CANONICAL PATTERN for inline overlays:
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* export async function showMyOverlay(options: Options): Promise<Result> {
|
|
14
|
+
* const state = { ... };
|
|
15
|
+
* const ctx = createInlineOverlayContext();
|
|
16
|
+
*
|
|
17
|
+
* // Setup
|
|
18
|
+
* // NOTE: Footer should be paused by CALLER (index.ts), not here
|
|
19
|
+
* // This prevents double-pause issues with agent tool overlays
|
|
20
|
+
* inlineSetup(ctx);
|
|
21
|
+
*
|
|
22
|
+
* // Initial render
|
|
23
|
+
* ctx.lineCount = renderMyOverlay(options, state, ctx);
|
|
24
|
+
* ctx.maxLineCount = Math.max(ctx.maxLineCount, ctx.lineCount);
|
|
25
|
+
*
|
|
26
|
+
* return new Promise((resolve) => {
|
|
27
|
+
* const cleanup = (result: Result) => {
|
|
28
|
+
* inlineCleanup(ctx);
|
|
29
|
+
* process.stdin.removeListener('data', handleData);
|
|
30
|
+
* resolve(result);
|
|
31
|
+
* };
|
|
32
|
+
*
|
|
33
|
+
* const handleData = (data: Buffer) => {
|
|
34
|
+
* // Handle keys, update state
|
|
35
|
+
* // ...
|
|
36
|
+
*
|
|
37
|
+
* // Re-render (always use maxLineCount for both clearing and target)
|
|
38
|
+
* ctx.lineCount = renderMyOverlay(options, state, ctx);
|
|
39
|
+
* ctx.maxLineCount = Math.max(ctx.maxLineCount, ctx.lineCount);
|
|
40
|
+
* };
|
|
41
|
+
*
|
|
42
|
+
* process.stdin.on('data', handleData);
|
|
43
|
+
* });
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* RENDER FUNCTION pattern:
|
|
48
|
+
*
|
|
49
|
+
* ```typescript
|
|
50
|
+
* function renderMyOverlay(
|
|
51
|
+
* options: Options,
|
|
52
|
+
* state: State,
|
|
53
|
+
* ctx: InlineOverlayContext
|
|
54
|
+
* ): number {
|
|
55
|
+
* const lines: string[] = [];
|
|
56
|
+
*
|
|
57
|
+
* // Clear previous render
|
|
58
|
+
* if (ctx.maxLineCount > 0) {
|
|
59
|
+
* terminal.clearLinesAbove(ctx.maxLineCount);
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* // Build lines array
|
|
63
|
+
* lines.push(...);
|
|
64
|
+
*
|
|
65
|
+
* // Pad to consistent height (prevents cursor drift)
|
|
66
|
+
* while (lines.length < ctx.maxLineCount) {
|
|
67
|
+
* lines.push('');
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* // Render
|
|
71
|
+
* terminal.write(lines.join('\n'));
|
|
72
|
+
*
|
|
73
|
+
* return lines.length;
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* Context for tracking inline overlay render state.
|
|
79
|
+
* This prevents ghost lines and cursor drift.
|
|
80
|
+
*/
|
|
81
|
+
export interface InlineOverlayContext {
|
|
82
|
+
/** Current number of lines rendered */
|
|
83
|
+
lineCount: number;
|
|
84
|
+
/** Maximum lines ever rendered (used for clearing) */
|
|
85
|
+
maxLineCount: number;
|
|
86
|
+
/** Whether raw mode was enabled before overlay */
|
|
87
|
+
wasRawMode: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a new inline overlay context.
|
|
91
|
+
* Call this at the start of showXxxOverlay().
|
|
92
|
+
*/
|
|
93
|
+
export declare function createInlineOverlayContext(): InlineOverlayContext;
|
|
94
|
+
/**
|
|
95
|
+
* Standard setup for inline overlays.
|
|
96
|
+
* Call this after creating the context.
|
|
97
|
+
*
|
|
98
|
+
* NOTE: Footer pause should be handled by the CALLER (index.ts),
|
|
99
|
+
* not by the overlay itself. This prevents double-pause issues
|
|
100
|
+
* when overlays are triggered by agent tools.
|
|
101
|
+
*/
|
|
102
|
+
export declare function inlineSetup(ctx: InlineOverlayContext): void;
|
|
103
|
+
/**
|
|
104
|
+
* Standard cleanup for inline overlays.
|
|
105
|
+
* Call this before resolving the promise.
|
|
106
|
+
*
|
|
107
|
+
* NOTE: Footer resume should be handled by the CALLER (index.ts),
|
|
108
|
+
* not by the overlay itself.
|
|
109
|
+
*/
|
|
110
|
+
export declare function inlineCleanup(ctx: InlineOverlayContext): void;
|
|
111
|
+
/**
|
|
112
|
+
* Cleanup with a result summary line.
|
|
113
|
+
* Some overlays show a brief result after closing.
|
|
114
|
+
*/
|
|
115
|
+
export declare function inlineCleanupWithSummary(ctx: InlineOverlayContext, summaryLine: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* Clear previous render and prepare for new render.
|
|
118
|
+
* Call this at the start of your render function.
|
|
119
|
+
*
|
|
120
|
+
* @param ctx - The overlay context
|
|
121
|
+
*/
|
|
122
|
+
export declare function inlineClearPrevious(ctx: InlineOverlayContext): void;
|
|
123
|
+
/**
|
|
124
|
+
* Pad lines array to target height (prevents cursor drift).
|
|
125
|
+
* Call this before rendering.
|
|
126
|
+
*
|
|
127
|
+
* @param lines - Array of lines to pad
|
|
128
|
+
* @param targetLineCount - Target number of lines (usually ctx.maxLineCount)
|
|
129
|
+
*/
|
|
130
|
+
export declare function inlinePadLines(lines: string[], targetLineCount: number): void;
|
|
131
|
+
/**
|
|
132
|
+
* Render lines and return the line count.
|
|
133
|
+
* Call this at the end of your render function.
|
|
134
|
+
*
|
|
135
|
+
* @param lines - Array of lines to render
|
|
136
|
+
* @returns Number of lines rendered
|
|
137
|
+
*/
|
|
138
|
+
export declare function inlineRenderLines(lines: string[]): number;
|
|
139
|
+
/**
|
|
140
|
+
* Complete render helper that clears, pads, and renders.
|
|
141
|
+
* Use this for simpler overlays.
|
|
142
|
+
*
|
|
143
|
+
* @param lines - Array of lines to render
|
|
144
|
+
* @param ctx - The overlay context
|
|
145
|
+
* @returns Number of lines rendered
|
|
146
|
+
*/
|
|
147
|
+
export declare function inlineRender(lines: string[], ctx: InlineOverlayContext): number;
|
|
148
|
+
/**
|
|
149
|
+
* Update context after render.
|
|
150
|
+
* Call this after your render function returns.
|
|
151
|
+
*
|
|
152
|
+
* @param ctx - The overlay context
|
|
153
|
+
* @param newLineCount - Number of lines just rendered
|
|
154
|
+
*/
|
|
155
|
+
export declare function inlineUpdateContext(ctx: InlineOverlayContext, newLineCount: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* Check if buffer is Escape key
|
|
158
|
+
*/
|
|
159
|
+
export declare function isEscapeKey(data: Buffer): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Check if buffer is Ctrl+C
|
|
162
|
+
*/
|
|
163
|
+
export declare function isCtrlCKey(data: Buffer): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Check if buffer is Enter key
|
|
166
|
+
*/
|
|
167
|
+
export declare function isEnterKey(data: Buffer): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Check if buffer is Backspace key
|
|
170
|
+
*/
|
|
171
|
+
export declare function isBackspaceKey(data: Buffer): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Check if buffer is Up arrow
|
|
174
|
+
*/
|
|
175
|
+
export declare function isUpArrowKey(data: Buffer): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Check if buffer is Down arrow
|
|
178
|
+
*/
|
|
179
|
+
export declare function isDownArrowKey(data: Buffer): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Check if buffer is Left arrow
|
|
182
|
+
*/
|
|
183
|
+
export declare function isLeftArrowKey(data: Buffer): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Check if buffer is Right arrow
|
|
186
|
+
*/
|
|
187
|
+
export declare function isRightArrowKey(data: Buffer): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Check if buffer is Tab key
|
|
190
|
+
*/
|
|
191
|
+
export declare function isTabKey(data: Buffer): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Check if buffer is Space key
|
|
194
|
+
*/
|
|
195
|
+
export declare function isSpaceKey(data: Buffer): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Check if buffer is a printable ASCII character
|
|
198
|
+
*/
|
|
199
|
+
export declare function isPrintableChar(data: Buffer): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Get printable character from buffer, or null if not printable
|
|
202
|
+
*/
|
|
203
|
+
export declare function getPrintableChar(data: Buffer): string | null;
|
|
204
|
+
/**
|
|
205
|
+
* Check if buffer is a number key (1-9)
|
|
206
|
+
*/
|
|
207
|
+
export declare function isNumberKey(data: Buffer): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Get number from number key (1-9), or null if not a number key
|
|
210
|
+
* Returns 1-9 (not 0-8)
|
|
211
|
+
*/
|
|
212
|
+
export declare function getNumberKey(data: Buffer): number | null;
|
|
213
|
+
/**
|
|
214
|
+
* Get 0-indexed number from number key, or null if not a number key
|
|
215
|
+
* Returns 0-8 (for use as array index)
|
|
216
|
+
*/
|
|
217
|
+
export declare function getNumberKeyIndex(data: Buffer): number | null;
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline Overlay Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for "in-conversation" overlays that render above the footer.
|
|
5
|
+
* These overlays differ from full-screen overlays (BaseOverlay) in that they:
|
|
6
|
+
* - Render inline within the conversation
|
|
7
|
+
* - Use line-based clearing (clearLinesAbove) instead of full screen clear
|
|
8
|
+
* - Track line counts to prevent ghost lines and cursor drift
|
|
9
|
+
*
|
|
10
|
+
* CANONICAL PATTERN for inline overlays:
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* export async function showMyOverlay(options: Options): Promise<Result> {
|
|
14
|
+
* const state = { ... };
|
|
15
|
+
* const ctx = createInlineOverlayContext();
|
|
16
|
+
*
|
|
17
|
+
* // Setup
|
|
18
|
+
* // NOTE: Footer should be paused by CALLER (index.ts), not here
|
|
19
|
+
* // This prevents double-pause issues with agent tool overlays
|
|
20
|
+
* inlineSetup(ctx);
|
|
21
|
+
*
|
|
22
|
+
* // Initial render
|
|
23
|
+
* ctx.lineCount = renderMyOverlay(options, state, ctx);
|
|
24
|
+
* ctx.maxLineCount = Math.max(ctx.maxLineCount, ctx.lineCount);
|
|
25
|
+
*
|
|
26
|
+
* return new Promise((resolve) => {
|
|
27
|
+
* const cleanup = (result: Result) => {
|
|
28
|
+
* inlineCleanup(ctx);
|
|
29
|
+
* process.stdin.removeListener('data', handleData);
|
|
30
|
+
* resolve(result);
|
|
31
|
+
* };
|
|
32
|
+
*
|
|
33
|
+
* const handleData = (data: Buffer) => {
|
|
34
|
+
* // Handle keys, update state
|
|
35
|
+
* // ...
|
|
36
|
+
*
|
|
37
|
+
* // Re-render (always use maxLineCount for both clearing and target)
|
|
38
|
+
* ctx.lineCount = renderMyOverlay(options, state, ctx);
|
|
39
|
+
* ctx.maxLineCount = Math.max(ctx.maxLineCount, ctx.lineCount);
|
|
40
|
+
* };
|
|
41
|
+
*
|
|
42
|
+
* process.stdin.on('data', handleData);
|
|
43
|
+
* });
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* RENDER FUNCTION pattern:
|
|
48
|
+
*
|
|
49
|
+
* ```typescript
|
|
50
|
+
* function renderMyOverlay(
|
|
51
|
+
* options: Options,
|
|
52
|
+
* state: State,
|
|
53
|
+
* ctx: InlineOverlayContext
|
|
54
|
+
* ): number {
|
|
55
|
+
* const lines: string[] = [];
|
|
56
|
+
*
|
|
57
|
+
* // Clear previous render
|
|
58
|
+
* if (ctx.maxLineCount > 0) {
|
|
59
|
+
* terminal.clearLinesAbove(ctx.maxLineCount);
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* // Build lines array
|
|
63
|
+
* lines.push(...);
|
|
64
|
+
*
|
|
65
|
+
* // Pad to consistent height (prevents cursor drift)
|
|
66
|
+
* while (lines.length < ctx.maxLineCount) {
|
|
67
|
+
* lines.push('');
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* // Render
|
|
71
|
+
* terminal.write(lines.join('\n'));
|
|
72
|
+
*
|
|
73
|
+
* return lines.length;
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
import * as terminal from '../terminal.js';
|
|
78
|
+
// =============================================================================
|
|
79
|
+
// Context Management
|
|
80
|
+
// =============================================================================
|
|
81
|
+
/**
|
|
82
|
+
* Create a new inline overlay context.
|
|
83
|
+
* Call this at the start of showXxxOverlay().
|
|
84
|
+
*/
|
|
85
|
+
export function createInlineOverlayContext() {
|
|
86
|
+
return {
|
|
87
|
+
lineCount: 0,
|
|
88
|
+
maxLineCount: 0,
|
|
89
|
+
wasRawMode: process.stdin.isRaw,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// =============================================================================
|
|
93
|
+
// Setup & Cleanup
|
|
94
|
+
// =============================================================================
|
|
95
|
+
/**
|
|
96
|
+
* Standard setup for inline overlays.
|
|
97
|
+
* Call this after creating the context.
|
|
98
|
+
*
|
|
99
|
+
* NOTE: Footer pause should be handled by the CALLER (index.ts),
|
|
100
|
+
* not by the overlay itself. This prevents double-pause issues
|
|
101
|
+
* when overlays are triggered by agent tools.
|
|
102
|
+
*/
|
|
103
|
+
export function inlineSetup(ctx) {
|
|
104
|
+
// Record raw mode state before we change it
|
|
105
|
+
ctx.wasRawMode = process.stdin.isRaw;
|
|
106
|
+
// Start from a fresh line
|
|
107
|
+
terminal.writeLine('');
|
|
108
|
+
// Hide cursor during overlay
|
|
109
|
+
terminal.hideCursor();
|
|
110
|
+
// Enable raw mode for key-by-key input
|
|
111
|
+
terminal.enableRawMode();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Standard cleanup for inline overlays.
|
|
115
|
+
* Call this before resolving the promise.
|
|
116
|
+
*
|
|
117
|
+
* NOTE: Footer resume should be handled by the CALLER (index.ts),
|
|
118
|
+
* not by the overlay itself.
|
|
119
|
+
*/
|
|
120
|
+
export function inlineCleanup(ctx) {
|
|
121
|
+
// Clear all lines we've ever rendered (prevents ghost lines)
|
|
122
|
+
if (ctx.maxLineCount > 0) {
|
|
123
|
+
terminal.clearLinesAbove(ctx.maxLineCount);
|
|
124
|
+
}
|
|
125
|
+
// Show cursor
|
|
126
|
+
terminal.showCursor();
|
|
127
|
+
// Restore raw mode to previous state
|
|
128
|
+
if (!ctx.wasRawMode) {
|
|
129
|
+
terminal.disableRawMode();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Cleanup with a result summary line.
|
|
134
|
+
* Some overlays show a brief result after closing.
|
|
135
|
+
*/
|
|
136
|
+
export function inlineCleanupWithSummary(ctx, summaryLine) {
|
|
137
|
+
// Clear all lines
|
|
138
|
+
if (ctx.maxLineCount > 0) {
|
|
139
|
+
terminal.clearLinesAbove(ctx.maxLineCount);
|
|
140
|
+
}
|
|
141
|
+
// Show result summary
|
|
142
|
+
terminal.writeLine(summaryLine);
|
|
143
|
+
terminal.writeLine(''); // Blank line for separation
|
|
144
|
+
// Show cursor
|
|
145
|
+
terminal.showCursor();
|
|
146
|
+
// Restore raw mode
|
|
147
|
+
if (!ctx.wasRawMode) {
|
|
148
|
+
terminal.disableRawMode();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// =============================================================================
|
|
152
|
+
// Render Helpers
|
|
153
|
+
// =============================================================================
|
|
154
|
+
/**
|
|
155
|
+
* Clear previous render and prepare for new render.
|
|
156
|
+
* Call this at the start of your render function.
|
|
157
|
+
*
|
|
158
|
+
* @param ctx - The overlay context
|
|
159
|
+
*/
|
|
160
|
+
export function inlineClearPrevious(ctx) {
|
|
161
|
+
if (ctx.maxLineCount > 0) {
|
|
162
|
+
terminal.clearLinesAbove(ctx.maxLineCount);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Pad lines array to target height (prevents cursor drift).
|
|
167
|
+
* Call this before rendering.
|
|
168
|
+
*
|
|
169
|
+
* @param lines - Array of lines to pad
|
|
170
|
+
* @param targetLineCount - Target number of lines (usually ctx.maxLineCount)
|
|
171
|
+
*/
|
|
172
|
+
export function inlinePadLines(lines, targetLineCount) {
|
|
173
|
+
while (lines.length < targetLineCount) {
|
|
174
|
+
lines.push('');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Render lines and return the line count.
|
|
179
|
+
* Call this at the end of your render function.
|
|
180
|
+
*
|
|
181
|
+
* @param lines - Array of lines to render
|
|
182
|
+
* @returns Number of lines rendered
|
|
183
|
+
*/
|
|
184
|
+
export function inlineRenderLines(lines) {
|
|
185
|
+
terminal.write(lines.join('\n'));
|
|
186
|
+
return lines.length;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Complete render helper that clears, pads, and renders.
|
|
190
|
+
* Use this for simpler overlays.
|
|
191
|
+
*
|
|
192
|
+
* @param lines - Array of lines to render
|
|
193
|
+
* @param ctx - The overlay context
|
|
194
|
+
* @returns Number of lines rendered
|
|
195
|
+
*/
|
|
196
|
+
export function inlineRender(lines, ctx) {
|
|
197
|
+
// Clear previous
|
|
198
|
+
inlineClearPrevious(ctx);
|
|
199
|
+
// Pad to max height
|
|
200
|
+
inlinePadLines(lines, ctx.maxLineCount);
|
|
201
|
+
// Render and return count
|
|
202
|
+
return inlineRenderLines(lines);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Update context after render.
|
|
206
|
+
* Call this after your render function returns.
|
|
207
|
+
*
|
|
208
|
+
* @param ctx - The overlay context
|
|
209
|
+
* @param newLineCount - Number of lines just rendered
|
|
210
|
+
*/
|
|
211
|
+
export function inlineUpdateContext(ctx, newLineCount) {
|
|
212
|
+
ctx.lineCount = newLineCount;
|
|
213
|
+
ctx.maxLineCount = Math.max(ctx.maxLineCount, newLineCount);
|
|
214
|
+
}
|
|
215
|
+
// =============================================================================
|
|
216
|
+
// Key Detection Utilities
|
|
217
|
+
// =============================================================================
|
|
218
|
+
// These are re-exported for convenience, but the canonical versions
|
|
219
|
+
// are in key-utils.ts. Inline overlays can use either.
|
|
220
|
+
/**
|
|
221
|
+
* Check if buffer is Escape key
|
|
222
|
+
*/
|
|
223
|
+
export function isEscapeKey(data) {
|
|
224
|
+
return data.length === 1 && data[0] === 0x1b;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Check if buffer is Ctrl+C
|
|
228
|
+
*/
|
|
229
|
+
export function isCtrlCKey(data) {
|
|
230
|
+
return data.length === 1 && data[0] === 0x03;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Check if buffer is Enter key
|
|
234
|
+
*/
|
|
235
|
+
export function isEnterKey(data) {
|
|
236
|
+
return data.length === 1 && (data[0] === 0x0d || data[0] === 0x0a);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Check if buffer is Backspace key
|
|
240
|
+
*/
|
|
241
|
+
export function isBackspaceKey(data) {
|
|
242
|
+
return data.length === 1 && (data[0] === 0x7f || data[0] === 0x08);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Check if buffer is Up arrow
|
|
246
|
+
*/
|
|
247
|
+
export function isUpArrowKey(data) {
|
|
248
|
+
return data.length === 3 && data[0] === 0x1b && data[1] === 0x5b && data[2] === 0x41;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Check if buffer is Down arrow
|
|
252
|
+
*/
|
|
253
|
+
export function isDownArrowKey(data) {
|
|
254
|
+
return data.length === 3 && data[0] === 0x1b && data[1] === 0x5b && data[2] === 0x42;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Check if buffer is Left arrow
|
|
258
|
+
*/
|
|
259
|
+
export function isLeftArrowKey(data) {
|
|
260
|
+
return data.length === 3 && data[0] === 0x1b && data[1] === 0x5b && data[2] === 0x44;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Check if buffer is Right arrow
|
|
264
|
+
*/
|
|
265
|
+
export function isRightArrowKey(data) {
|
|
266
|
+
return data.length === 3 && data[0] === 0x1b && data[1] === 0x5b && data[2] === 0x43;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Check if buffer is Tab key
|
|
270
|
+
*/
|
|
271
|
+
export function isTabKey(data) {
|
|
272
|
+
return data.length === 1 && data[0] === 0x09;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Check if buffer is Space key
|
|
276
|
+
*/
|
|
277
|
+
export function isSpaceKey(data) {
|
|
278
|
+
return data.length === 1 && data[0] === 0x20;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Check if buffer is a printable ASCII character
|
|
282
|
+
*/
|
|
283
|
+
export function isPrintableChar(data) {
|
|
284
|
+
return data.length === 1 && data[0] >= 0x20 && data[0] < 0x7f;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get printable character from buffer, or null if not printable
|
|
288
|
+
*/
|
|
289
|
+
export function getPrintableChar(data) {
|
|
290
|
+
if (isPrintableChar(data)) {
|
|
291
|
+
return String.fromCharCode(data[0]);
|
|
292
|
+
}
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Check if buffer is a number key (1-9)
|
|
297
|
+
*/
|
|
298
|
+
export function isNumberKey(data) {
|
|
299
|
+
return data.length === 1 && data[0] >= 0x31 && data[0] <= 0x39;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get number from number key (1-9), or null if not a number key
|
|
303
|
+
* Returns 1-9 (not 0-8)
|
|
304
|
+
*/
|
|
305
|
+
export function getNumberKey(data) {
|
|
306
|
+
if (isNumberKey(data)) {
|
|
307
|
+
return data[0] - 0x30; // Returns 1-9
|
|
308
|
+
}
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Get 0-indexed number from number key, or null if not a number key
|
|
313
|
+
* Returns 0-8 (for use as array index)
|
|
314
|
+
*/
|
|
315
|
+
export function getNumberKeyIndex(data) {
|
|
316
|
+
if (isNumberKey(data)) {
|
|
317
|
+
return data[0] - 0x31; // Returns 0-8
|
|
318
|
+
}
|
|
319
|
+
return null;
|
|
320
|
+
}
|