@native-sdk/cli 0.7.0 → 0.7.2
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/build/app.zig +8 -0
- package/build.zig +114 -103
- package/native-sdk.d.ts +6 -3
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/text.ts +25 -14
- package/packages/core/src/checker.ts +39 -0
- package/packages/core/src/emitter.ts +125 -1
- package/skill-data/native-ui/SKILL.md +11 -7
- package/src/platform/macos/appkit_host.m +76 -4
- package/src/platform/macos/cef_host.mm +24 -2
- package/src/platform/macos/root.zig +13 -0
- package/src/platform/types.zig +4 -0
- package/src/platform/windows/gpu_surface_renderer.cpp +2280 -0
- package/src/platform/windows/gpu_surface_renderer.h +86 -0
- package/src/platform/windows/root.zig +298 -20
- package/src/platform/windows/webview2_host.cpp +343 -33
- package/src/primitives/canvas/code.zig +501 -33
- package/src/primitives/canvas/code_tests.zig +1029 -6
- package/src/primitives/canvas/events.zig +111 -1
- package/src/primitives/canvas/frame.zig +45 -1
- package/src/primitives/canvas/gpu.zig +6 -0
- package/src/primitives/canvas/markdown_tests.zig +17 -18
- package/src/primitives/canvas/render_tests.zig +93 -0
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/serialization.zig +150 -21
- package/src/primitives/canvas/text.zig +6 -0
- package/src/primitives/canvas/themes/geist.zig +51 -5
- package/src/primitives/canvas/tokens.zig +33 -4
- package/src/primitives/canvas/ui.zig +160 -36
- package/src/primitives/canvas/ui_markup.zig +60 -9
- package/src/primitives/canvas/ui_markup_compiled.zig +41 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +12 -0
- package/src/primitives/canvas/ui_markup_contract.zig +17 -1
- package/src/primitives/canvas/ui_markup_view.zig +44 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +80 -6
- package/src/primitives/canvas/ui_schema.zig +18 -0
- package/src/primitives/canvas/ui_schema_tests.zig +10 -7
- package/src/primitives/canvas/ui_tests.zig +40 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
- package/src/primitives/canvas/widget_invalidation.zig +12 -1
- package/src/primitives/canvas/widget_layout.zig +260 -21
- package/src/primitives/canvas/widget_metrics.zig +47 -6
- package/src/primitives/canvas/widget_render.zig +849 -78
- package/src/primitives/canvas/widget_render_controls.zig +83 -25
- package/src/primitives/canvas/widget_render_style.zig +52 -8
- package/src/primitives/canvas/widget_runtime.zig +2 -0
- package/src/primitives/canvas/widget_text_input.zig +167 -8
- package/src/primitives/canvas/widget_tree.zig +6 -5
- package/src/primitives/canvas/widgets.zig +78 -2
- package/src/runtime/canvas_budget_edge_tests.zig +3 -2
- package/src/runtime/canvas_frame.zig +60 -7
- package/src/runtime/canvas_frame_invalidation_tests.zig +80 -0
- package/src/runtime/canvas_frame_packet_tests.zig +83 -9
- package/src/runtime/canvas_frame_patch_tests.zig +16 -0
- package/src/runtime/canvas_images.zig +8 -2
- package/src/runtime/canvas_limits.zig +13 -6
- package/src/runtime/canvas_widget_clipboard_tests.zig +8 -5
- package/src/runtime/canvas_widget_context_menu.zig +7 -2
- package/src/runtime/canvas_widget_event_tests.zig +18 -14
- package/src/runtime/canvas_widget_events.zig +51 -20
- package/src/runtime/canvas_widget_runtime.zig +108 -4
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +59 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +100 -0
- package/src/runtime/canvas_widget_state.zig +27 -0
- package/src/runtime/canvas_widget_text_tests.zig +326 -0
- package/src/runtime/core.zig +15 -5
- package/src/runtime/effects.zig +6 -0
- package/src/runtime/effects_tests.zig +30 -0
- package/src/runtime/gpu_surface_events.zig +50 -19
- package/src/runtime/media_surface_tests.zig +1 -1
- package/src/runtime/runtime_event_tests.zig +74 -0
- package/src/runtime/ui_app.zig +10 -8
- package/src/runtime/ui_app_tests.zig +67 -0
- package/src/runtime/view.zig +60 -16
- package/src/runtime/view_canvas.zig +15 -0
- package/src/runtime/view_widget_scroll.zig +48 -18
- package/src/runtime/view_widget_text.zig +59 -16
- package/src/runtime/window_view_runtime.zig +10 -0
- package/src/tooling/templates.zig +9 -6
package/src/runtime/ui_app.zig
CHANGED
|
@@ -4327,13 +4327,14 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
4327
4327
|
self.fonts_built_count = runtime.registeredCanvasFontCount();
|
|
4328
4328
|
}
|
|
4329
4329
|
|
|
4330
|
-
/// Present the planned canvas frame: GPU packet when the
|
|
4331
|
-
///
|
|
4332
|
-
///
|
|
4333
|
-
/// e.g.
|
|
4334
|
-
///
|
|
4335
|
-
///
|
|
4336
|
-
///
|
|
4330
|
+
/// Present the planned canvas frame: GPU packet when the view did
|
|
4331
|
+
/// not explicitly request software and the platform has a packet
|
|
4332
|
+
/// presenter (macOS/Metal — unchanged), otherwise the CPU
|
|
4333
|
+
/// reference-rendered pixel path (`presentGpuSurfacePixels`, e.g.
|
|
4334
|
+
/// Linux/GTK). A platform whose packet presenter exists but reports
|
|
4335
|
+
/// `UnsupportedService` at present time also falls back to pixels;
|
|
4336
|
+
/// that attempt forces a full repaint because the failed packet plan
|
|
4337
|
+
/// already recorded the frame's presented summary.
|
|
4337
4338
|
fn presentFrame(self: *Self, runtime: *Runtime, frame_event: platform.GpuSurfaceFrameEvent, canvas_label: []const u8, force_full_repaint: bool, clear_color: canvas.Color) anyerror!void {
|
|
4338
4339
|
// A forced frame must paint unconditionally: the installing
|
|
4339
4340
|
// frame has no earlier glass to retain. Software-buffer
|
|
@@ -4341,7 +4342,8 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
4341
4342
|
// a surface handoff.
|
|
4342
4343
|
const services = runtime.options.platform.services;
|
|
4343
4344
|
var packet_attempted = false;
|
|
4344
|
-
|
|
4345
|
+
const packet_requested = canvas_frame.canvasGpuPacketPresentationRequested(runtime, frame_event.window_id, canvas_label);
|
|
4346
|
+
if (packet_requested and (services.present_gpu_surface_packet_fn != null or services.present_gpu_surface_packet_binary_fn != null)) {
|
|
4345
4347
|
packet_attempted = true;
|
|
4346
4348
|
const packet_presented = blk: {
|
|
4347
4349
|
_ = runtime.presentNextCanvasGpuPacketWithScale(
|
|
@@ -66,6 +66,25 @@ fn counterOptions() CounterApp.Options {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
const software_counter_views = [_]app_manifest.ShellView{
|
|
70
|
+
.{ .label = canvas_label, .kind = .gpu_surface, .fill = true, .gpu_backend = .software },
|
|
71
|
+
};
|
|
72
|
+
const software_counter_windows = [_]app_manifest.ShellWindow{.{
|
|
73
|
+
.label = "main",
|
|
74
|
+
.title = "Software Counter",
|
|
75
|
+
.width = 400,
|
|
76
|
+
.height = 300,
|
|
77
|
+
.views = &software_counter_views,
|
|
78
|
+
}};
|
|
79
|
+
const software_counter_scene: app_manifest.ShellConfig = .{ .windows = &software_counter_windows };
|
|
80
|
+
|
|
81
|
+
fn softwareCounterOptions() CounterApp.Options {
|
|
82
|
+
var options = counterOptions();
|
|
83
|
+
options.name = "ui-app-software-counter";
|
|
84
|
+
options.scene = software_counter_scene;
|
|
85
|
+
return options;
|
|
86
|
+
}
|
|
87
|
+
|
|
69
88
|
fn findWidgetIdByText(tree: anytype, kind: canvas.WidgetKind, text: []const u8) ?canvas.ObjectId {
|
|
70
89
|
return findIn(tree.root, kind, text);
|
|
71
90
|
}
|
|
@@ -480,6 +499,54 @@ test "ui app presents pixels when the packet service is unsupported" {
|
|
|
480
499
|
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 1"));
|
|
481
500
|
}
|
|
482
501
|
|
|
502
|
+
test "ui app explicit software canvas bypasses the production packet path" {
|
|
503
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
504
|
+
defer harness.destroy(std.testing.allocator);
|
|
505
|
+
harness.null_platform.gpu_surfaces = true;
|
|
506
|
+
harness.runtime.options.pixel_present_retained_baseline = true;
|
|
507
|
+
|
|
508
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
509
|
+
defer std.testing.allocator.destroy(app_state);
|
|
510
|
+
app_state.* = CounterApp.init(std.testing.allocator, .{}, softwareCounterOptions());
|
|
511
|
+
defer app_state.deinit();
|
|
512
|
+
const app = app_state.app();
|
|
513
|
+
try harness.start(app);
|
|
514
|
+
|
|
515
|
+
// Packet services are available and would accept this frame. The
|
|
516
|
+
// immutable software request must still send it directly to the
|
|
517
|
+
// reference renderer without recording a packet fallback.
|
|
518
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
519
|
+
.label = canvas_label,
|
|
520
|
+
.size = geometry.SizeF.init(400, 300),
|
|
521
|
+
.scale_factor = 2,
|
|
522
|
+
.frame_index = 1,
|
|
523
|
+
.timestamp_ns = 1_000_000,
|
|
524
|
+
} });
|
|
525
|
+
|
|
526
|
+
try std.testing.expect(app_state.installed);
|
|
527
|
+
try std.testing.expectEqual(zero_platform.GpuSurfaceBackend.software, harness.runtime.views[0].gpu_requested_backend);
|
|
528
|
+
try std.testing.expectEqual(@as(usize, 0), harness.null_platform.gpu_surface_packet_present_count);
|
|
529
|
+
try std.testing.expectEqual(@as(usize, 0), harness.null_platform.gpu_surface_image_upload_count);
|
|
530
|
+
try std.testing.expectEqual(@as(usize, 1), harness.null_platform.gpu_surface_present_count);
|
|
531
|
+
try std.testing.expectEqual(zero_platform.GpuPresentPath.pixels, harness.runtime.views[0].gpu_present_path);
|
|
532
|
+
try std.testing.expectEqual(zero_platform.GpuPresentFallbackReason.none, harness.runtime.views[0].info().gpu_present_fallback_reason);
|
|
533
|
+
|
|
534
|
+
// A changed follow-up frame remains incremental. Treating the central
|
|
535
|
+
// software-policy rejection as a failed packet attempt would force this
|
|
536
|
+
// pixel present back to the full surface.
|
|
537
|
+
try app_state.dispatch(&harness.runtime, 1, .increment);
|
|
538
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
539
|
+
.label = canvas_label,
|
|
540
|
+
.size = geometry.SizeF.init(400, 300),
|
|
541
|
+
.scale_factor = 2,
|
|
542
|
+
.frame_index = 2,
|
|
543
|
+
.timestamp_ns = 17_000_000,
|
|
544
|
+
} });
|
|
545
|
+
try std.testing.expectEqual(@as(usize, 2), harness.null_platform.gpu_surface_present_count);
|
|
546
|
+
const dirty = harness.null_platform.gpu_surface_present_dirty_bounds orelse return error.TestUnexpectedResult;
|
|
547
|
+
try std.testing.expect(dirty.width < 400 or dirty.height < 300);
|
|
548
|
+
}
|
|
549
|
+
|
|
483
550
|
// ---------------------------------- reflow stale-pixel oracle fixture
|
|
484
551
|
|
|
485
552
|
const ReflowRow = struct {
|
package/src/runtime/view.zig
CHANGED
|
@@ -29,9 +29,7 @@ const max_canvas_visual_effects_per_view = canvas_limits.max_canvas_visual_effec
|
|
|
29
29
|
const max_canvas_text_layouts_per_view = canvas_limits.max_canvas_text_layouts_per_view;
|
|
30
30
|
const max_canvas_widget_nodes_per_view = canvas_limits.max_canvas_widget_nodes_per_view;
|
|
31
31
|
const max_canvas_widget_semantics_per_view = canvas_limits.max_canvas_widget_semantics_per_view;
|
|
32
|
-
const max_canvas_widget_text_bytes_per_view = canvas_limits.max_canvas_widget_text_bytes_per_view;
|
|
33
32
|
const max_canvas_widget_source_text_entries_per_view = canvas_limits.max_canvas_widget_source_text_entries_per_view;
|
|
34
|
-
const max_canvas_widget_text_history_bytes_per_view = canvas_limits.max_canvas_widget_text_history_bytes_per_view;
|
|
35
33
|
const max_canvas_widget_text_history_entries_per_view = canvas_limits.max_canvas_widget_text_history_entries_per_view;
|
|
36
34
|
|
|
37
35
|
const CanvasWidgetSourceTextEntry = canvas_widget_runtime.CanvasWidgetSourceTextEntry;
|
|
@@ -161,12 +159,10 @@ pub fn clearImeGraceOnViewBlur(runtime: anytype, view: *RuntimeView) void {
|
|
|
161
159
|
// otherwise leave the carry armed to swallow the refocused view's
|
|
162
160
|
// first unrelated commit.
|
|
163
161
|
view.canvas_widget_claimed_key_grace = .none;
|
|
164
|
-
// A Tab that entered a live terminal
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
// for the tail of the old gesture.
|
|
169
|
-
view.canvas_widget_terminal_focus_entry_tab_held = false;
|
|
162
|
+
// A Tab that entered a Tab-owning editor (live terminal or editable
|
|
163
|
+
// code) suppresses its repeats and release until the physical key
|
|
164
|
+
// comes up. If the view blurs first, retire the latch here.
|
|
165
|
+
view.canvas_widget_tab_input_focus_entry_held = false;
|
|
170
166
|
// Same physical-lifetime rule for terminal Paste: a native menu can
|
|
171
167
|
// synthesize only the key-down, and a real Cmd/Ctrl+V may release its
|
|
172
168
|
// modifier before V. Blur retires either incomplete gesture so no
|
|
@@ -223,6 +219,11 @@ pub const RuntimeView = struct {
|
|
|
223
219
|
gpu_first_frame_latency_recorded: bool = false,
|
|
224
220
|
gpu_frame_nonblank: bool = false,
|
|
225
221
|
gpu_sample_color: u32 = 0,
|
|
222
|
+
/// Immutable creation-time backend request. `gpu_backend` below is
|
|
223
|
+
/// completion state and changes to the concrete presenter reported by
|
|
224
|
+
/// the host, so it cannot answer whether packet work was explicitly
|
|
225
|
+
/// opted out before a present.
|
|
226
|
+
gpu_requested_backend: platform.GpuSurfaceBackend = .none,
|
|
226
227
|
gpu_backend: platform.GpuSurfaceBackend = .none,
|
|
227
228
|
gpu_pixel_format: platform.GpuSurfacePixelFormat = .none,
|
|
228
229
|
gpu_present_mode: platform.GpuSurfacePresentMode = .none,
|
|
@@ -538,12 +539,11 @@ pub const RuntimeView = struct {
|
|
|
538
539
|
/// one is still held, on hosts that emit input-method text before
|
|
539
540
|
/// its key_down) flows instead of being eaten by a stale latch.
|
|
540
541
|
canvas_widget_claimed_key_grace: CanvasWidgetClaimedKeyGrace = .none,
|
|
541
|
-
/// A physical Tab whose first key-down moved focus INTO a
|
|
542
|
-
/// terminal. Its auto-repeats and
|
|
543
|
-
///
|
|
544
|
-
///
|
|
545
|
-
|
|
546
|
-
canvas_widget_terminal_focus_entry_tab_held: bool = false,
|
|
542
|
+
/// A physical Tab whose first key-down moved focus INTO a Tab-owning
|
|
543
|
+
/// editor (live terminal or editable code). Its auto-repeats and
|
|
544
|
+
/// eventual release still belong to focus traversal, not input for
|
|
545
|
+
/// the newly focused target.
|
|
546
|
+
canvas_widget_tab_input_focus_entry_held: bool = false,
|
|
547
547
|
/// A Cmd/Ctrl+V key-down the clipboard pass converted into terminal
|
|
548
548
|
/// paste input. Its physical V release belongs to that paste even if
|
|
549
549
|
/// the modifier came up first; the raw gpu-input pass consumes it
|
|
@@ -706,6 +706,11 @@ pub const RuntimeView = struct {
|
|
|
706
706
|
canvas_widget_click_count: u8 = 0,
|
|
707
707
|
canvas_widget_click_timestamp_ns: u64 = 0,
|
|
708
708
|
canvas_widget_click_point: geometry.PointF = .{},
|
|
709
|
+
/// A chain belongs to one physical pointer and one resolved press/text
|
|
710
|
+
/// target. Nearby controls must never donate the first click of another
|
|
711
|
+
/// control's double-click gesture.
|
|
712
|
+
canvas_widget_click_pointer_id: u64 = 0,
|
|
713
|
+
canvas_widget_click_target_id: canvas.ObjectId = 0,
|
|
709
714
|
/// The anchor RUN of an in-flight multi-click drag: the word (or
|
|
710
715
|
/// line) selected by the initiating double (triple) click. Drag
|
|
711
716
|
/// extension unions the run under the pointer with this range, so
|
|
@@ -724,7 +729,11 @@ pub const RuntimeView = struct {
|
|
|
724
729
|
canvas_widget_drag_regions: [canvas_limits.max_canvas_widget_window_drag_regions_per_view]platform.WindowDragRegion = undefined,
|
|
725
730
|
canvas_widget_drag_region_count: usize = 0,
|
|
726
731
|
canvas_widget_drag_regions_pushed: bool = false,
|
|
727
|
-
|
|
732
|
+
widget_text_inline_bytes: [canvas_limits.max_canvas_widget_inline_text_bytes_per_view]u8 = undefined,
|
|
733
|
+
/// Points at `widget_text_inline_bytes` for ordinary views and upgrades to
|
|
734
|
+
/// heap-owned large-file capacity only when a retained layout needs it.
|
|
735
|
+
widget_text_bytes: []u8 = &.{},
|
|
736
|
+
widget_text_bytes_heap_owned: bool = false,
|
|
728
737
|
widget_text_len: usize = 0,
|
|
729
738
|
widget_span_entries: [canvas_limits.max_canvas_widget_spans_per_view]canvas.TextSpan = undefined,
|
|
730
739
|
widget_span_len: usize = 0,
|
|
@@ -763,7 +772,9 @@ pub const RuntimeView = struct {
|
|
|
763
772
|
/// snapshot.
|
|
764
773
|
canvas_widget_text_history_entries: [max_canvas_widget_text_history_entries_per_view]view_widget_text.CanvasWidgetTextHistoryEntry = undefined,
|
|
765
774
|
canvas_widget_text_history_entry_count: usize = 0,
|
|
766
|
-
|
|
775
|
+
canvas_widget_text_history_inline_bytes: [canvas_limits.max_canvas_widget_inline_text_history_bytes_per_view]u8 = undefined,
|
|
776
|
+
canvas_widget_text_history_bytes: []u8 = &.{},
|
|
777
|
+
canvas_widget_text_history_bytes_heap_owned: bool = false,
|
|
767
778
|
canvas_widget_text_history_byte_count: usize = 0,
|
|
768
779
|
canvas_widget_text_history_next_serial: u64 = 1,
|
|
769
780
|
/// Native textarea Up/Down retains its painted x coordinate while a
|
|
@@ -781,6 +792,7 @@ pub const RuntimeView = struct {
|
|
|
781
792
|
const CanvasWidgetTextMethods = view_widget_text.RuntimeViewCanvasWidgetText(RuntimeView);
|
|
782
793
|
pub const applyCanvasWidgetTextEdit = CanvasWidgetTextMethods.applyCanvasWidgetTextEdit;
|
|
783
794
|
pub const applyCanvasWidgetTextEditWithoutHistory = CanvasWidgetTextMethods.applyCanvasWidgetTextEditWithoutHistory;
|
|
795
|
+
pub const canvasWidgetTextEditNeedsLargeStorage = CanvasWidgetTextMethods.canvasWidgetTextEditNeedsLargeStorage;
|
|
784
796
|
pub const canvasWidgetKeyboardTextEdit = CanvasWidgetTextMethods.canvasWidgetKeyboardTextEdit;
|
|
785
797
|
pub const canvasWidgetTextHistoryShortcut = CanvasWidgetTextMethods.canvasWidgetTextHistoryShortcut;
|
|
786
798
|
pub const canvasWidgetTextHistoryAvailability = CanvasWidgetTextMethods.canvasWidgetTextHistoryAvailability;
|
|
@@ -853,6 +865,7 @@ pub const RuntimeView = struct {
|
|
|
853
865
|
pub const copyCanvasFrameResourceCache = CanvasFrameMethods.copyCanvasFrameResourceCache;
|
|
854
866
|
pub const copyCanvasFramePathGeometryCache = CanvasFrameMethods.copyCanvasFramePathGeometryCache;
|
|
855
867
|
pub const copyCanvasFrameImageCache = CanvasFrameMethods.copyCanvasFrameImageCache;
|
|
868
|
+
pub const removeCanvasFrameImageCacheId = CanvasFrameMethods.removeCanvasFrameImageCacheId;
|
|
856
869
|
pub const copyCanvasFrameLayerCache = CanvasFrameMethods.copyCanvasFrameLayerCache;
|
|
857
870
|
pub const copyCanvasFrameVisualEffectCache = CanvasFrameMethods.copyCanvasFrameVisualEffectCache;
|
|
858
871
|
pub const copyCanvasRenderAnimations = CanvasFrameMethods.copyCanvasRenderAnimations;
|
|
@@ -1199,7 +1212,21 @@ pub const RuntimeView = struct {
|
|
|
1199
1212
|
}
|
|
1200
1213
|
|
|
1201
1214
|
pub fn copyRuntimeStateFrom(self: *RuntimeView, source: *const RuntimeView, scratch: *canvas_widget_runtime.CanvasWidgetCopyScratch) void {
|
|
1215
|
+
const widget_text_bytes = self.widget_text_bytes;
|
|
1216
|
+
const widget_text_bytes_heap_owned = self.widget_text_bytes_heap_owned;
|
|
1217
|
+
const text_history_bytes = self.canvas_widget_text_history_bytes;
|
|
1218
|
+
const text_history_bytes_heap_owned = self.canvas_widget_text_history_bytes_heap_owned;
|
|
1202
1219
|
self.* = source.*;
|
|
1220
|
+
self.widget_text_bytes = widget_text_bytes;
|
|
1221
|
+
self.widget_text_bytes_heap_owned = widget_text_bytes_heap_owned;
|
|
1222
|
+
self.canvas_widget_text_history_bytes = text_history_bytes;
|
|
1223
|
+
self.canvas_widget_text_history_bytes_heap_owned = text_history_bytes_heap_owned;
|
|
1224
|
+
if (self.canvas_widget_text_history_bytes.ptr != source.canvas_widget_text_history_bytes.ptr) {
|
|
1225
|
+
@memcpy(
|
|
1226
|
+
self.canvas_widget_text_history_bytes[0..source.canvas_widget_text_history_byte_count],
|
|
1227
|
+
source.canvas_widget_text_history_bytes[0..source.canvas_widget_text_history_byte_count],
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1203
1230
|
self.label = copyInto(&self.label_storage, source.label) catch unreachable;
|
|
1204
1231
|
self.parent = if (source.parent) |parent| copyInto(&self.parent_storage, parent) catch unreachable else null;
|
|
1205
1232
|
self.role = copyInto(&self.role_storage, source.role) catch unreachable;
|
|
@@ -1213,4 +1240,21 @@ pub const RuntimeView = struct {
|
|
|
1213
1240
|
self.widget_revision = source.widget_revision;
|
|
1214
1241
|
@memcpy(self.widget_scroll_states[0..source.widget_layout_node_count], source.widget_scroll_states[0..source.widget_layout_node_count]);
|
|
1215
1242
|
}
|
|
1243
|
+
|
|
1244
|
+
pub fn ensureLargeCanvasWidgetTextStorage(self: *RuntimeView, allocator: std.mem.Allocator) !void {
|
|
1245
|
+
if (self.widget_text_bytes_heap_owned) return;
|
|
1246
|
+
const text_bytes = try allocator.alloc(u8, canvas_limits.max_canvas_widget_text_bytes_per_view);
|
|
1247
|
+
errdefer allocator.free(text_bytes);
|
|
1248
|
+
const history_bytes = try allocator.alloc(u8, canvas_limits.max_canvas_widget_text_history_bytes_per_view);
|
|
1249
|
+
errdefer allocator.free(history_bytes);
|
|
1250
|
+
@memcpy(text_bytes[0..self.widget_text_len], self.widget_text_bytes[0..self.widget_text_len]);
|
|
1251
|
+
@memcpy(
|
|
1252
|
+
history_bytes[0..self.canvas_widget_text_history_byte_count],
|
|
1253
|
+
self.canvas_widget_text_history_bytes[0..self.canvas_widget_text_history_byte_count],
|
|
1254
|
+
);
|
|
1255
|
+
self.widget_text_bytes = text_bytes;
|
|
1256
|
+
self.widget_text_bytes_heap_owned = true;
|
|
1257
|
+
self.canvas_widget_text_history_bytes = history_bytes;
|
|
1258
|
+
self.canvas_widget_text_history_bytes_heap_owned = true;
|
|
1259
|
+
}
|
|
1216
1260
|
};
|
|
@@ -313,6 +313,21 @@ pub fn RuntimeViewCanvasFrame(comptime RuntimeView: type) type {
|
|
|
313
313
|
self.canvas_frame_image_cache_count = entries.len;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
/// Forget every retained cache key for one platform image. The
|
|
317
|
+
/// platform removal seam destroys the resource independently of
|
|
318
|
+
/// this per-view planner mirror; leaving an identical key here
|
|
319
|
+
/// would turn a same-content re-registration into `.retain` and
|
|
320
|
+
/// skip the upload needed to recreate that resource.
|
|
321
|
+
pub fn removeCanvasFrameImageCacheId(self: *RuntimeView, image_id: canvas.ImageId) void {
|
|
322
|
+
var kept: usize = 0;
|
|
323
|
+
for (self.canvas_frame_image_cache[0..self.canvas_frame_image_cache_count]) |entry| {
|
|
324
|
+
if (entry.key.image_id == image_id) continue;
|
|
325
|
+
self.canvas_frame_image_cache[kept] = entry;
|
|
326
|
+
kept += 1;
|
|
327
|
+
}
|
|
328
|
+
self.canvas_frame_image_cache_count = kept;
|
|
329
|
+
}
|
|
330
|
+
|
|
316
331
|
pub fn copyCanvasFrameLayerCache(self: *RuntimeView, entries: []const canvas.RenderLayerCacheEntry) anyerror!void {
|
|
317
332
|
if (entries.len > self.canvas_frame_layer_cache.len) return error.LayerListFull;
|
|
318
333
|
@memcpy(self.canvas_frame_layer_cache[0..entries.len], entries);
|
|
@@ -164,9 +164,13 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
164
164
|
if (!canvas.widgetScrollsAxis(scroll_node.widget, axis)) return false;
|
|
165
165
|
|
|
166
166
|
if (scroll_node.widget.kind == .textarea) {
|
|
167
|
-
const max_offset =
|
|
167
|
+
const max_offset = if (axis == .vertical)
|
|
168
|
+
canvas.textInputMaxScrollOffsetForWidget(scroll_node.widget, self.widget_tokens)
|
|
169
|
+
else
|
|
170
|
+
canvas.textInputMaxHorizontalScrollOffsetForWidget(scroll_node.widget, self.widget_tokens);
|
|
168
171
|
if (max_offset <= 0) return false;
|
|
169
|
-
const
|
|
172
|
+
const value = if (axis == .vertical) scroll_node.widget.value else scroll_node.widget.value_x;
|
|
173
|
+
const current_offset = std.math.clamp(value, 0, max_offset);
|
|
170
174
|
return if (delta > 0) current_offset < max_offset else current_offset > 0;
|
|
171
175
|
}
|
|
172
176
|
|
|
@@ -191,8 +195,8 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
191
195
|
const scroll_node = self.widget_layout_nodes[scroll_index];
|
|
192
196
|
if (!canvasWidgetScrollableKind(scroll_node.widget.kind)) return null;
|
|
193
197
|
if (scroll_node.widget.kind == .textarea) {
|
|
194
|
-
if (axis
|
|
195
|
-
return self
|
|
198
|
+
if (!canvas.widgetScrollsAxis(scroll_node.widget, axis)) return null;
|
|
199
|
+
return applyCanvasWidgetTextareaScrollAxis(self, scroll_index, axis, delta, source);
|
|
196
200
|
}
|
|
197
201
|
if (canvasWidgetModelDrivenVirtual(scroll_node.widget)) return null;
|
|
198
202
|
if (!canvas.widgetScrollsAxis(scroll_node.widget, axis)) return null;
|
|
@@ -246,28 +250,43 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
246
250
|
}
|
|
247
251
|
|
|
248
252
|
pub fn applyCanvasWidgetTextareaScroll(self: *RuntimeView, scroll_index: usize, delta_y: f32, source: CanvasWidgetScrollSource) anyerror!?geometry.RectF {
|
|
253
|
+
return applyCanvasWidgetTextareaScrollAxis(self, scroll_index, .vertical, delta_y, source);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
fn applyCanvasWidgetTextareaScrollAxis(self: *RuntimeView, scroll_index: usize, comptime axis: canvas.ScrollAxis, delta: f32, source: CanvasWidgetScrollSource) anyerror!?geometry.RectF {
|
|
249
257
|
if (scroll_index >= self.widget_layout_node_count) return null;
|
|
250
258
|
const widget = self.widget_layout_nodes[scroll_index].widget;
|
|
251
259
|
if (widget.kind != .textarea) return null;
|
|
252
260
|
|
|
253
261
|
const viewport = canvas.textInputViewportForWidget(widget, self.widget_tokens) orelse return null;
|
|
262
|
+
const vertical = axis == .vertical;
|
|
254
263
|
const current = canvas.ScrollAxisState{
|
|
255
|
-
.offset =
|
|
256
|
-
|
|
257
|
-
|
|
264
|
+
.offset = if (vertical)
|
|
265
|
+
canvas.clampedTextInputScrollOffsetForWidget(widget, self.widget_tokens, widget.value)
|
|
266
|
+
else
|
|
267
|
+
canvas.clampedTextInputHorizontalScrollOffsetForWidget(widget, self.widget_tokens, widget.value_x),
|
|
268
|
+
.viewport_extent = if (vertical) viewport.height else viewport.width,
|
|
269
|
+
.content_extent = if (vertical)
|
|
270
|
+
canvas.textInputContentExtentForWidget(widget, self.widget_tokens)
|
|
271
|
+
else
|
|
272
|
+
canvas.textInputContentWidthForWidget(widget, self.widget_tokens),
|
|
258
273
|
};
|
|
259
274
|
const next = switch (source) {
|
|
260
|
-
.wheel => current.applyWheelClamped(
|
|
275
|
+
.wheel => current.applyWheelClamped(delta, self.widget_tokens.scroll),
|
|
261
276
|
.discrete => discrete: {
|
|
262
277
|
var state = current;
|
|
263
|
-
state.offset +=
|
|
278
|
+
state.offset += delta;
|
|
264
279
|
state.velocity = 0;
|
|
265
280
|
break :discrete state.clamped();
|
|
266
281
|
},
|
|
267
282
|
};
|
|
268
283
|
if (next.offset == current.offset) return null;
|
|
269
284
|
|
|
270
|
-
|
|
285
|
+
if (vertical) {
|
|
286
|
+
self.widget_layout_nodes[scroll_index].widget.value = next.offset;
|
|
287
|
+
} else {
|
|
288
|
+
self.widget_layout_nodes[scroll_index].widget.value_x = next.offset;
|
|
289
|
+
}
|
|
271
290
|
try self.refreshCanvasWidgetSemantics();
|
|
272
291
|
self.widget_revision += 1;
|
|
273
292
|
return self.canvasWidgetDirtyBounds(scroll_index, widget.frame);
|
|
@@ -445,16 +464,21 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
445
464
|
|
|
446
465
|
/// The horizontal content extent: how far the region's mounted
|
|
447
466
|
/// descendants reach rightward, rebased to offset 0. Textareas
|
|
448
|
-
///
|
|
449
|
-
///
|
|
467
|
+
/// ordinary textareas pin horizontally; editable no-wrap code
|
|
468
|
+
/// reports its longest logical line. Closed
|
|
450
469
|
/// disclosure subtrees are skipped — concealed content lays out
|
|
451
470
|
/// at full size and must not inflate the scrollable range on
|
|
452
471
|
/// either axis (the semantics walker applies the same rule).
|
|
453
472
|
pub fn canvasWidgetScrollContentExtentX(self: *const RuntimeView, scroll_index: usize, viewport: geometry.RectF) f32 {
|
|
454
|
-
if (scroll_index < self.widget_layout_node_count
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
473
|
+
if (scroll_index < self.widget_layout_node_count) {
|
|
474
|
+
const widget = self.widget_layout_nodes[scroll_index].widget;
|
|
475
|
+
if (widget.kind == .textarea) {
|
|
476
|
+
return if (widget.code_editor)
|
|
477
|
+
@max(viewport.width, canvas.textInputContentWidthForWidget(widget, self.widget_tokens))
|
|
478
|
+
else
|
|
479
|
+
viewport.width;
|
|
480
|
+
}
|
|
481
|
+
if (widget.layout.virtualized) return viewport.width;
|
|
458
482
|
}
|
|
459
483
|
return canvas_widget_runtime.canvasWidgetLayoutScrollContentExtentX(
|
|
460
484
|
self.widget_layout_nodes[0..self.widget_layout_node_count],
|
|
@@ -488,8 +512,7 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
488
512
|
|
|
489
513
|
/// Keep the editable field's caret inside its visible span after
|
|
490
514
|
/// a text or caret change: textareas scroll vertically, single-
|
|
491
|
-
/// line fields horizontally
|
|
492
|
-
/// `value` offset channel.
|
|
515
|
+
/// line fields horizontally, and no-wrap code editors do both.
|
|
493
516
|
pub fn scrollCanvasTextInputCaretIntoView(self: *RuntimeView, index: usize) void {
|
|
494
517
|
if (index >= self.widget_layout_node_count) return;
|
|
495
518
|
var widget = self.widget_layout_nodes[index].widget;
|
|
@@ -501,6 +524,13 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
501
524
|
}
|
|
502
525
|
if (widget.kind != .textarea) return;
|
|
503
526
|
|
|
527
|
+
if (widget.code_editor and widget.text_no_wrap) {
|
|
528
|
+
const next_x = canvas.textInputCaretVisibleScrollOffsetForWidget(widget, self.widget_tokens, widget.value_x);
|
|
529
|
+
if (next_x != widget.value_x) {
|
|
530
|
+
widget.value_x = next_x;
|
|
531
|
+
self.widget_layout_nodes[index].widget.value_x = next_x;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
504
534
|
const viewport = canvas.textInputViewportForWidget(widget, self.widget_tokens) orelse return;
|
|
505
535
|
const geometry_value = canvas.textGeometryForWidget(widget, self.widget_tokens);
|
|
506
536
|
const caret = geometry_value.caret_bounds orelse return;
|
|
@@ -54,6 +54,20 @@ pub const CanvasWidgetTextHistoryAvailability = struct {
|
|
|
54
54
|
|
|
55
55
|
const max_text_history_edits_per_shortcut = 3;
|
|
56
56
|
|
|
57
|
+
/// One event-loop thread performs at most one retained widget edit at a time.
|
|
58
|
+
/// Keep the maximal edit/rewrite workspaces in lazy per-thread storage: with
|
|
59
|
+
/// practical code-file budgets these buffers no longer fit on mobile and
|
|
60
|
+
/// Windows default stacks, while unused host threads still pay only the TLS
|
|
61
|
+
/// pointer supplied by `LazyTls`.
|
|
62
|
+
const CanvasWidgetTextEditScratch = struct {
|
|
63
|
+
edit_buffer: [max_canvas_widget_text_bytes_per_view]u8,
|
|
64
|
+
rewrite_buffer: [max_canvas_widget_text_bytes_per_view]u8,
|
|
65
|
+
text_ranges: [max_canvas_widget_nodes_per_view]WidgetTextStorageRange,
|
|
66
|
+
label_ranges: [max_canvas_widget_nodes_per_view]WidgetTextStorageRange,
|
|
67
|
+
command_ranges: [max_canvas_widget_nodes_per_view]WidgetTextStorageRange,
|
|
68
|
+
};
|
|
69
|
+
const canvas_widget_text_edit_scratch = canvas.lazy_tls.LazyTls(CanvasWidgetTextEditScratch);
|
|
70
|
+
|
|
57
71
|
pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
58
72
|
return struct {
|
|
59
73
|
pub fn applyCanvasWidgetTextEdit(self: *RuntimeView, target_id: canvas.ObjectId, edit: canvas.TextInputEvent) anyerror!?geometry.RectF {
|
|
@@ -64,19 +78,34 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
64
78
|
return applyCanvasWidgetTextEditWithHistory(self, target_id, edit, false);
|
|
65
79
|
}
|
|
66
80
|
|
|
81
|
+
pub fn canvasWidgetTextEditNeedsLargeStorage(
|
|
82
|
+
self: *const RuntimeView,
|
|
83
|
+
target_id: canvas.ObjectId,
|
|
84
|
+
edit: canvas.TextInputEvent,
|
|
85
|
+
) bool {
|
|
86
|
+
if (self.widget_text_bytes_heap_owned) return false;
|
|
87
|
+
_ = self.canvasWidgetNodeIndexById(target_id) orelse return false;
|
|
88
|
+
const inserted_len = switch (edit) {
|
|
89
|
+
.insert_text => |text| text.len,
|
|
90
|
+
.set_composition => |composition| composition.text.len,
|
|
91
|
+
else => 0,
|
|
92
|
+
};
|
|
93
|
+
return self.widget_text_len +| inserted_len > self.widget_text_bytes.len;
|
|
94
|
+
}
|
|
95
|
+
|
|
67
96
|
fn applyCanvasWidgetTextEditWithHistory(self: *RuntimeView, target_id: canvas.ObjectId, edit: canvas.TextInputEvent, record_history: bool) anyerror!?geometry.RectF {
|
|
68
97
|
const index = self.canvasWidgetNodeIndexById(target_id) orelse return null;
|
|
69
98
|
const widget = self.widget_layout_nodes[index].widget;
|
|
70
99
|
if (!canvasWidgetEditableTextKind(widget.kind) or widget.state.disabled) return null;
|
|
71
100
|
|
|
72
101
|
const previous_bounds = widget.frame;
|
|
73
|
-
|
|
102
|
+
const scratch = canvas_widget_text_edit_scratch.get();
|
|
74
103
|
const current_state = canvas.TextEditState{
|
|
75
104
|
.text = widget.text,
|
|
76
105
|
.selection = widget.text_selection orelse canvas.TextSelection.collapsed(widget.text.len),
|
|
77
106
|
.composition = widget.text_composition,
|
|
78
107
|
};
|
|
79
|
-
const next_state = try current_state.apply(edit, &edit_buffer);
|
|
108
|
+
const next_state = try current_state.apply(edit, &scratch.edit_buffer);
|
|
80
109
|
if (canvasWidgetTextEditUnchanged(current_state, next_state)) return null;
|
|
81
110
|
try validateCanvasWidgetTextStorageRewrite(self, index, next_state);
|
|
82
111
|
|
|
@@ -154,6 +183,9 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
154
183
|
// a newline; submit rides the primary-modifier chord instead.
|
|
155
184
|
// Shared with the app dispatch path so the model's `on_input`
|
|
156
185
|
// hears exactly the edit the retained text applied.
|
|
186
|
+
if (canvas.widgetCodeTabTextEditEvent(widget, keyboard)) |tab_edit| {
|
|
187
|
+
return tab_edit;
|
|
188
|
+
}
|
|
157
189
|
if (canvas.widgetKeyboardNewlineTextEditEvent(widget.kind, keyboard)) |newline_edit| {
|
|
158
190
|
return newline_edit;
|
|
159
191
|
}
|
|
@@ -1144,7 +1176,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1144
1176
|
}
|
|
1145
1177
|
const selected_index = point_index orelse return null;
|
|
1146
1178
|
const selected_widget = self.widget_layout_nodes[selected_index].widget;
|
|
1147
|
-
const focus = selected_widget.static_text_group_offset + point_offset;
|
|
1179
|
+
const focus = @as(usize, @intCast(selected_widget.static_text_group_offset)) + point_offset;
|
|
1148
1180
|
const anchor = if (extend)
|
|
1149
1181
|
self.canvas_widget_selected_text_group_anchor
|
|
1150
1182
|
else
|
|
@@ -1159,7 +1191,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1159
1191
|
if (candidate.static_text_group_id != group_id) {
|
|
1160
1192
|
continue;
|
|
1161
1193
|
}
|
|
1162
|
-
const source_start = candidate.static_text_group_offset;
|
|
1194
|
+
const source_start: usize = @intCast(candidate.static_text_group_offset);
|
|
1163
1195
|
const source_end = source_start +| candidate.text.len;
|
|
1164
1196
|
const next_selection: ?canvas.TextSelection = if (selection_start == selection_end)
|
|
1165
1197
|
if (candidate_index == selected_index)
|
|
@@ -1289,7 +1321,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1289
1321
|
if (widget.static_text_group_id != group_id) {
|
|
1290
1322
|
continue;
|
|
1291
1323
|
}
|
|
1292
|
-
const source_start = widget.static_text_group_offset;
|
|
1324
|
+
const source_start: usize = @intCast(widget.static_text_group_offset);
|
|
1293
1325
|
const source_end = source_start +| widget.text.len;
|
|
1294
1326
|
const copy_start = @max(start, source_start);
|
|
1295
1327
|
const copy_end = @min(end, source_end);
|
|
@@ -1318,31 +1350,42 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1318
1350
|
|
|
1319
1351
|
pub fn rewriteCanvasWidgetTextStorage(self: *RuntimeView, edited_index: usize, next_state: canvas.TextEditState) anyerror!void {
|
|
1320
1352
|
try validateCanvasWidgetTextStorageRewrite(self, edited_index, next_state);
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1353
|
+
const text_changed = !std.mem.eql(
|
|
1354
|
+
u8,
|
|
1355
|
+
self.widget_layout_nodes[edited_index].widget.text,
|
|
1356
|
+
next_state.text,
|
|
1357
|
+
);
|
|
1358
|
+
const scratch = canvas_widget_text_edit_scratch.get();
|
|
1325
1359
|
var temp_len: usize = 0;
|
|
1326
1360
|
|
|
1327
1361
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, index| {
|
|
1328
1362
|
const text = if (index == edited_index) next_state.text else node.widget.text;
|
|
1329
|
-
text_ranges[index] = try appendWidgetTextStorageRange(&
|
|
1330
|
-
label_ranges[index] = try appendWidgetTextStorageRange(&
|
|
1331
|
-
command_ranges[index] = try appendWidgetTextStorageRange(&
|
|
1363
|
+
scratch.text_ranges[index] = try appendWidgetTextStorageRange(&scratch.rewrite_buffer, &temp_len, text);
|
|
1364
|
+
scratch.label_ranges[index] = try appendWidgetTextStorageRange(&scratch.rewrite_buffer, &temp_len, node.widget.semantics.label);
|
|
1365
|
+
scratch.command_ranges[index] = try appendWidgetTextStorageRange(&scratch.rewrite_buffer, &temp_len, node.widget.command);
|
|
1332
1366
|
}
|
|
1333
1367
|
|
|
1334
|
-
@memcpy(self.widget_text_bytes[0..temp_len],
|
|
1368
|
+
@memcpy(self.widget_text_bytes[0..temp_len], scratch.rewrite_buffer[0..temp_len]);
|
|
1335
1369
|
self.widget_text_len = temp_len;
|
|
1336
1370
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |*node, index| {
|
|
1337
|
-
const text_range = text_ranges[index];
|
|
1338
|
-
const label_range = label_ranges[index];
|
|
1339
|
-
const command_range = command_ranges[index];
|
|
1371
|
+
const text_range = scratch.text_ranges[index];
|
|
1372
|
+
const label_range = scratch.label_ranges[index];
|
|
1373
|
+
const command_range = scratch.command_ranges[index];
|
|
1340
1374
|
node.widget.text = self.widget_text_bytes[text_range.start..text_range.end];
|
|
1341
1375
|
node.widget.semantics.label = self.widget_text_bytes[label_range.start..label_range.end];
|
|
1342
1376
|
node.widget.command = self.widget_text_bytes[command_range.start..command_range.end];
|
|
1343
1377
|
}
|
|
1344
1378
|
self.widget_layout_nodes[edited_index].widget.text_selection = next_state.selection;
|
|
1345
1379
|
self.widget_layout_nodes[edited_index].widget.text_composition = next_state.composition;
|
|
1380
|
+
if (text_changed) {
|
|
1381
|
+
if (!self.widget_layout_nodes[edited_index].widget.hasCodeDiff()) {
|
|
1382
|
+
self.widget_layout_nodes[edited_index].widget.code_content_width_generation = 0;
|
|
1383
|
+
}
|
|
1384
|
+
canvas.cacheTextInputContentWidthForWidget(
|
|
1385
|
+
&self.widget_layout_nodes[edited_index].widget,
|
|
1386
|
+
self.widget_tokens,
|
|
1387
|
+
);
|
|
1388
|
+
}
|
|
1346
1389
|
}
|
|
1347
1390
|
|
|
1348
1391
|
/// Prove a retained text rewrite fits before any editor history is
|
|
@@ -484,6 +484,7 @@ pub fn RuntimeWindowViewRuntime(comptime Runtime: type) type {
|
|
|
484
484
|
.transparent = options.transparent,
|
|
485
485
|
.bridge_enabled = options.bridge_enabled,
|
|
486
486
|
.gpu_size = if (options.kind == .gpu_surface) options.frame.size() else geometry.SizeF.init(0, 0),
|
|
487
|
+
.gpu_requested_backend = if (options.kind == .gpu_surface) options.gpu_surface.backend else .none,
|
|
487
488
|
.gpu_backend = if (options.kind == .gpu_surface) options.gpu_surface.backend else .none,
|
|
488
489
|
.gpu_pixel_format = if (options.kind == .gpu_surface) options.gpu_surface.pixel_format else .none,
|
|
489
490
|
.gpu_present_mode = if (options.kind == .gpu_surface) options.gpu_surface.present_mode else .none,
|
|
@@ -496,6 +497,8 @@ pub fn RuntimeWindowViewRuntime(comptime Runtime: type) type {
|
|
|
496
497
|
.keyboard_active = windowKeyboardActive(self, options.window_id),
|
|
497
498
|
.open = true,
|
|
498
499
|
};
|
|
500
|
+
self.views[index].widget_text_bytes = &self.views[index].widget_text_inline_bytes;
|
|
501
|
+
self.views[index].canvas_widget_text_history_bytes = &self.views[index].canvas_widget_text_history_inline_bytes;
|
|
499
502
|
self.views[index].label = try copyInto(&self.views[index].label_storage, options.label);
|
|
500
503
|
self.views[index].parent = if (options.parent) |parent| try copyInto(&self.views[index].parent_storage, parent) else null;
|
|
501
504
|
self.views[index].role = try copyInto(&self.views[index].role_storage, options.role);
|
|
@@ -667,6 +670,13 @@ pub fn RuntimeWindowViewRuntime(comptime Runtime: type) type {
|
|
|
667
670
|
self.views[cursor].copyRuntimeStateFrom(next, &self.canvas_widget_copy_scratch);
|
|
668
671
|
}
|
|
669
672
|
self.view_count -= 1;
|
|
673
|
+
const released = &self.views[self.view_count];
|
|
674
|
+
if (released.widget_text_bytes_heap_owned) self.owned_allocator.free(released.widget_text_bytes);
|
|
675
|
+
if (released.canvas_widget_text_history_bytes_heap_owned) self.owned_allocator.free(released.canvas_widget_text_history_bytes);
|
|
676
|
+
released.widget_text_bytes = &.{};
|
|
677
|
+
released.widget_text_bytes_heap_owned = false;
|
|
678
|
+
released.canvas_widget_text_history_bytes = &.{};
|
|
679
|
+
released.canvas_widget_text_history_bytes_heap_owned = false;
|
|
670
680
|
}
|
|
671
681
|
|
|
672
682
|
pub fn removeViewsForWindow(self: *Runtime, window_id: platform.WindowId) void {
|