@bettertui/core 0.1.0 → 0.1.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/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @bettertui/core
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/@bettertui/core.svg)](https://www.npmjs.com/package/@bettertui/core)
4
+ [![crates.io bettertui_engine](https://img.shields.io/crates/v/bettertui_engine.svg)](https://crates.io/crates/bettertui_engine)
5
+ [![docs.rs](https://img.shields.io/docsrs/bettertui_engine)](https://docs.rs/bettertui_engine)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ > **Website:** [bettertui.dev](https://bettertui.dev) | **Docs:** [bettertui.dev/docs](https://bettertui.dev/docs) | **npm:** [npmjs.com/package/@bettertui/core](https://www.npmjs.com/package/@bettertui/core)
9
+
3
10
  **Framework-agnostic command protocol, tree manipulation, reconciler wrapper, and runtime.** Framework package for vanilla / native TypeScript. No React dependency.
4
11
 
5
12
  ## Overview
@@ -52,6 +59,10 @@ Re-exports all types from `@bettertui/shared` (internal — don't install separa
52
59
 
53
60
  ## Related Documentation
54
61
 
62
+ - [Website](https://bettertui.dev)
63
+ - [npm package](https://www.npmjs.com/package/@bettertui/core)
64
+ - [Rust engine crate](https://crates.io/crates/bettertui_engine) ([docs.rs](https://docs.rs/bettertui_engine))
65
+ - [GitHub repository](https://github.com/localfirstai/bettertui)
55
66
  - [Architecture overview](../../docs/architecture/overview.md)
56
67
  - [API reference](../../docs/api/packages/core.md)
57
68
  - [Guides](../../docs/guides/getting-started.md)
Binary file
package/index.d.mts CHANGED
@@ -2863,6 +2863,42 @@ declare class Timeline {
2863
2863
  /** Create a new Timeline instance. */
2864
2864
  declare function createTimeline$1(duration?: number, options?: TimelineOptions): Timeline;
2865
2865
  //#endregion
2866
+ //#region src/lib/wordBoundary.d.ts
2867
+ /**
2868
+ * Find the left (backward) word boundary from a given position.
2869
+ *
2870
+ * Ports the Rust `TextBuffer::word_boundary_left` algorithm exactly:
2871
+ * 1. If pos is 0, return 0 immediately.
2872
+ * 2. Starting at pos, skip whitespace characters backward.
2873
+ * 3. Then skip non-whitespace characters backward.
2874
+ * 4. Return the resulting index.
2875
+ *
2876
+ * This means the cursor lands at the start of the previous word,
2877
+ * or at the start of the current word if pos was inside a word
2878
+ * preceded by whitespace.
2879
+ *
2880
+ * @param text - The full text string to navigate.
2881
+ * @param pos - The current cursor position (0-based character index).
2882
+ * @returns The character index of the left word boundary.
2883
+ */
2884
+ declare function wordBoundaryLeft(text: string, pos: number): number;
2885
+ /**
2886
+ * Find the right (forward) word boundary from a given position.
2887
+ *
2888
+ * Ports the Rust `TextBuffer::word_boundary_right` algorithm exactly:
2889
+ * 1. Starting at pos, skip whitespace characters forward.
2890
+ * 2. Then skip non-whitespace characters forward.
2891
+ * 3. Return the resulting index.
2892
+ *
2893
+ * This means the cursor lands just past the end of the next word,
2894
+ * or just past the end of the current word if pos was inside one.
2895
+ *
2896
+ * @param text - The full text string to navigate.
2897
+ * @param pos - The current cursor position (0-based character index).
2898
+ * @returns The character index of the right word boundary.
2899
+ */
2900
+ declare function wordBoundaryRight(text: string, pos: number): number;
2901
+ //#endregion
2866
2902
  //#region src/renderables/Input.d.ts
2867
2903
  interface InputOptions extends BoxOptions {
2868
2904
  value?: string;
@@ -4537,5 +4573,5 @@ type OptimizedBuffer = {
4537
4573
  fillRect(x: number, y: number, w: number, h: number, color: unknown): void;
4538
4574
  };
4539
4575
  //#endregion
4540
- export { ASCIIFont, type ASCIIFontKind, type ASCIIFontOptions, type ActiveKeyInfo, type AlignItems, type AlignSelf, Audio, type AudioGroup, type AudioPlayOptions, type AudioPlaybackDevice, type AudioSetupOptions, type AudioSound, type AudioStartOptions, type AudioStats, AudioStream, type AudioStreamAction, AudioStreamError, type AudioStreamErrorContext, type AudioStreamMetadata, type AudioStreamMetadataFormat, type AudioStreamReconnectEvent, type AudioStreamState, type AudioStreamStats, type AudioStreamUrlOptions, type AudioTapResult, type AudioVoice, type BindingInfo, type BorderSide, type BorderStyle, type BorderStyleKind, Box, type BoxOptions, type CallerInfo, Canvas, type CanvasBodyOptions, type CanvasFooterOptions, type CanvasHeaderOptions, type CanvasOptions, CapabilityInspector, type CapabilityInspectorOptions, CliRenderEvents, CliRenderer, type CliRendererOptions, type Clock, Code, type CodeOptions, type ColorInput, type ColorValue, type Command, CommandBuffer, type CommandBufferConsumer, type CommandContext, type CommandEntry, type CommandHandler, CommandInspector, type CommandInspectorOptions, type CommandResult, CommandRuntime, type CommandRuntimeOptions, type CommandType, type ConsoleLogEntry, ConsoleLogLevel, CreateDevToolsOptions, DebugConsole, DebugPanel, DevTools, type LogLevel as DevToolsLogLevel, Logger as DevToolsLogger, type DevToolsNode, DevToolsOptions, type TerminalCapabilities as DevToolsTerminalCapabilities, DevToolsTimeline, type DevToolsTimelineOptions, type DiagnosticExport, DiagnosticSnapshot, Diff, type DiffOptions, EasingName, type EnvVarConfig, type EventCategory, EventInspector, type EventInspectorOptions, type ExportData, type ExportOptions, type ExternalOutputMode, type ExtmarksController, ExtmarksControllerStub, type FlexDirection, FocusInspector, type FocusInspectorOptions, type FocusSnapshot, FrameBuffer, type FrameBufferLike, type FrameBufferOptions, type FrameMetrics, type Gap, GenericVNode as Generic, type GraphicsFormat, HASTElement, type HighlightSegment, type HighlightedLine, type HostConfig, type HostContext, type ImperativeContext, Input, InputEvents, type InputOptions, type InputRenderableOptions, type Inset, type Instance, type InterceptContext, type InterceptHandler, InternalKeyHandler, type JustifyContent, type KeyAliasMap, type KeyBinding, type KeyBindingLike, type KeyBindingLookup, KeyCodes, KeyEvent, KeyEvent as KeyboardEvent, type KeyEventSource, type KeyEventType, KeyHandler, type KeyHandlerEventMap, KeyInput, type KeyListener, type KeyModifiers, Keymap, type KeymapEvent, type KeymapOptions, type LayoutConstraints, LayoutEvents, LineNumber, type LineNumberOptions, type LogEntry, LogLevel$1 as LogLevel, Logger$1 as Logger, LoggerConfig, type LoggerOptions, type Margin, Markdown, type MarkdownOptions, MemoryStats, type MockInput, type MockKeysOptions, type MockMouse, type MouseButton, MouseButtons, type MouseEvent, type MouseEventOptions, type MouseEventType, type MouseModifiers, MouseParser, type MousePosition, type NapiDiagnosticSnapshot, type NapiEngine, type NapiEventBus, type NapiFocusManager, NapiHitGrid, type NapiKeymap, type NapiLoggerConfig, NapiPluginHost, type NapiScheduler, NapiSpanFeed, type NapiSpanFeedStats, type NapiTextEngine, type NapiTheme, type NapiThemeBorders, type NapiThemeColors, type NapiThemeSpacing, NapiTimeline, type NapiWidgetHost, type NativeSpanFeedOptions, OptimizedBuffer, type Overflow, type OverlayCorner, OverlayHost, type OverlayHostOptions, type Padding, type Panel, type PanelContext, type ParseKeypressOptions, type ParsedKey, PasteEvent, type PasteMetadata, type PerformanceSnapshot, PerformanceTracker, type PerformanceTrackerOptions, PixelBuffer, type PluginStateName, type Point, type Position, RESET, type RGB, RGBA, type RawKeyEvent, type RawMouseEvent, type RecordedCommand, type RecordedEvent, type Rect, RenderContext, type RenderResult, Renderable, RenderableEvents, Root, RootTextNode, SchedulerInspector, type SchedulerInspectorOptions, type SchedulerSnapshot, Screen, ScreenEvents, type ScreenMode, type ScreenResizeEvent, ScrollBar, type ScrollBarOptions, ScrollBox, type ScrollBoxOptions, type ScrollInfo, Select, SelectEvents, type SelectOption, type SelectOptions, type SelectRenderableOptions, Selection, type Size, type Sizing, Slider, SliderEvents, type SliderOptions, type SliderRenderableOptions, type SlotMode, type SnapshotDiff, SnapshotManager, type SnapshotOptions, Spring, SpringOptions, type Spy, type StdinEvent, StdinParser, type StdinParserOptions, type StdinParserProtocolContext, type StdinResponseProtocol, type StylableInput, type Style, StyledText, SyntaxStyle, SystemClock, type TabOption, TabSelect, TabSelectEvents, type TabSelectOptions, type TabSelectRenderableOptions, type TableColumn, type TerminalCapabilities$1 as TerminalCapabilities, type TerminalCapabilitiesOptions, TerminalConsole, TerminalConsoleCache, type TestBinding, type TestKeyInput, TestReadStream, type TestRenderer, type TestRendererOptions, type TestRendererSetup, type TestStdin, type TestStdout, TestWriteStream, Text, TextAttributes, type TextChunk, type TextInstance, TextNode, type TextNodeOptions, type TextOptions, TextTable, type TextTableColumnFitter, type TextTableColumnWidthMode, type TextTableContent, type TextTableOptions, Textarea, type TextareaOptions, type Theme, type ThemeColors, type ThemeMode, type ThemeSpacing, TimeToFirstDraw, type TimeToFirstDrawOptions, Timeline, type TimelineEntry, type TimelineOptions, type TimerHandle, TreeInspector, type TreeInspectorOptions, type TreeSnapshot, Tween, type TweenConfig, TweenOptions, type VNode, ASCIIFont$1 as VNodeASCIIFont, BoxVNode as VNodeBox, CodeVNode as VNodeCode, InputVNode as VNodeInput, ScrollBox$1 as VNodeScrollBox, SelectVNode as VNodeSelect, TabSelectVNode as VNodeTabSelect, TextVNode as VNodeText, type ValidationError, type ValidationResult, type WidgetContext, type WidgetLifecycle, ansiUtils_d_exports as ansi, appendChild, bg, bgBlack, bgBlue, bgCyan, bgGreen, bgMagenta, bgRed, bgWhite, bgYellow, black, blink, blue, bold, brightBlack, brightBlue, brightCyan, brightGreen, brightMagenta, brightRed, brightWhite, brightYellow, buildKeyBindingsMap, cacheHitRatio, capture, clamp, clearEnvCache, clipboardDecode, clipboardQuerySequence, clipboardSetSequence, commitTextUpdate, commitUpdate, createCliRenderer, createDarkTheme, createDevTools, createEngine, createEventBus, createExport, createFocusManager, createFullTerminalCapabilities, createHitGrid, createITerm2TerminalCapabilities, createInstance, createKeymap, createKittyTerminalCapabilities, createLightTheme, createMinimalTerminalCapabilities, createMockKeys, createMockMouse, createMockNativeKeymap, createTimeline as createNativeTimeline, createPluginHost, createReconciler, createScheduler, createSpanFeed, createSpy, createSummary, createTerminalCapabilities, createTestKeymap, createTestRenderer, createTestRendererSync, createTestStdin, createTestStdout, createTextEngine, createTextInstance, createTimeline$1 as createTimeline, createWidgetHost, cyan, decodePasteBytes, defaultKeyAliases, delegate, destroySingleton, detectCapabilities, dim, easing, env, exportToJson, fg, finalizeInitialChildren, generateEnvColored, generateEnvMarkdown, generateId, getAllEnvVarConfigs, getEnvVarConfig, getKeyBindingAction, getKeyBindingKey, getKeyBindingKeys, getNativePackageName, getSingleton, getVersion, gradientH, graphicsItermWrite, graphicsKittyDelete, graphicsKittyDeleteAll, graphicsKittyWrite, graphicsQuery, graphicsSixelWrite, green, h, hasSingleton, hastToStyledText, highlightCode, insertBefore, instantiate, inverseLerp, isStyledText, isValidColor, italic, keyBindingToString, kittyNamedSingleStrokeKeys, layoutToEngineJson, lerp, link, loggerFlush, loggerGetDiagnostics, loggerGetLevel, loggerInit, loggerSetLevel, loggerSetModuleFilter, magenta, matchesKeyBinding, maybeMakeRenderable, measureText, mergeKeyAliases, mergeKeyBindings, nonAlphanumericKeys, parseColor, parseHex, parseKeypress, parseKittyKeyboard, prepareUpdate, red, registerEnvVar, removeChild, resetAfterCommit, resolveRenderLib, reverse, rgbBg, rgbFg, rgbaToEngineColor, singleton, smoothstep, strikethrough, stringToStyledText, stripAnsiSequences, styledTextToAnsi, t, terminalConsoleCache, terminalNamedSingleStrokeKeys, underline, validate, validateLayoutConstraints, validateStyle, visibleWidth, vstyles, warnIfInvalid, white, yellow };
4576
+ export { ASCIIFont, type ASCIIFontKind, type ASCIIFontOptions, type ActiveKeyInfo, type AlignItems, type AlignSelf, Audio, type AudioGroup, type AudioPlayOptions, type AudioPlaybackDevice, type AudioSetupOptions, type AudioSound, type AudioStartOptions, type AudioStats, AudioStream, type AudioStreamAction, AudioStreamError, type AudioStreamErrorContext, type AudioStreamMetadata, type AudioStreamMetadataFormat, type AudioStreamReconnectEvent, type AudioStreamState, type AudioStreamStats, type AudioStreamUrlOptions, type AudioTapResult, type AudioVoice, type BindingInfo, type BorderSide, type BorderStyle, type BorderStyleKind, Box, type BoxOptions, type CallerInfo, Canvas, type CanvasBodyOptions, type CanvasFooterOptions, type CanvasHeaderOptions, type CanvasOptions, CapabilityInspector, type CapabilityInspectorOptions, CliRenderEvents, CliRenderer, type CliRendererOptions, type Clock, Code, type CodeOptions, type ColorInput, type ColorValue, type Command, CommandBuffer, type CommandBufferConsumer, type CommandContext, type CommandEntry, type CommandHandler, CommandInspector, type CommandInspectorOptions, type CommandResult, CommandRuntime, type CommandRuntimeOptions, type CommandType, type ConsoleLogEntry, ConsoleLogLevel, CreateDevToolsOptions, DebugConsole, DebugPanel, DevTools, type LogLevel as DevToolsLogLevel, Logger as DevToolsLogger, type DevToolsNode, DevToolsOptions, type TerminalCapabilities as DevToolsTerminalCapabilities, DevToolsTimeline, type DevToolsTimelineOptions, type DiagnosticExport, DiagnosticSnapshot, Diff, type DiffOptions, EasingName, type EnvVarConfig, type EventCategory, EventInspector, type EventInspectorOptions, type ExportData, type ExportOptions, type ExternalOutputMode, type ExtmarksController, ExtmarksControllerStub, type FlexDirection, FocusInspector, type FocusInspectorOptions, type FocusSnapshot, FrameBuffer, type FrameBufferLike, type FrameBufferOptions, type FrameMetrics, type Gap, GenericVNode as Generic, type GraphicsFormat, HASTElement, type HighlightSegment, type HighlightedLine, type HostConfig, type HostContext, type ImperativeContext, Input, InputEvents, type InputOptions, type InputRenderableOptions, type Inset, type Instance, type InterceptContext, type InterceptHandler, InternalKeyHandler, type JustifyContent, type KeyAliasMap, type KeyBinding, type KeyBindingLike, type KeyBindingLookup, KeyCodes, KeyEvent, KeyEvent as KeyboardEvent, type KeyEventSource, type KeyEventType, KeyHandler, type KeyHandlerEventMap, KeyInput, type KeyListener, type KeyModifiers, Keymap, type KeymapEvent, type KeymapOptions, type LayoutConstraints, LayoutEvents, LineNumber, type LineNumberOptions, type LogEntry, LogLevel$1 as LogLevel, Logger$1 as Logger, LoggerConfig, type LoggerOptions, type Margin, Markdown, type MarkdownOptions, MemoryStats, type MockInput, type MockKeysOptions, type MockMouse, type MouseButton, MouseButtons, type MouseEvent, type MouseEventOptions, type MouseEventType, type MouseModifiers, MouseParser, type MousePosition, type NapiDiagnosticSnapshot, type NapiEngine, type NapiEventBus, type NapiFocusManager, NapiHitGrid, type NapiKeymap, type NapiLoggerConfig, NapiPluginHost, type NapiScheduler, NapiSpanFeed, type NapiSpanFeedStats, type NapiTextEngine, type NapiTheme, type NapiThemeBorders, type NapiThemeColors, type NapiThemeSpacing, NapiTimeline, type NapiWidgetHost, type NativeSpanFeedOptions, OptimizedBuffer, type Overflow, type OverlayCorner, OverlayHost, type OverlayHostOptions, type Padding, type Panel, type PanelContext, type ParseKeypressOptions, type ParsedKey, PasteEvent, type PasteMetadata, type PerformanceSnapshot, PerformanceTracker, type PerformanceTrackerOptions, PixelBuffer, type PluginStateName, type Point, type Position, RESET, type RGB, RGBA, type RawKeyEvent, type RawMouseEvent, type RecordedCommand, type RecordedEvent, type Rect, RenderContext, type RenderResult, Renderable, RenderableEvents, Root, RootTextNode, SchedulerInspector, type SchedulerInspectorOptions, type SchedulerSnapshot, Screen, ScreenEvents, type ScreenMode, type ScreenResizeEvent, ScrollBar, type ScrollBarOptions, ScrollBox, type ScrollBoxOptions, type ScrollInfo, Select, SelectEvents, type SelectOption, type SelectOptions, type SelectRenderableOptions, Selection, type Size, type Sizing, Slider, SliderEvents, type SliderOptions, type SliderRenderableOptions, type SlotMode, type SnapshotDiff, SnapshotManager, type SnapshotOptions, Spring, SpringOptions, type Spy, type StdinEvent, StdinParser, type StdinParserOptions, type StdinParserProtocolContext, type StdinResponseProtocol, type StylableInput, type Style, StyledText, SyntaxStyle, SystemClock, type TabOption, TabSelect, TabSelectEvents, type TabSelectOptions, type TabSelectRenderableOptions, type TableColumn, type TerminalCapabilities$1 as TerminalCapabilities, type TerminalCapabilitiesOptions, TerminalConsole, TerminalConsoleCache, type TestBinding, type TestKeyInput, TestReadStream, type TestRenderer, type TestRendererOptions, type TestRendererSetup, type TestStdin, type TestStdout, TestWriteStream, Text, TextAttributes, type TextChunk, type TextInstance, TextNode, type TextNodeOptions, type TextOptions, TextTable, type TextTableColumnFitter, type TextTableColumnWidthMode, type TextTableContent, type TextTableOptions, Textarea, type TextareaOptions, type Theme, type ThemeColors, type ThemeMode, type ThemeSpacing, TimeToFirstDraw, type TimeToFirstDrawOptions, Timeline, type TimelineEntry, type TimelineOptions, type TimerHandle, TreeInspector, type TreeInspectorOptions, type TreeSnapshot, Tween, type TweenConfig, TweenOptions, type VNode, ASCIIFont$1 as VNodeASCIIFont, BoxVNode as VNodeBox, CodeVNode as VNodeCode, InputVNode as VNodeInput, ScrollBox$1 as VNodeScrollBox, SelectVNode as VNodeSelect, TabSelectVNode as VNodeTabSelect, TextVNode as VNodeText, type ValidationError, type ValidationResult, type WidgetContext, type WidgetLifecycle, ansiUtils_d_exports as ansi, appendChild, bg, bgBlack, bgBlue, bgCyan, bgGreen, bgMagenta, bgRed, bgWhite, bgYellow, black, blink, blue, bold, brightBlack, brightBlue, brightCyan, brightGreen, brightMagenta, brightRed, brightWhite, brightYellow, buildKeyBindingsMap, cacheHitRatio, capture, clamp, clearEnvCache, clipboardDecode, clipboardQuerySequence, clipboardSetSequence, commitTextUpdate, commitUpdate, createCliRenderer, createDarkTheme, createDevTools, createEngine, createEventBus, createExport, createFocusManager, createFullTerminalCapabilities, createHitGrid, createITerm2TerminalCapabilities, createInstance, createKeymap, createKittyTerminalCapabilities, createLightTheme, createMinimalTerminalCapabilities, createMockKeys, createMockMouse, createMockNativeKeymap, createTimeline as createNativeTimeline, createPluginHost, createReconciler, createScheduler, createSpanFeed, createSpy, createSummary, createTerminalCapabilities, createTestKeymap, createTestRenderer, createTestRendererSync, createTestStdin, createTestStdout, createTextEngine, createTextInstance, createTimeline$1 as createTimeline, createWidgetHost, cyan, decodePasteBytes, defaultKeyAliases, delegate, destroySingleton, detectCapabilities, dim, easing, env, exportToJson, fg, finalizeInitialChildren, generateEnvColored, generateEnvMarkdown, generateId, getAllEnvVarConfigs, getEnvVarConfig, getKeyBindingAction, getKeyBindingKey, getKeyBindingKeys, getNativePackageName, getSingleton, getVersion, gradientH, graphicsItermWrite, graphicsKittyDelete, graphicsKittyDeleteAll, graphicsKittyWrite, graphicsQuery, graphicsSixelWrite, green, h, hasSingleton, hastToStyledText, highlightCode, insertBefore, instantiate, inverseLerp, isStyledText, isValidColor, italic, keyBindingToString, kittyNamedSingleStrokeKeys, layoutToEngineJson, lerp, link, loggerFlush, loggerGetDiagnostics, loggerGetLevel, loggerInit, loggerSetLevel, loggerSetModuleFilter, magenta, matchesKeyBinding, maybeMakeRenderable, measureText, mergeKeyAliases, mergeKeyBindings, nonAlphanumericKeys, parseColor, parseHex, parseKeypress, parseKittyKeyboard, prepareUpdate, red, registerEnvVar, removeChild, resetAfterCommit, resolveRenderLib, reverse, rgbBg, rgbFg, rgbaToEngineColor, singleton, smoothstep, strikethrough, stringToStyledText, stripAnsiSequences, styledTextToAnsi, t, terminalConsoleCache, terminalNamedSingleStrokeKeys, underline, validate, validateLayoutConstraints, validateStyle, visibleWidth, vstyles, warnIfInvalid, white, wordBoundaryLeft, wordBoundaryRight, yellow };
4541
4577
  //# sourceMappingURL=index.d.mts.map
package/index.mjs CHANGED
@@ -4903,6 +4903,55 @@ function createTimeline$1(duration, options) {
4903
4903
  return new Timeline(duration ?? 1, options ?? {});
4904
4904
  }
4905
4905
  //#endregion
4906
+ //#region src/lib/wordBoundary.ts
4907
+ /**
4908
+ * Find the left (backward) word boundary from a given position.
4909
+ *
4910
+ * Ports the Rust `TextBuffer::word_boundary_left` algorithm exactly:
4911
+ * 1. If pos is 0, return 0 immediately.
4912
+ * 2. Starting at pos, skip whitespace characters backward.
4913
+ * 3. Then skip non-whitespace characters backward.
4914
+ * 4. Return the resulting index.
4915
+ *
4916
+ * This means the cursor lands at the start of the previous word,
4917
+ * or at the start of the current word if pos was inside a word
4918
+ * preceded by whitespace.
4919
+ *
4920
+ * @param text - The full text string to navigate.
4921
+ * @param pos - The current cursor position (0-based character index).
4922
+ * @returns The character index of the left word boundary.
4923
+ */
4924
+ function wordBoundaryLeft(text, pos) {
4925
+ if (pos === 0) return 0;
4926
+ const chars = [...text];
4927
+ let i = pos;
4928
+ while (i > 0 && /\s/.test(chars[i - 1])) i -= 1;
4929
+ while (i > 0 && !/\s/.test(chars[i - 1])) i -= 1;
4930
+ return i;
4931
+ }
4932
+ /**
4933
+ * Find the right (forward) word boundary from a given position.
4934
+ *
4935
+ * Ports the Rust `TextBuffer::word_boundary_right` algorithm exactly:
4936
+ * 1. Starting at pos, skip whitespace characters forward.
4937
+ * 2. Then skip non-whitespace characters forward.
4938
+ * 3. Return the resulting index.
4939
+ *
4940
+ * This means the cursor lands just past the end of the next word,
4941
+ * or just past the end of the current word if pos was inside one.
4942
+ *
4943
+ * @param text - The full text string to navigate.
4944
+ * @param pos - The current cursor position (0-based character index).
4945
+ * @returns The character index of the right word boundary.
4946
+ */
4947
+ function wordBoundaryRight(text, pos) {
4948
+ const chars = [...text];
4949
+ let i = pos;
4950
+ while (i < chars.length && /\s/.test(chars[i])) i += 1;
4951
+ while (i < chars.length && !/\s/.test(chars[i])) i += 1;
4952
+ return i;
4953
+ }
4954
+ //#endregion
4906
4955
  //#region src/renderables/Box.ts
4907
4956
  /**
4908
4957
  * Box — the primary container widget.
@@ -5498,6 +5547,16 @@ var Input = class extends Box {
5498
5547
  this._submit();
5499
5548
  return;
5500
5549
  }
5550
+ if (key.name === "left" && key.alt || key.name === "b" && key.alt) {
5551
+ this._cursorPos = wordBoundaryLeft(this._value, this._cursorPos);
5552
+ this._render();
5553
+ return;
5554
+ }
5555
+ if (key.name === "right" && key.alt || key.name === "f" && key.alt) {
5556
+ this._cursorPos = wordBoundaryRight(this._value, this._cursorPos);
5557
+ this._render();
5558
+ return;
5559
+ }
5501
5560
  if (key.name === "left") {
5502
5561
  this._cursorPos = Math.max(0, this._cursorPos - 1);
5503
5562
  this._render();
@@ -5518,6 +5577,25 @@ var Input = class extends Box {
5518
5577
  this._render();
5519
5578
  return;
5520
5579
  }
5580
+ if (key.name === "w" && key.ctrl || key.name === "backspace" && key.alt) {
5581
+ const start = wordBoundaryLeft(this._value, this._cursorPos);
5582
+ if (start < this._cursorPos) {
5583
+ this._value = this._value.slice(0, start) + this._value.slice(this._cursorPos);
5584
+ this._cursorPos = start;
5585
+ this._render();
5586
+ this.emit("input", this._value);
5587
+ }
5588
+ return;
5589
+ }
5590
+ if (key.name === "d" && key.alt || key.name === "delete" && key.alt) {
5591
+ const end = wordBoundaryRight(this._value, this._cursorPos);
5592
+ if (end > this._cursorPos) {
5593
+ this._value = this._value.slice(0, this._cursorPos) + this._value.slice(end);
5594
+ this._render();
5595
+ this.emit("input", this._value);
5596
+ }
5597
+ return;
5598
+ }
5521
5599
  if (key.name === "backspace" || key.name === "delete" && !key.ctrl) {
5522
5600
  if (key.name === "backspace" && this._cursorPos > 0) {
5523
5601
  this._value = this._value.slice(0, this._cursorPos - 1) + this._value.slice(this._cursorPos);
@@ -15732,6 +15810,6 @@ function hastToStyledText(node, _style) {
15732
15810
  return traverse(node);
15733
15811
  }
15734
15812
  //#endregion
15735
- export { ASCIIFont, Audio, AudioStream, AudioStreamError, Box, Canvas, CapabilityInspector, CliRenderEvents, CliRenderer, Code, CommandBuffer, CommandInspector, CommandRuntime, ConsoleLogLevel, DebugPanel, Logger as DevToolsLogger, DevToolsTimeline, Diff, EventInspector, ExtmarksControllerStub, FocusInspector, FrameBuffer, GenericVNode as Generic, Input, InputEvents, InternalKeyHandler, KeyCodes, KeyEvent, KeyEvent as KeyboardEvent, KeyHandler, KeyInput, Keymap, LayoutEvents, LineNumber, Markdown, MouseButtons, MouseParser, NapiHitGrid, NapiPluginHost, NapiSpanFeed, NapiTimeline, OverlayHost, PasteEvent, PerformanceTracker, PixelBuffer, RESET, RGBA, Renderable, RenderableEvents, Root, RootTextNode, SchedulerInspector, Screen, ScreenEvents, ScrollBar, ScrollBox, Select, SelectEvents, Slider, SliderEvents, SnapshotManager, Spring, StdinParser, StyledText, SyntaxStyle, SystemClock, TabSelect, TabSelectEvents, TerminalConsole, TerminalConsoleCache, TestReadStream, TestWriteStream, Text, TextAttributes, TextNode, TextTable, Textarea, TimeToFirstDraw, Timeline, TreeInspector, Tween, ASCIIFont$1 as VNodeASCIIFont, BoxVNode as VNodeBox, CodeVNode as VNodeCode, InputVNode as VNodeInput, ScrollBox$1 as VNodeScrollBox, SelectVNode as VNodeSelect, TabSelectVNode as VNodeTabSelect, TextVNode as VNodeText, ansiUtils_exports as ansi, appendChild, bg, bgBlack, bgBlue, bgCyan, bgGreen, bgMagenta, bgRed, bgWhite, bgYellow, black, blink, blue, bold, brightBlack, brightBlue, brightCyan, brightGreen, brightMagenta, brightRed, brightWhite, brightYellow, buildKeyBindingsMap, cacheHitRatio, capture, clamp, clearEnvCache, clipboardDecode, clipboardQuerySequence, clipboardSetSequence, commitTextUpdate, commitUpdate, createCliRenderer, createDarkTheme, createDevTools, createEngine, createEventBus, createExport, createFocusManager, createFullTerminalCapabilities, createHitGrid, createITerm2TerminalCapabilities, createInstance, createKeymap, createKittyTerminalCapabilities, createLightTheme, createMinimalTerminalCapabilities, createMockKeys, createMockMouse, createMockNativeKeymap, createTimeline as createNativeTimeline, createPluginHost, createReconciler, createScheduler, createSpanFeed, createSpy, createSummary, createTerminalCapabilities, createTestKeymap, createTestRenderer, createTestRendererSync, createTestStdin, createTestStdout, createTextEngine, createTextInstance, createTimeline$1 as createTimeline, createWidgetHost, cyan, decodePasteBytes, defaultKeyAliases, delegate, destroySingleton, detectCapabilities, dim, easing, env, exportToJson, fg, finalizeInitialChildren, generateEnvColored, generateEnvMarkdown, generateId, getAllEnvVarConfigs, getEnvVarConfig, getKeyBindingAction, getKeyBindingKey, getKeyBindingKeys, getNativePackageName, getSingleton, getVersion, gradientH, graphicsItermWrite, graphicsKittyDelete, graphicsKittyDeleteAll, graphicsKittyWrite, graphicsQuery, graphicsSixelWrite, green, h, hasSingleton, hastToStyledText, highlightCode, insertBefore, instantiate, inverseLerp, isStyledText, isValidColor, italic, keyBindingToString, kittyNamedSingleStrokeKeys, layoutToEngineJson, lerp, link, loggerFlush, loggerGetDiagnostics, loggerGetLevel, loggerInit, loggerSetLevel, loggerSetModuleFilter, magenta, matchesKeyBinding, maybeMakeRenderable, measureText, mergeKeyAliases, mergeKeyBindings, nonAlphanumericKeys, parseColor, parseHex, parseKeypress, parseKittyKeyboard, prepareUpdate, red, registerEnvVar, removeChild, resetAfterCommit, resolveRenderLib, reverse, rgbBg, rgbFg, rgbaToEngineColor, singleton, smoothstep, strikethrough, stringToStyledText, stripAnsiSequences, styledTextToAnsi, t, terminalConsoleCache, terminalNamedSingleStrokeKeys, underline, validate, validateLayoutConstraints, validateStyle, visibleWidth, vstyles, warnIfInvalid, white, yellow };
15813
+ export { ASCIIFont, Audio, AudioStream, AudioStreamError, Box, Canvas, CapabilityInspector, CliRenderEvents, CliRenderer, Code, CommandBuffer, CommandInspector, CommandRuntime, ConsoleLogLevel, DebugPanel, Logger as DevToolsLogger, DevToolsTimeline, Diff, EventInspector, ExtmarksControllerStub, FocusInspector, FrameBuffer, GenericVNode as Generic, Input, InputEvents, InternalKeyHandler, KeyCodes, KeyEvent, KeyEvent as KeyboardEvent, KeyHandler, KeyInput, Keymap, LayoutEvents, LineNumber, Markdown, MouseButtons, MouseParser, NapiHitGrid, NapiPluginHost, NapiSpanFeed, NapiTimeline, OverlayHost, PasteEvent, PerformanceTracker, PixelBuffer, RESET, RGBA, Renderable, RenderableEvents, Root, RootTextNode, SchedulerInspector, Screen, ScreenEvents, ScrollBar, ScrollBox, Select, SelectEvents, Slider, SliderEvents, SnapshotManager, Spring, StdinParser, StyledText, SyntaxStyle, SystemClock, TabSelect, TabSelectEvents, TerminalConsole, TerminalConsoleCache, TestReadStream, TestWriteStream, Text, TextAttributes, TextNode, TextTable, Textarea, TimeToFirstDraw, Timeline, TreeInspector, Tween, ASCIIFont$1 as VNodeASCIIFont, BoxVNode as VNodeBox, CodeVNode as VNodeCode, InputVNode as VNodeInput, ScrollBox$1 as VNodeScrollBox, SelectVNode as VNodeSelect, TabSelectVNode as VNodeTabSelect, TextVNode as VNodeText, ansiUtils_exports as ansi, appendChild, bg, bgBlack, bgBlue, bgCyan, bgGreen, bgMagenta, bgRed, bgWhite, bgYellow, black, blink, blue, bold, brightBlack, brightBlue, brightCyan, brightGreen, brightMagenta, brightRed, brightWhite, brightYellow, buildKeyBindingsMap, cacheHitRatio, capture, clamp, clearEnvCache, clipboardDecode, clipboardQuerySequence, clipboardSetSequence, commitTextUpdate, commitUpdate, createCliRenderer, createDarkTheme, createDevTools, createEngine, createEventBus, createExport, createFocusManager, createFullTerminalCapabilities, createHitGrid, createITerm2TerminalCapabilities, createInstance, createKeymap, createKittyTerminalCapabilities, createLightTheme, createMinimalTerminalCapabilities, createMockKeys, createMockMouse, createMockNativeKeymap, createTimeline as createNativeTimeline, createPluginHost, createReconciler, createScheduler, createSpanFeed, createSpy, createSummary, createTerminalCapabilities, createTestKeymap, createTestRenderer, createTestRendererSync, createTestStdin, createTestStdout, createTextEngine, createTextInstance, createTimeline$1 as createTimeline, createWidgetHost, cyan, decodePasteBytes, defaultKeyAliases, delegate, destroySingleton, detectCapabilities, dim, easing, env, exportToJson, fg, finalizeInitialChildren, generateEnvColored, generateEnvMarkdown, generateId, getAllEnvVarConfigs, getEnvVarConfig, getKeyBindingAction, getKeyBindingKey, getKeyBindingKeys, getNativePackageName, getSingleton, getVersion, gradientH, graphicsItermWrite, graphicsKittyDelete, graphicsKittyDeleteAll, graphicsKittyWrite, graphicsQuery, graphicsSixelWrite, green, h, hasSingleton, hastToStyledText, highlightCode, insertBefore, instantiate, inverseLerp, isStyledText, isValidColor, italic, keyBindingToString, kittyNamedSingleStrokeKeys, layoutToEngineJson, lerp, link, loggerFlush, loggerGetDiagnostics, loggerGetLevel, loggerInit, loggerSetLevel, loggerSetModuleFilter, magenta, matchesKeyBinding, maybeMakeRenderable, measureText, mergeKeyAliases, mergeKeyBindings, nonAlphanumericKeys, parseColor, parseHex, parseKeypress, parseKittyKeyboard, prepareUpdate, red, registerEnvVar, removeChild, resetAfterCommit, resolveRenderLib, reverse, rgbBg, rgbFg, rgbaToEngineColor, singleton, smoothstep, strikethrough, stringToStyledText, stripAnsiSequences, styledTextToAnsi, t, terminalConsoleCache, terminalNamedSingleStrokeKeys, underline, validate, validateLayoutConstraints, validateStyle, visibleWidth, vstyles, warnIfInvalid, white, wordBoundaryLeft, wordBoundaryRight, yellow };
15736
15814
 
15737
15815
  //# sourceMappingURL=index.mjs.map