@opentui/core 0.5.6 → 0.5.8

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.
@@ -1,5 +1,5 @@
1
1
  import { Renderable } from "../Renderable.js";
2
- import type { ViewportBounds } from "../types.js";
2
+ import type { SelectionBehavior, ViewportBounds } from "../types.js";
3
3
  import { fonts } from "./ascii.font.js";
4
4
  export declare class Selection {
5
5
  private _anchor;
@@ -9,13 +9,14 @@ export declare class Selection {
9
9
  private _isActive;
10
10
  private _isDragging;
11
11
  private _isStart;
12
+ behavior: SelectionBehavior;
12
13
  constructor(anchorRenderable: Renderable, anchor: {
13
14
  x: number;
14
15
  y: number;
15
16
  }, focus: {
16
17
  x: number;
17
18
  y: number;
18
- });
19
+ }, behavior?: SelectionBehavior);
19
20
  get isStart(): boolean;
20
21
  set isStart(value: boolean);
21
22
  get anchor(): {
@@ -47,6 +48,7 @@ export interface LocalSelectionBounds {
47
48
  focusX: number;
48
49
  focusY: number;
49
50
  isActive: boolean;
51
+ behavior: SelectionBehavior;
50
52
  }
51
53
  export declare function convertGlobalToLocalSelection(globalSelection: Selection | null, localX: number, localY: number): LocalSelectionBounds | null;
52
54
  export declare class ASCIIFontSelectionHelper {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "index.node.js",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
7
- "version": "0.5.6",
7
+ "version": "0.5.8",
8
8
  "description": "OpenTUI is a TypeScript library on a native Zig core for building terminal user interfaces (TUIs)",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -75,13 +75,13 @@
75
75
  "web-tree-sitter": "0.25.10"
76
76
  },
77
77
  "optionalDependencies": {
78
- "@opentui/core-darwin-x64": "0.5.6",
79
- "@opentui/core-darwin-arm64": "0.5.6",
80
- "@opentui/core-linux-x64": "0.5.6",
81
- "@opentui/core-linux-arm64": "0.5.6",
82
- "@opentui/core-win32-x64": "0.5.6",
83
- "@opentui/core-win32-arm64": "0.5.6",
84
- "@opentui/core-linux-x64-musl": "0.5.6",
85
- "@opentui/core-linux-arm64-musl": "0.5.6"
78
+ "@opentui/core-darwin-x64": "0.5.8",
79
+ "@opentui/core-darwin-arm64": "0.5.8",
80
+ "@opentui/core-linux-x64": "0.5.8",
81
+ "@opentui/core-linux-arm64": "0.5.8",
82
+ "@opentui/core-win32-x64": "0.5.8",
83
+ "@opentui/core-win32-arm64": "0.5.8",
84
+ "@opentui/core-linux-x64-musl": "0.5.8",
85
+ "@opentui/core-linux-arm64-musl": "0.5.8"
86
86
  }
87
87
  }
@@ -3,7 +3,7 @@ import { Selection, type LocalSelectionBounds } from "../lib/selection.js";
3
3
  import { EditBuffer, type LogicalCursor } from "../edit-buffer.js";
4
4
  import { EditorView, type VisualCursor } from "../editor-view.js";
5
5
  import { RGBA } from "../lib/RGBA.js";
6
- import type { RenderContext, Highlight, CursorStyleOptions, LineInfoProvider, LineInfo } from "../types.js";
6
+ import type { RenderContext, Highlight, CursorStyleOptions, LineInfoProvider, LineInfo, SelectionOccupancy } from "../types.js";
7
7
  import type { OptimizedBuffer } from "../buffer.js";
8
8
  import type { SyntaxStyle } from "../syntax-style.js";
9
9
  declare const BrandedEditBufferRenderable: unique symbol;
@@ -36,6 +36,7 @@ export interface EditBufferOptions extends RenderableOptions<EditBufferRenderabl
36
36
  showCursor?: boolean;
37
37
  cursorColor?: string | RGBA;
38
38
  cursorStyle?: CursorStyleOptions;
39
+ selectionOccupancy?: SelectionOccupancy;
39
40
  syntaxStyle?: SyntaxStyle;
40
41
  tabIndicator?: string | number;
41
42
  tabIndicatorColor?: string | RGBA;
@@ -120,6 +121,8 @@ export declare abstract class EditBufferRenderable extends Renderable implements
120
121
  set cursorColor(value: RGBA | string);
121
122
  get cursorStyle(): CursorStyleOptions;
122
123
  set cursorStyle(style: CursorStyleOptions);
124
+ get selectionOccupancy(): SelectionOccupancy;
125
+ set selectionOccupancy(value: SelectionOccupancy | null | undefined);
123
126
  get tabIndicator(): string | number | undefined;
124
127
  set tabIndicator(value: string | number | undefined);
125
128
  get tabIndicatorColor(): RGBA | undefined;
@@ -153,6 +156,7 @@ export declare abstract class EditBufferRenderable extends Renderable implements
153
156
  deleteCharBackward(): boolean;
154
157
  newLine(): boolean;
155
158
  deleteLine(): boolean;
159
+ private collapseSelectionToEdge;
156
160
  moveCursorLeft(options?: {
157
161
  select?: boolean;
158
162
  }): boolean;
package/renderer.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Renderable, RootRenderable } from "./Renderable.js";
2
- import { DebugOverlayCorner, type CursorStyleOptions, type MousePointerStyle, type RenderContext, type TerminalCapabilities, type ThemeMode, type WidthMethod } from "./types.js";
2
+ import { DebugOverlayCorner, type CursorStyleOptions, type MousePointerStyle, type RenderContext, type TerminalCapabilities, type ThemeMode, type SelectionBehavior, type WidthMethod } from "./types.js";
3
3
  import { RGBA, type ColorInput } from "./lib/RGBA.js";
4
4
  import { OptimizedBuffer } from "./buffer.js";
5
5
  import { type NativeBufferedOutput, type NativeRenderStats, type RendererHandle } from "./zig.js";
@@ -295,6 +295,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
295
295
  private lastOverRenderable?;
296
296
  private currentSelection;
297
297
  private selectionContainers;
298
+ private lastClick;
298
299
  private clipboard;
299
300
  private _splitHeight;
300
301
  private renderOffset;
@@ -585,11 +586,13 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
585
586
  get hasSelection(): boolean;
586
587
  getSelectionContainer(): Renderable | null;
587
588
  clearSelection(): void;
589
+ private clearSelectionState;
588
590
  /**
589
591
  * Start a new selection at the given coordinates.
590
592
  * Used by both mouse and keyboard selection.
591
593
  */
592
- startSelection(renderable: Renderable, x: number, y: number): void;
594
+ startSelection(renderable: Renderable, x: number, y: number, behavior?: SelectionBehavior): void;
595
+ private nextClickBehavior;
593
596
  updateSelection(currentRenderable: Renderable | undefined, x: number, y: number, options?: {
594
597
  finishDragging?: boolean;
595
598
  }): void;
package/testing.bun.js CHANGED
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  ANSI,
4
4
  CliRenderer
5
- } from "./chunk-bun-da1keqyp.js";
5
+ } from "./chunk-bun-b3exa82d.js";
6
6
  import {
7
7
  SystemClock,
8
8
  TreeSitterClient
9
- } from "./chunk-bun-9335djz2.js";
9
+ } from "./chunk-bun-2956gvaq.js";
10
10
 
11
11
  // src/testing/mock-keys.ts
12
12
  import { Buffer as Buffer2 } from "buffer";
package/testing.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  ANSI,
3
3
  CliRenderer
4
- } from "./chunk-node-ks0581vk.js";
4
+ } from "./chunk-node-kr27pp2p.js";
5
5
  import {
6
6
  SystemClock,
7
7
  TreeSitterClient
8
- } from "./chunk-node-2h23nsbj.js";
8
+ } from "./chunk-node-mfda59vq.js";
9
9
 
10
10
  // src/testing/mock-keys.ts
11
11
  import { Buffer as Buffer2 } from "node:buffer";
@@ -1,6 +1,7 @@
1
1
  import { RGBA } from "./lib/RGBA.js";
2
2
  import { type LineInfo, type MeasureResult, type RenderLib, type TextBufferViewHandle } from "./zig.js";
3
3
  import type { TextBuffer } from "./text-buffer.js";
4
+ import type { SelectionBehavior, SelectionOccupancy } from "./types.js";
4
5
  export declare class TextBufferView {
5
6
  private lib;
6
7
  private viewPtr;
@@ -18,9 +19,11 @@ export declare class TextBufferView {
18
19
  end: number;
19
20
  } | null;
20
21
  hasSelection(): boolean;
21
- setLocalSelection(anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor?: RGBA, fgColor?: RGBA): boolean;
22
- updateLocalSelection(anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor?: RGBA, fgColor?: RGBA): boolean;
22
+ setLocalSelection(anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor?: RGBA, fgColor?: RGBA, behavior?: SelectionBehavior): boolean;
23
+ updateLocalSelection(anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor?: RGBA, fgColor?: RGBA, behavior?: SelectionBehavior): boolean;
23
24
  resetLocalSelection(): void;
25
+ setSelectionOccupancy(occupancy: SelectionOccupancy): void;
26
+ getSelectionOccupancy(): SelectionOccupancy;
24
27
  setWrapWidth(width: number | null): void;
25
28
  setWrapMode(mode: "none" | "char" | "word"): void;
26
29
  setFirstLineOffset(offset: number): void;
package/types.d.ts CHANGED
@@ -24,6 +24,15 @@ export declare const ATTRIBUTE_BASE_MASK = 255;
24
24
  export declare function getBaseAttributes(attr: number): number;
25
25
  export type ThemeMode = "dark" | "light";
26
26
  export type CursorStyle = "block" | "line" | "underline" | "default";
27
+ /** How a selection occupies cells between stored anchor and focus offsets.
28
+ * Independent of `cursorStyle` (CSI `q` is paint). Default `cell` includes
29
+ * the grapheme under the max endpoint. `boundary` is the half-open insert
30
+ * range `[min, max)`. */
31
+ export type SelectionOccupancy = "cell" | "boundary";
32
+ /** How local cell coordinates expand into a highlight range.
33
+ * `cell` is the current inclusive press/drag. `word` and `line` expand
34
+ * each endpoint through native selectWord / selectLine. */
35
+ export type SelectionBehavior = "cell" | "word" | "line";
27
36
  export type MousePointerStyle = "default" | "pointer" | "text" | "crosshair" | "move" | "not-allowed";
28
37
  export interface CursorStyleOptions {
29
38
  style?: CursorStyle;
@@ -42,7 +51,7 @@ export declare enum TargetChannel {
42
51
  BG = 2,
43
52
  Both = 3
44
53
  }
45
- export type WidthMethod = "wcwidth" | "unicode";
54
+ export type WidthMethod = "wcwidth" | "unicode" | "unicode-wide";
46
55
  export type TerminalMultiplexer = "none" | "tmux" | "zellij" | "screen" | "unknown";
47
56
  export type TerminalCapabilityState = "unknown" | "supported" | "unsupported";
48
57
  export type ImageRenderProtocol = "auto" | "kitty" | "sixel" | "blocks";
@@ -128,7 +137,7 @@ export interface RenderContext extends EventEmitter {
128
137
  keyInput: KeyHandler;
129
138
  _internalKeyInput: InternalKeyHandler;
130
139
  clearSelection: () => void;
131
- startSelection: (renderable: Renderable, x: number, y: number) => void;
140
+ startSelection: (renderable: Renderable, x: number, y: number, behavior?: SelectionBehavior) => void;
132
141
  updateSelection: (currentRenderable: Renderable | undefined, x: number, y: number, options?: {
133
142
  finishDragging?: boolean;
134
143
  }) => void;
package/yoga.bun.js CHANGED
@@ -93,7 +93,7 @@ import {
93
93
  WRAP_WRAP_REVERSE,
94
94
  Wrap,
95
95
  yoga_default
96
- } from "./chunk-bun-9335djz2.js";
96
+ } from "./chunk-bun-2956gvaq.js";
97
97
  export {
98
98
  yoga_default as default,
99
99
  Wrap,
package/yoga.js CHANGED
@@ -92,7 +92,7 @@ import {
92
92
  WRAP_WRAP_REVERSE,
93
93
  Wrap,
94
94
  yoga_default
95
- } from "./chunk-node-2h23nsbj.js";
95
+ } from "./chunk-node-mfda59vq.js";
96
96
  export {
97
97
  yoga_default as default,
98
98
  Wrap,
package/zig-structs.d.ts CHANGED
@@ -38,6 +38,7 @@ export declare const VisualCursorStruct: import("bun-ffi-structs").DefineStructR
38
38
  export declare const TerminalCapabilitiesStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["kitty_keyboard", "bool_u8"], readonly ["kitty_graphics", "bool_u8"], readonly ["rgb", "bool_u8"], readonly ["ansi256", "bool_u8"], readonly ["unicode", import("bun-ffi-structs").EnumDef<{
39
39
  wcwidth: number;
40
40
  unicode: number;
41
+ "unicode-wide": number;
41
42
  }>], readonly ["sgr_pixels", "bool_u8"], readonly ["color_scheme_updates", "bool_u8"], readonly ["explicit_width", "bool_u8"], readonly ["scaled_text", "bool_u8"], readonly ["sixel", "bool_u8"], readonly ["focus_tracking", "bool_u8"], readonly ["sync", "bool_u8"], readonly ["bracketed_paste", "bool_u8"], readonly ["hyperlinks", "bool_u8"], readonly ["osc52", "bool_u8"], readonly ["notifications", "bool_u8"], readonly ["explicit_cursor_positioning", "bool_u8"], readonly ["remote", "bool_u8"], readonly ["multiplexer", import("bun-ffi-structs").EnumDef<{
42
43
  none: number;
43
44
  tmux: number;
package/zig.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type FFICallbackInstance, type Pointer } from "./platform/ffi.js";
2
- import { type CursorStyle, type CursorStyleOptions, type TargetChannel, type DebugOverlayCorner, type WidthMethod, type TerminalCapabilities, type Highlight, type LineInfo, type ImageRenderProtocol } from "./types.js";
2
+ import { type CursorStyle, type CursorStyleOptions, type SelectionOccupancy, type SelectionBehavior, type TargetChannel, type DebugOverlayCorner, type WidthMethod, type TerminalCapabilities, type Highlight, type LineInfo, type ImageRenderProtocol } from "./types.js";
3
3
  export type { LineInfo, AllocatorStats, AudioStreamCreateOptions, BuildOptions, NativeAudioCaptureStats, NativeAudioStreamStats, NativeRenderStats, };
4
4
  import { RGBA } from "./lib/RGBA.js";
5
5
  import { OptimizedBuffer } from "./buffer.js";
@@ -474,10 +474,12 @@ export interface RenderLib extends AudioEngineLib {
474
474
  start: number;
475
475
  end: number;
476
476
  } | null;
477
- textBufferViewSetLocalSelection: (view: TextBufferViewHandle, anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor: RGBA | null, fgColor: RGBA | null) => boolean;
477
+ textBufferViewSetLocalSelection: (view: TextBufferViewHandle, anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor: RGBA | null, fgColor: RGBA | null, behavior?: SelectionBehavior) => boolean;
478
478
  textBufferViewUpdateSelection: (view: TextBufferViewHandle, end: number, bgColor: RGBA | null, fgColor: RGBA | null) => void;
479
- textBufferViewUpdateLocalSelection: (view: TextBufferViewHandle, anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor: RGBA | null, fgColor: RGBA | null) => boolean;
479
+ textBufferViewUpdateLocalSelection: (view: TextBufferViewHandle, anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor: RGBA | null, fgColor: RGBA | null, behavior?: SelectionBehavior) => boolean;
480
480
  textBufferViewResetLocalSelection: (view: TextBufferViewHandle) => void;
481
+ textBufferViewSetSelectionOccupancy: (view: TextBufferViewHandle, occupancy: SelectionOccupancy) => void;
482
+ textBufferViewGetSelectionOccupancy: (view: TextBufferViewHandle) => SelectionOccupancy;
481
483
  textBufferViewSetWrapWidth: (view: TextBufferViewHandle, width: number) => void;
482
484
  textBufferViewSetWrapMode: (view: TextBufferViewHandle, mode: "none" | "char" | "word") => void;
483
485
  textBufferViewSetFirstLineOffset: (view: TextBufferViewHandle, offset: number) => void;
@@ -573,10 +575,14 @@ export interface RenderLib extends AudioEngineLib {
573
575
  start: number;
574
576
  end: number;
575
577
  } | null;
576
- editorViewSetLocalSelection: (view: EditorViewHandle, anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor: RGBA | null, fgColor: RGBA | null, updateCursor: boolean, followCursor: boolean) => boolean;
578
+ editorViewSetLocalSelection: (view: EditorViewHandle, anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor: RGBA | null, fgColor: RGBA | null, updateCursor: boolean, followCursor: boolean, behavior?: SelectionBehavior) => boolean;
577
579
  editorViewUpdateSelection: (view: EditorViewHandle, end: number, bgColor: RGBA | null, fgColor: RGBA | null) => void;
578
- editorViewUpdateLocalSelection: (view: EditorViewHandle, anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor: RGBA | null, fgColor: RGBA | null, updateCursor: boolean, followCursor: boolean) => boolean;
580
+ editorViewUpdateLocalSelection: (view: EditorViewHandle, anchorX: number, anchorY: number, focusX: number, focusY: number, bgColor: RGBA | null, fgColor: RGBA | null, updateCursor: boolean, followCursor: boolean, behavior?: SelectionBehavior) => boolean;
579
581
  editorViewResetLocalSelection: (view: EditorViewHandle) => void;
582
+ editorViewConvertSelectionToCell: (view: EditorViewHandle) => boolean;
583
+ editorViewSetSelectionOccupancy: (view: EditorViewHandle, occupancy: SelectionOccupancy) => void;
584
+ editorViewSetSelectionInclusive: (view: EditorViewHandle, start: number, end: number, bgColor: RGBA | null, fgColor: RGBA | null) => void;
585
+ editorViewSetSelectionColors: (view: EditorViewHandle, bgColor: RGBA | null, fgColor: RGBA | null) => void;
580
586
  editorViewGetSelectedTextBytes: (view: EditorViewHandle, maxLength: number) => Uint8Array | null;
581
587
  editorViewGetCursor: (view: EditorViewHandle) => {
582
588
  row: number;
@@ -593,6 +599,7 @@ export interface RenderLib extends AudioEngineLib {
593
599
  editorViewGetEOL: (view: EditorViewHandle) => VisualCursor;
594
600
  editorViewGetVisualSOL: (view: EditorViewHandle) => VisualCursor;
595
601
  editorViewGetVisualEOL: (view: EditorViewHandle) => VisualCursor;
602
+ editorViewGotoVisualLineEnd: (view: EditorViewHandle) => void;
596
603
  editorViewGetLineInfo: (view: EditorViewHandle) => LineInfo;
597
604
  editorViewGetLogicalLineInfo: (view: EditorViewHandle) => LineInfo;
598
605
  editorViewSetPlaceholderStyledText: (view: EditorViewHandle, chunks: Array<{