@native-sdk/cli 0.6.2 → 0.7.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.
Files changed (64) hide show
  1. package/build.zig +8 -0
  2. package/package.json +9 -9
  3. package/packages/core/package-lock.json +2 -2
  4. package/packages/core/package.json +1 -1
  5. package/packages/core/sdk/text.ts +62 -21
  6. package/skill-data/native-ui/SKILL.md +17 -2
  7. package/src/platform/macos/appkit_host.h +2 -0
  8. package/src/platform/macos/appkit_host.m +36 -10
  9. package/src/platform/macos/root.zig +7 -1
  10. package/src/platform/types.zig +2 -0
  11. package/src/primitives/canvas/code.zig +590 -0
  12. package/src/primitives/canvas/code_tests.zig +1062 -0
  13. package/src/primitives/canvas/equality.zig +3 -1
  14. package/src/primitives/canvas/events.zig +4 -0
  15. package/src/primitives/canvas/layout_audit.zig +3 -1
  16. package/src/primitives/canvas/markdown.zig +13 -11
  17. package/src/primitives/canvas/markdown_tests.zig +167 -4
  18. package/src/primitives/canvas/root.zig +15 -2
  19. package/src/primitives/canvas/tests.zig +1 -0
  20. package/src/primitives/canvas/text.zig +10 -0
  21. package/src/primitives/canvas/text_interaction.zig +164 -22
  22. package/src/primitives/canvas/text_layout.zig +107 -21
  23. package/src/primitives/canvas/text_measure_cache.zig +4 -4
  24. package/src/primitives/canvas/text_span_tests.zig +254 -0
  25. package/src/primitives/canvas/text_spans.zig +556 -32
  26. package/src/primitives/canvas/text_tests.zig +86 -0
  27. package/src/primitives/canvas/themes/geist.zig +29 -0
  28. package/src/primitives/canvas/tokens.zig +72 -2
  29. package/src/primitives/canvas/ui.zig +325 -21
  30. package/src/primitives/canvas/ui_markup.zig +59 -2
  31. package/src/primitives/canvas/ui_markup_compiled.zig +76 -0
  32. package/src/primitives/canvas/ui_markup_compiled_tests.zig +33 -0
  33. package/src/primitives/canvas/ui_markup_contract.zig +34 -0
  34. package/src/primitives/canvas/ui_markup_reflect.zig +20 -3
  35. package/src/primitives/canvas/ui_markup_view.zig +73 -0
  36. package/src/primitives/canvas/ui_markup_view_tests.zig +101 -0
  37. package/src/primitives/canvas/ui_schema.zig +17 -6
  38. package/src/primitives/canvas/ui_schema_tests.zig +7 -6
  39. package/src/primitives/canvas/ui_tests.zig +6 -0
  40. package/src/primitives/canvas/widget_invalidation.zig +3 -0
  41. package/src/primitives/canvas/widget_layout.zig +57 -8
  42. package/src/primitives/canvas/widget_layout_tests.zig +35 -0
  43. package/src/primitives/canvas/widget_metrics.zig +30 -1
  44. package/src/primitives/canvas/widget_render.zig +454 -9
  45. package/src/primitives/canvas/widget_runtime.zig +1 -0
  46. package/src/primitives/canvas/widget_text_input.zig +23 -11
  47. package/src/primitives/canvas/widget_text_select.zig +2 -2
  48. package/src/primitives/canvas/widgets.zig +13 -0
  49. package/src/root.zig +1 -0
  50. package/src/runtime/api.zig +9 -0
  51. package/src/runtime/canvas_frame_helpers.zig +1 -0
  52. package/src/runtime/canvas_limits.zig +7 -0
  53. package/src/runtime/canvas_widget_accessibility_tests.zig +27 -1
  54. package/src/runtime/canvas_widget_clipboard_tests.zig +146 -0
  55. package/src/runtime/canvas_widget_context_menu.zig +12 -2
  56. package/src/runtime/canvas_widget_display.zig +15 -1
  57. package/src/runtime/canvas_widget_events.zig +50 -20
  58. package/src/runtime/canvas_widget_runtime.zig +74 -12
  59. package/src/runtime/canvas_widget_state.zig +1 -0
  60. package/src/runtime/canvas_widget_text_tests.zig +1935 -70
  61. package/src/runtime/gpu_surface_events.zig +38 -0
  62. package/src/runtime/view.zig +37 -3
  63. package/src/runtime/view_widget_text.zig +1242 -14
  64. package/src/runtime/view_widget_tree.zig +2 -0
@@ -305,7 +305,9 @@ pub fn optionalF32Equal(a: ?f32, b: ?f32) bool {
305
305
 
306
306
  pub fn optionalTextSelectionsEqual(a: ?TextSelection, b: ?TextSelection) bool {
307
307
  if (a) |left| {
308
- if (b) |right| return left.anchor == right.anchor and left.focus == right.focus;
308
+ if (b) |right| return left.anchor == right.anchor and
309
+ left.focus == right.focus and
310
+ left.affinity == right.affinity;
309
311
  return false;
310
312
  }
311
313
  return b == null;
@@ -67,6 +67,10 @@ pub const WidgetPointerEvent = struct {
67
67
  /// may leave this at 0; gesture owners use the initiating down to
68
68
  /// decide whether to capture.
69
69
  button: i32 = 0,
70
+ /// Keyboard modifiers held for this pointer event. Text editors use
71
+ /// Shift on pointer-down to extend from the existing selection
72
+ /// anchor instead of replacing it with a collapsed caret.
73
+ modifiers: WidgetKeyboardModifiers = .{},
70
74
  };
71
75
 
72
76
  pub const WidgetKeyboardPhase = enum {
@@ -244,7 +244,9 @@ fn auditNodeTextOverflow(layout: WidgetLayoutTree, node_index: usize, tokens: De
244
244
  }
245
245
 
246
246
  fn auditSpanParagraphOverflow(widget: Widget, frame: geometry.RectF, node_index: usize, tokens: DesignTokens, sink: *FindingSink) void {
247
- const content = frame.inset(widget.layout.padding).normalized();
247
+ var framed_widget = widget;
248
+ framed_widget.frame = frame;
249
+ const content = widget_metrics.widgetTextSpanContentFrame(framed_widget, tokens).normalized();
248
250
  var runs: [text_spans_model.max_text_span_runs_per_paragraph]text_spans_model.TextSpanRun = undefined;
249
251
  const span_layout = text_spans_model.layoutTextSpans(
250
252
  widget.spans,
@@ -10,7 +10,8 @@
10
10
  //!
11
11
  //! Supported blocks: `#`/`##`/`###` headings (deeper levels clamp to h3),
12
12
  //! paragraphs, bullet/ordered/task lists (nesting up to
13
- //! `max_markdown_list_depth` by two-space indent), fenced code blocks,
13
+ //! `max_markdown_list_depth` by two-space indent), fenced code blocks
14
+ //! (source indentation preserved and language-tagged fences highlighted),
14
15
  //! `>` blockquotes, horizontal rules, GFM pipe tables (header row +
15
16
  //! delimiter row + body rows onto `table`/`data_row`/`data_cell` widgets;
16
17
  //! `:---`/`:--:`/`---:` delimiter cells set per-column start/center/end
@@ -57,6 +58,7 @@
57
58
  //! that exceed a capacity truncate deterministically.
58
59
 
59
60
  const std = @import("std");
61
+ const code_model = @import("code.zig");
60
62
  const geometry = @import("geometry");
61
63
  const canvas = @import("root.zig");
62
64
  const text_spans = @import("text_spans.zig");
@@ -291,7 +293,8 @@ pub fn Markdown(comptime Msg: type) type {
291
293
  }
292
294
 
293
295
  fn parseCodeFence(self: *Builder, lines: *LineIterator) ?Node {
294
- _ = lines.next(); // opening fence (info string ignored)
296
+ const opening = lines.next() orelse return null;
297
+ const language = code_model.languageFromFence(opening);
295
298
  const start = lines.index;
296
299
  var end = start;
297
300
  while (lines.next()) |line| {
@@ -299,13 +302,7 @@ pub fn Markdown(comptime Msg: type) type {
299
302
  end = lines.index;
300
303
  }
301
304
  const code = std.mem.trimEnd(u8, lines.source[start..@min(end, lines.source.len)], "\n");
302
- const code_span = [_]TextSpan{.{ .text = code, .monospace = true }};
303
- return self.ui.el(.panel, .{
304
- .padding = 12,
305
- .style_tokens = .{ .background = .surface_subtle },
306
- }, .{
307
- self.ui.paragraph(.{}, &code_span),
308
- });
305
+ return self.ui.code(.{ .language = language }, code);
309
306
  }
310
307
 
311
308
  fn parseBlockquote(self: *Builder, lines: *LineIterator) ?Node {
@@ -365,9 +362,14 @@ pub fn Markdown(comptime Msg: type) type {
365
362
  .semantics = .{ .label = marker.content },
366
363
  }),
367
364
  };
368
- if (depth == 0) return self.ui.row(.{ .gap = 8 }, .{ lead, content });
365
+ // The outer row must keep stretch alignment so a wrapped
366
+ // paragraph receives the row's full measured height. A
367
+ // one-child column consumes that stretched marker slot
368
+ // while laying its marker at the slot's leading edge.
369
+ const lead_top = self.ui.column(.{}, .{lead});
370
+ if (depth == 0) return self.ui.row(.{ .gap = 8 }, .{ lead_top, content });
369
371
  const indent = self.ui.el(.stack, .{ .width = @as(f32, @floatFromInt(depth)) * 16 }, .{});
370
- return self.ui.row(.{ .gap = 8 }, .{ indent, lead, content });
372
+ return self.ui.row(.{ .gap = 8 }, .{ indent, lead_top, content });
371
373
  }
372
374
 
373
375
  fn parseDetails(self: *Builder, lines: *LineIterator) ?Node {
@@ -48,6 +48,42 @@ fn countKind(widget: canvas.Widget, kind: canvas.WidgetKind) usize {
48
48
  return count;
49
49
  }
50
50
 
51
+ fn findKind(widget: canvas.Widget, kind: canvas.WidgetKind) ?canvas.Widget {
52
+ if (widget.kind == kind) return widget;
53
+ for (widget.children) |child| {
54
+ if (findKind(child, kind)) |found| return found;
55
+ }
56
+ return null;
57
+ }
58
+
59
+ fn appendParagraphText(widget: canvas.Widget, out: *std.ArrayListUnmanaged(u8), allocator: std.mem.Allocator) !void {
60
+ if (widget.kind == .text and widget.spans.len > 0) {
61
+ try out.appendSlice(allocator, widget.text);
62
+ return;
63
+ }
64
+ for (widget.children) |child| try appendParagraphText(child, out, allocator);
65
+ }
66
+
67
+ fn hasSpan(widget: canvas.Widget, text: []const u8, color: ?canvas.TextSpanColor) bool {
68
+ for (widget.spans) |span| {
69
+ if (std.mem.eql(u8, span.text, text) and span.color == color) return true;
70
+ }
71
+ for (widget.children) |child| {
72
+ if (hasSpan(child, text, color)) return true;
73
+ }
74
+ return false;
75
+ }
76
+
77
+ fn allSpansMonospace(widget: canvas.Widget) bool {
78
+ for (widget.spans) |span| {
79
+ if (!span.monospace) return false;
80
+ }
81
+ for (widget.children) |child| {
82
+ if (!allSpansMonospace(child)) return false;
83
+ }
84
+ return true;
85
+ }
86
+
51
87
  fn findParagraphContaining(widget: canvas.Widget, fragment: []const u8) ?canvas.Widget {
52
88
  if (widget.kind == .text and widget.spans.len > 0 and std.mem.indexOf(u8, widget.text, fragment) != null) return widget;
53
89
  for (widget.children) |child| {
@@ -72,6 +108,18 @@ fn findKindLabel(widget: canvas.Widget, kind: canvas.WidgetKind, label: []const
72
108
  return null;
73
109
  }
74
110
 
111
+ fn findRowWithDirectParagraph(widget: canvas.Widget, fragment: []const u8) ?canvas.Widget {
112
+ if (widget.kind == .row) {
113
+ for (widget.children) |child| {
114
+ if (child.kind == .text and child.spans.len > 0 and std.mem.indexOf(u8, child.text, fragment) != null) return widget;
115
+ }
116
+ }
117
+ for (widget.children) |child| {
118
+ if (findRowWithDirectParagraph(child, fragment)) |found| return found;
119
+ }
120
+ return null;
121
+ }
122
+
75
123
  test "markdown maps headings, paragraphs, and inline styles onto spans" {
76
124
  var doc = TestDoc.init();
77
125
  defer doc.deinit();
@@ -144,11 +192,104 @@ test "markdown maps lists, task lists, code fences, quotes, and rules" {
144
192
  try testing.expect(findParagraphContaining(tree.root, "one") != null);
145
193
  try testing.expect(findParagraphContaining(tree.root, "quoted wisdom") != null);
146
194
  try testing.expectEqual(@as(usize, 2), countKind(tree.root, .separator));
147
-
148
- // The fenced block is a panel wrapping a mono paragraph.
195
+ // The row keeps stretch alignment for wrapped paragraph height, while
196
+ // a leading column pins the marker itself to the first-line edge.
197
+ const bullet_row = findRowWithDirectParagraph(tree.root, "first").?;
198
+ const ordered_row = findRowWithDirectParagraph(tree.root, "one").?;
199
+ try testing.expectEqual(canvas.WidgetCrossAlignment.stretch, bullet_row.layout.cross_alignment);
200
+ try testing.expectEqual(canvas.WidgetKind.column, bullet_row.children[0].kind);
201
+ try testing.expectEqualStrings("•", bullet_row.children[0].children[0].text);
202
+ try testing.expectEqual(canvas.WidgetCrossAlignment.stretch, ordered_row.layout.cross_alignment);
203
+ try testing.expectEqual(canvas.WidgetKind.column, ordered_row.children[0].kind);
204
+ try testing.expectEqualStrings("1.", ordered_row.children[0].children[0].text);
205
+
206
+ // The fenced block is a panel wrapping highlighted mono spans.
149
207
  try testing.expectEqual(@as(usize, 1), countKind(tree.root, .panel));
150
208
  const code = findParagraphContaining(tree.root, "const x = 1;").?;
151
209
  try testing.expect(code.spans[0].monospace);
210
+ try testing.expectEqual(@as(?canvas.TextSpanColor, .syntax_keyword), code.spans[0].color);
211
+ }
212
+
213
+ test "language-tagged code fences highlight tokens and preserve indentation" {
214
+ var doc = TestDoc.init();
215
+ defer doc.deinit();
216
+ const tree = try doc.build(
217
+ \\```zig
218
+ \\pub fn main() void {
219
+ \\ const message = "hello";
220
+ \\ // keep this indentation
221
+ \\ return 42;
222
+ \\}
223
+ \\```
224
+ , .{});
225
+
226
+ const panel = findKind(tree.root, .panel).?;
227
+ var source_text: std.ArrayListUnmanaged(u8) = .empty;
228
+ defer source_text.deinit(testing.allocator);
229
+ try appendParagraphText(panel, &source_text, testing.allocator);
230
+ try testing.expectEqualStrings(
231
+ "pub fn main() void {\n const message = \"hello\";\n // keep this indentation\n return 42;\n}",
232
+ source_text.items,
233
+ );
234
+ try testing.expect(allSpansMonospace(panel));
235
+ try testing.expect(hasSpan(panel, "pub", .syntax_keyword));
236
+ try testing.expect(hasSpan(panel, "void", .syntax_literal));
237
+ try testing.expect(hasSpan(panel, "\"hello\"", .syntax_literal));
238
+ try testing.expect(hasSpan(panel, "// keep this indentation", .syntax_comment));
239
+ try testing.expect(hasSpan(panel, "42", .syntax_literal));
240
+
241
+ const indented = findParagraphContaining(panel, "const message").?;
242
+ var runs: [text_spans.max_text_span_runs_per_paragraph]text_spans.TextSpanRun = undefined;
243
+ const layout = text_spans.layoutTextSpans(indented.spans, .{ .size = 14, .max_width = 10_000 }, &runs);
244
+ var indented_keyword_x: ?f32 = null;
245
+ for (layout.runs) |run| {
246
+ if (run.line_index == 1 and std.mem.eql(u8, run.text, "const")) indented_keyword_x = run.x;
247
+ }
248
+ // Four source spaces occupy real horizontal advance before `const`.
249
+ try testing.expect(indented_keyword_x != null);
250
+ try testing.expectApproxEqAbs(@as(f32, 4 * 14 * 0.6), indented_keyword_x.?, 0.01);
251
+ }
252
+
253
+ test "unrecognized code-fence languages remain plain monospace" {
254
+ var doc = TestDoc.init();
255
+ defer doc.deinit();
256
+ const tree = try doc.build(
257
+ \\```made-up-language
258
+ \\alpha 42
259
+ \\```
260
+ , .{});
261
+
262
+ const code = findParagraphContaining(tree.root, "alpha 42").?;
263
+ try testing.expectEqual(@as(usize, 1), code.spans.len);
264
+ try testing.expect(code.spans[0].monospace);
265
+ try testing.expectEqual(@as(?canvas.TextSpanColor, .syntax_plain), code.spans[0].color);
266
+ }
267
+
268
+ test "per-line syntax highlighting does not drop fenced code" {
269
+ const code_source =
270
+ "const a0 = 0;\n" ++
271
+ "const a1 = 1;\n" ++
272
+ "const a2 = 2;\n" ++
273
+ "const a3 = 3;\n" ++
274
+ "const a4 = 4;\n" ++
275
+ "const a5 = 5;\n" ++
276
+ "const a6 = 6;\n" ++
277
+ "const a7 = 7;\n" ++
278
+ "const a8 = 8;\n" ++
279
+ "const a9 = 9;\n" ++
280
+ "const a10 = 10;\n" ++
281
+ "const a11 = 11;";
282
+ const source = "```zig\n" ++ code_source ++ "\n```";
283
+
284
+ var doc = TestDoc.init();
285
+ defer doc.deinit();
286
+ const tree = try doc.build(source, .{});
287
+ const panel = findKind(tree.root, .panel).?;
288
+ var rendered: std.ArrayListUnmanaged(u8) = .empty;
289
+ defer rendered.deinit(testing.allocator);
290
+ try appendParagraphText(panel, &rendered, testing.allocator);
291
+ try testing.expectEqualStrings(code_source, rendered.items);
292
+ try testing.expect(hasSpan(panel, "const", .syntax_keyword));
152
293
  }
153
294
 
154
295
  test "details blocks are caller-controlled collapsibles" {
@@ -391,6 +532,12 @@ test "the README-shaped fixture renders through the mapper and the reference ren
391
532
  const surface = try canvas.ReferenceRenderSurface.init(width, height, pixels);
392
533
  try surface.renderPass(frame.renderPass(), canvas.Color.rgb8(255, 255, 255));
393
534
 
535
+ // Deliberate golden updates can be reviewed as pixels before pinning
536
+ // the new signature.
537
+ if (markdownGoldenDumpRequested()) {
538
+ try dumpMarkdownGoldenPng("/tmp/markdown-shots/readme.png", width, height, pixels);
539
+ }
540
+
394
541
  // Golden: byte-identical reference rendering of the README fixture.
395
542
  try testing.expectEqual(markdown_document_reference_signature, support.referenceSurfaceSignature(pixels));
396
543
  try support.expectVisiblePixel(surface.pixelRgba8(24, 32));
@@ -402,11 +549,27 @@ test "the README-shaped fixture renders through the mapper and the reference ren
402
549
  // scales, wrapped bullets and em-dash spacing at the face's real
403
550
  // advances, real sans and mono outlines (fixed-pitch runs sit in their
404
551
  // 0.6 em cells), GFM tables as borderless cells on hairline row
405
- // separators, fenced-code panels, and near-black underlined links.
552
+ // separators, fenced-code panels with preserved source indentation and
553
+ // language-token colors, and near-black underlined links.
406
554
  // Update deliberately when markdown rendering changes, reviewing the
407
555
  // rendered pixels first (see reference_tests.zig conventions).
408
- const markdown_document_reference_signature: u64 = 4124710367581899536;
556
+ const markdown_document_reference_signature: u64 = 12721641780797724784;
409
557
 
558
+ fn markdownGoldenDumpRequested() bool {
559
+ if (comptime !@import("builtin").link_libc) return false;
560
+ return std.c.getenv("MARKDOWN_GOLDEN_DUMP") != null;
561
+ }
562
+
563
+ fn dumpMarkdownGoldenPng(path: []const u8, width: usize, height: usize, pixels: []const u8) !void {
564
+ const io = testing.io;
565
+ std.Io.Dir.cwd().createDirPath(io, std.fs.path.dirname(path) orelse ".") catch {};
566
+ var file = try std.Io.Dir.cwd().createFile(io, path, .{});
567
+ defer file.close(io);
568
+ var write_buffer: [4096]u8 = undefined;
569
+ var writer = file.writer(io, &write_buffer);
570
+ try canvas.png.writeRgba8(&writer.interface, width, height, pixels);
571
+ try writer.interface.flush();
572
+ }
410
573
 
411
574
  test "bare URLs autolink at word boundaries with trailing punctuation trimmed" {
412
575
  var doc = TestDoc.init();
@@ -198,6 +198,8 @@ pub const TextLayoutCachePlanner = text_model.TextLayoutCachePlanner;
198
198
  pub const TextRange = text_model.TextRange;
199
199
  pub const TextSelectionRect = text_model.TextSelectionRect;
200
200
  pub const TextSelection = text_model.TextSelection;
201
+ pub const TextCaretAffinity = text_model.TextCaretAffinity;
202
+ pub const TextCaretPosition = text_model.TextCaretPosition;
201
203
  pub const TextCaretDirection = text_model.TextCaretDirection;
202
204
  pub const TextCaretMove = text_model.TextCaretMove;
203
205
  pub const TextCompositionUpdate = text_model.TextCompositionUpdate;
@@ -355,6 +357,7 @@ pub const ColorContrast = token_model.ColorContrast;
355
357
  pub const ThemeOptions = token_model.ThemeOptions;
356
358
  pub const ThemePack = token_model.ThemePack;
357
359
  pub const ColorTokens = token_model.ColorTokens;
360
+ pub const colorTokenValue = token_model.colorTokenValue;
358
361
  pub const FontFamily = token_model.FontFamily;
359
362
  pub const TypographyTokens = token_model.TypographyTokens;
360
363
  pub const SpacingTokens = token_model.SpacingTokens;
@@ -528,8 +531,9 @@ pub const max_chart_axis_ticks = chart.max_chart_axis_ticks;
528
531
  pub const chartPointCount = chart.chartPointCount;
529
532
  pub const chartHoverIndex = chart.chartHoverIndex;
530
533
 
531
- // GitHub-flavored-markdown mapper (markdown source -> widget tree + span
532
- // model) lives in `markdown.zig`; also exported as `native_sdk.markdown`.
534
+ // Shared source-code lexer/presentation model and GitHub-flavored-markdown
535
+ // mapper. Markdown fenced blocks lower through `Ui.code`.
536
+ pub const code = @import("code.zig");
533
537
  pub const markdown = @import("markdown.zig");
534
538
 
535
539
  // Deterministic key-lookup scratch shared by the per-frame planners and
@@ -661,17 +665,25 @@ pub const layoutWidgetTreeWithTokens = widget_runtime.layoutWidgetTreeWithTokens
661
665
  pub const layoutTextRun = text_model.layoutTextRun;
662
666
  pub const layoutTextRunPlan = text_model.layoutTextRunPlan;
663
667
  pub const layoutTextCaretRect = text_model.layoutTextCaretRect;
668
+ pub const layoutTextCaretRectWithAffinity = text_model.layoutTextCaretRectWithAffinity;
664
669
  pub const textCaretRectForLayout = text_model.textCaretRectForLayout;
670
+ pub const textCaretRectForLayoutWithAffinity = text_model.textCaretRectForLayoutWithAffinity;
665
671
  pub const layoutTextSelectionRects = text_model.layoutTextSelectionRects;
666
672
  pub const textSelectionRectsForLayout = text_model.textSelectionRectsForLayout;
667
673
  pub const layoutTextOffsetForPoint = text_model.layoutTextOffsetForPoint;
674
+ pub const layoutTextCaretPositionForPoint = text_model.layoutTextCaretPositionForPoint;
668
675
  pub const textOffsetForLayoutPoint = text_model.textOffsetForLayoutPoint;
676
+ pub const textCaretPositionForLayoutPoint = text_model.textCaretPositionForLayoutPoint;
669
677
  pub const applyTextInputEvent = text_model.applyTextInputEvent;
670
678
  pub const snapTextOffset = text_model.snapTextOffset;
671
679
  pub const snapTextRange = text_model.snapTextRange;
672
680
  pub const snapTextSelection = text_model.snapTextSelection;
681
+ pub const snapTextCaretPosition = text_model.snapTextCaretPosition;
682
+ pub const snapTextCaretSelection = text_model.snapTextCaretSelection;
673
683
  pub const textWordSelectionAtOffset = text_model.textWordSelectionAtOffset;
674
684
  pub const textLineSelectionAtOffset = text_model.textLineSelectionAtOffset;
685
+ pub const textLineStartOffset = text_model.textLineStartOffset;
686
+ pub const textLineEndOffset = text_model.textLineEndOffset;
675
687
 
676
688
  pub const sampleCanvasRenderAnimations = render_model.sampleCanvasRenderAnimations;
677
689
 
@@ -689,6 +701,7 @@ pub const textSelectionCommandId = widget_runtime.textSelectionCommandId;
689
701
  pub const toggleWidgetKnobTravel = widget_runtime.toggleWidgetKnobTravel;
690
702
  pub const widgetControlAimPoint = widget_runtime.widgetControlAimPoint;
691
703
  pub const textSelectionForWidgetPoint = widget_runtime.textSelectionForWidgetPoint;
704
+ pub const textCaretPositionForWidgetPoint = widget_runtime.textCaretPositionForWidgetPoint;
692
705
  pub const textOffsetForWidgetPoint = widget_runtime.textOffsetForWidgetPoint;
693
706
 
694
707
  // Static text selection (click-drag select + copy in `.text` widgets;
@@ -25,6 +25,7 @@ test {
25
25
  _ = @import("text_metrics_tests.zig");
26
26
  _ = @import("text_batch_tests.zig");
27
27
  _ = @import("text_span_tests.zig");
28
+ _ = @import("code_tests.zig");
28
29
  _ = @import("markdown_tests.zig");
29
30
  _ = @import("markdown_hostile_tests.zig");
30
31
  _ = @import("layout_audit_tests.zig");
@@ -39,11 +39,15 @@ pub const layoutTextRunPlan = text_layout.layoutTextRunPlan;
39
39
  pub const TextLineIterator = text_layout.TextLineIterator;
40
40
  pub const textBounds = text_layout.textBounds;
41
41
  pub const layoutTextCaretRect = text_layout.layoutTextCaretRect;
42
+ pub const layoutTextCaretRectWithAffinity = text_layout.layoutTextCaretRectWithAffinity;
42
43
  pub const textCaretRectForLayout = text_layout.textCaretRectForLayout;
44
+ pub const textCaretRectForLayoutWithAffinity = text_layout.textCaretRectForLayoutWithAffinity;
43
45
  pub const layoutTextSelectionRects = text_layout.layoutTextSelectionRects;
44
46
  pub const textSelectionRectsForLayout = text_layout.textSelectionRectsForLayout;
45
47
  pub const layoutTextOffsetForPoint = text_layout.layoutTextOffsetForPoint;
48
+ pub const layoutTextCaretPositionForPoint = text_layout.layoutTextCaretPositionForPoint;
46
49
  pub const textOffsetForLayoutPoint = text_layout.textOffsetForLayoutPoint;
50
+ pub const textCaretPositionForLayoutPoint = text_layout.textCaretPositionForLayoutPoint;
47
51
  pub const nextTextLineEnd = text_layout.nextTextLineEnd;
48
52
  pub const textLineRange = text_layout.textLineRange;
49
53
  pub const textLineCaretX = text_layout.textLineCaretX;
@@ -62,6 +66,8 @@ pub const isTextBreakByte = text_layout.isTextBreakByte;
62
66
  pub const TextRange = text_interaction.TextRange;
63
67
  pub const TextSelectionRect = text_interaction.TextSelectionRect;
64
68
  pub const TextSelection = text_interaction.TextSelection;
69
+ pub const TextCaretAffinity = text_interaction.TextCaretAffinity;
70
+ pub const TextCaretPosition = text_interaction.TextCaretPosition;
65
71
  pub const TextCaretDirection = text_interaction.TextCaretDirection;
66
72
  pub const TextCaretMove = text_interaction.TextCaretMove;
67
73
  pub const TextCompositionUpdate = text_interaction.TextCompositionUpdate;
@@ -70,6 +76,8 @@ pub const TextEditState = text_interaction.TextEditState;
70
76
  pub const TextBuffer = text_interaction.TextBuffer;
71
77
  pub const applyTextInputEvent = text_interaction.applyTextInputEvent;
72
78
  pub const snapTextSelection = text_interaction.snapTextSelection;
79
+ pub const snapTextCaretPosition = text_interaction.snapTextCaretPosition;
80
+ pub const snapTextCaretSelection = text_interaction.snapTextCaretSelection;
73
81
  pub const snapTextRange = text_interaction.snapTextRange;
74
82
  pub const previousTextOffset = text_interaction.previousTextOffset;
75
83
  pub const nextTextOffset = text_interaction.nextTextOffset;
@@ -77,6 +85,8 @@ pub const previousTextWordOffset = text_interaction.previousTextWordOffset;
77
85
  pub const nextTextWordOffset = text_interaction.nextTextWordOffset;
78
86
  pub const textWordSelectionAtOffset = text_interaction.textWordSelectionAtOffset;
79
87
  pub const textLineSelectionAtOffset = text_interaction.textLineSelectionAtOffset;
88
+ pub const textLineStartOffset = text_interaction.textLineStartOffset;
89
+ pub const textLineEndOffset = text_interaction.textLineEndOffset;
80
90
  pub const snapTextOffset = text_interaction.snapTextOffset;
81
91
  pub const utf8SequenceLength = text_interaction.utf8SequenceLength;
82
92
  pub const isUtf8ContinuationByte = text_interaction.isUtf8ContinuationByte;