@native-sdk/cli 0.5.4 → 0.6.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/build/app.zig +50 -1
- package/build.zig +588 -32
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +3 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +280 -8
- package/packages/core/sdk/core.ts +481 -2
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +599 -3
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +39 -2
- package/skill-data/ts-core/SKILL.md +4 -2
- package/src/app_runner/root.zig +32 -10
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +527 -13
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +280 -7
- package/src/platform/macos/appkit_host.h +104 -6
- package/src/platform/macos/appkit_host.m +1368 -74
- package/src/platform/macos/cef_host.mm +110 -1
- package/src/platform/macos/root.zig +287 -7
- package/src/platform/null_platform.zig +398 -4
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +386 -14
- package/src/platform/windows/root.zig +298 -9
- package/src/platform/windows/webview2_host.cpp +330 -5
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +524 -5
- package/src/primitives/canvas/ui_markup.zig +195 -2
- package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
- package/src/primitives/canvas/ui_markup_contract.zig +88 -5
- package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +149 -0
- package/src/primitives/canvas/ui_markup_view.zig +191 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
- package/src/primitives/canvas/ui_schema.zig +97 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -11
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +16 -0
- package/src/runtime/api.zig +76 -6
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +1 -0
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +268 -26
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +73 -2
- package/src/runtime/effects.zig +6389 -54
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +14 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +25 -4
- package/src/runtime/gpu_surface_events.zig +475 -15
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +25 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_journal.zig +367 -61
- package/src/runtime/session_record.zig +16 -0
- package/src/runtime/session_replay.zig +395 -11
- package/src/runtime/session_tests.zig +114 -19
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/tests.zig +6 -0
- package/src/runtime/ts_core_host.zig +980 -140
- package/src/runtime/ts_core_host_tests.zig +1059 -1
- package/src/runtime/ts_ui_app.zig +16 -5
- package/src/runtime/ui_app.zig +2338 -67
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +268 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_storage.zig +45 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +1 -0
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/templates.zig +25 -7
|
@@ -81,10 +81,11 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
81
81
|
|
|
82
82
|
/// The press target a routed pointer event dispatches to, with the
|
|
83
83
|
/// press-vs-drag disambiguation applied: a release that ends a
|
|
84
|
-
/// static-text selection drag is a selection
|
|
85
|
-
/// so it presses no one (the selection it
|
|
86
|
-
/// copy). A plain click collapses the
|
|
87
|
-
/// reaches `.up` collapsed and the
|
|
84
|
+
/// static-text or terminal selection drag is a selection
|
|
85
|
+
/// gesture, not a click, so it presses no one (the selection it
|
|
86
|
+
/// made stays live for copy). A plain click collapses the
|
|
87
|
+
/// selection on `.down`, so it reaches `.up` collapsed and the
|
|
88
|
+
/// press lands normally.
|
|
88
89
|
fn canvasWidgetPressTargetForRoute(
|
|
89
90
|
self: *const Runtime,
|
|
90
91
|
view_index: usize,
|
|
@@ -94,6 +95,12 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
94
95
|
const press_target = route.press_target orelse return null;
|
|
95
96
|
if (pointer.phase != .up) return press_target;
|
|
96
97
|
const raw = route.target orelse return press_target;
|
|
98
|
+
if (raw.kind == .terminal) {
|
|
99
|
+
const node = self.views[view_index].widgetLayoutTree().findById(raw.id) orelse return press_target;
|
|
100
|
+
const grid = node.widget.terminal.grid orelse return press_target;
|
|
101
|
+
if (grid.selection_active) return null;
|
|
102
|
+
return press_target;
|
|
103
|
+
}
|
|
97
104
|
if (raw.kind != .text) return press_target;
|
|
98
105
|
if (self.views[view_index].canvas_widget_selected_text_id != raw.id) return press_target;
|
|
99
106
|
const node = self.views[view_index].widgetLayoutTree().findById(raw.id) orelse return press_target;
|
|
@@ -186,11 +193,42 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
186
193
|
const index = runtimeFindViewIndex(self, input_event.window_id, input_event.label) orelse return error.ViewNotFound;
|
|
187
194
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
188
195
|
if (!self.views[index].focused) return null;
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
196
|
+
const tree = self.views[index].widgetLayoutTree();
|
|
197
|
+
// An open IME sequence belongs to the editor it STARTED in:
|
|
198
|
+
// its set/commit/cancel continue to route to the owning
|
|
199
|
+
// text entry even when keyboard focus has since moved, so
|
|
200
|
+
// the starting editor resolves its own marked text — never
|
|
201
|
+
// the newly focused widget, never the target-less fallback.
|
|
202
|
+
// `text_input` prefers the owner too: the owner pin is only
|
|
203
|
+
// ever set mid-sequence (and held one event past a cancel,
|
|
204
|
+
// the converted-commit grace), and in both windows a
|
|
205
|
+
// text_input is the sequence's own resolution — the hosts
|
|
206
|
+
// never deliver ordinary typing while a composition is open.
|
|
207
|
+
const ime_owner = self.views[index].canvas_widget_ime_owner_id;
|
|
208
|
+
const target_id = switch (input_event.kind) {
|
|
209
|
+
.ime_set_composition, .ime_commit_composition, .ime_cancel_composition, .text_input => id: {
|
|
210
|
+
if (ime_owner != 0) {
|
|
211
|
+
if (tree.findById(ime_owner)) |node| {
|
|
212
|
+
if (canvas.isWidgetTextEntry(node.widget)) break :id ime_owner;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
break :id self.views[index].canvas_widget_focused_id;
|
|
216
|
+
},
|
|
217
|
+
else => self.views[index].canvas_widget_focused_id,
|
|
218
|
+
};
|
|
219
|
+
if (target_id == 0) return null;
|
|
220
|
+
// Text and IME only belong to an EDITABLE widget. A focused
|
|
221
|
+
// non-text widget (a button, a list row) cannot consume a
|
|
222
|
+
// composition, so returning null here lets the committed
|
|
223
|
+
// text fall through to the app's target-less `on_text` seam
|
|
224
|
+
// instead of being routed to a widget that drops it — the
|
|
225
|
+
// terminal-with-a-focused-button case.
|
|
226
|
+
if (tree.findById(target_id)) |node| {
|
|
227
|
+
if (!canvas.isWidgetTextEntry(node.widget)) return null;
|
|
228
|
+
}
|
|
229
|
+
const keyboard = canvasWidgetTextInputEventFromGpuInput(input_event, target_id) orelse return null;
|
|
192
230
|
|
|
193
|
-
const route = try
|
|
231
|
+
const route = try tree.routeKeyboardEvent(keyboard, output);
|
|
194
232
|
if (route.target == null) return null;
|
|
195
233
|
return .{
|
|
196
234
|
.window_id = input_event.window_id,
|
|
@@ -333,7 +371,7 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
333
371
|
// caret) however focus arrived — the :focus-visible contract
|
|
334
372
|
// text inputs have on every platform.
|
|
335
373
|
const next_focus_visible_id: canvas.ObjectId = if (pointer_event.press_target) |target| blk: {
|
|
336
|
-
if (target.id == next_focus_id and canvas_widget_runtime.
|
|
374
|
+
if (target.id == next_focus_id and canvas_widget_runtime.canvasWidgetShowsPointerFocusRing(target.kind)) break :blk next_focus_id;
|
|
337
375
|
break :blk 0;
|
|
338
376
|
} else 0;
|
|
339
377
|
|
|
@@ -366,34 +404,122 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
366
404
|
const target_id: canvas.ObjectId = if (pointer_event.target) |target| target.id else 0;
|
|
367
405
|
const hover_target = layout_tree.hoverTargetForHit(pointer_event.target);
|
|
368
406
|
const hover_target_id: canvas.ObjectId = if (hover_target) |value| value.id else 0;
|
|
369
|
-
const
|
|
407
|
+
const raw_hit = layout_tree.hitTestWithTokens(pointer_event.pointer.point, self.views[index].widget_tokens);
|
|
408
|
+
// Containment resolves through the HOVER policy hit test —
|
|
409
|
+
// the only consumer that may see hover-only listeners; the
|
|
410
|
+
// wash/cursor resolution below stays on the interactive
|
|
411
|
+
// raw hit, so binding hover never moves a wash or a click.
|
|
412
|
+
const hover_raw_hit = layout_tree.hitTestHoverWithTokens(pointer_event.pointer.point, self.views[index].widget_tokens);
|
|
413
|
+
const hit_target = layout_tree.hoverTargetForHit(raw_hit);
|
|
370
414
|
const hit_target_id: canvas.ObjectId = if (hit_target) |value| value.id else 0;
|
|
371
415
|
const hit_cursor = platformCursorFromCanvas(layout_tree.cursorForHit(hit_target));
|
|
372
416
|
var next_hovered_id = self.views[index].canvas_widget_hovered_id;
|
|
373
417
|
var next_pressed_id = self.views[index].canvas_widget_pressed_id;
|
|
374
418
|
var next_cursor = self.views[index].canvas_widget_cursor;
|
|
375
419
|
|
|
420
|
+
// The hover-Msg chain re-resolves from the SAME raw hit the
|
|
421
|
+
// wash phase-switch consumes below, so containment and the
|
|
422
|
+
// wash always agree: fresh hit test for hovers/moves/ups
|
|
423
|
+
// (drags included — the wash follows the actual pointer),
|
|
424
|
+
// the routed raw target for downs, empty on cancel (the
|
|
425
|
+
// pointer left the view — the window-leave edge). Wheel
|
|
426
|
+
// keeps the standing chain; the scroll reconcile re-derives
|
|
427
|
+
// it from the post-scroll tree. Down/drag/up advance the
|
|
428
|
+
// chain only while a hover-capable pointer is live (a prior
|
|
429
|
+
// hover-phase move) — touch input arrives as bare
|
|
430
|
+
// down/drag/up sequences, so a tap or a scrub can never
|
|
431
|
+
// synthesize hover, while a mouse (whose presence the
|
|
432
|
+
// hover phase already proved) keeps full fidelity through
|
|
433
|
+
// clicks and drags.
|
|
434
|
+
// The hover-capable proof is per pointer IDENTITY: only the
|
|
435
|
+
// pointer that earned it (a hover-phase move) advances the
|
|
436
|
+
// chain through its clicks and drags, so on hosts that
|
|
437
|
+
// distinguish pointers a touch contact can never ride a
|
|
438
|
+
// mouse's proof.
|
|
439
|
+
const hover_pointer_proven = self.views[index].canvas_widget_hover_pointer_live and
|
|
440
|
+
self.views[index].canvas_widget_hover_pointer_id == pointer_event.pointer.pointer_id;
|
|
376
441
|
switch (pointer_event.pointer.phase) {
|
|
377
442
|
.hover, .move => {
|
|
378
443
|
next_hovered_id = hit_target_id;
|
|
379
444
|
next_cursor = hit_cursor;
|
|
445
|
+
// A hover-phase move earns the proof UNLESS the host
|
|
446
|
+
// stamped the event touch-sourced
|
|
447
|
+
// (`platform.touch_pointer_id_bit`): Windows
|
|
448
|
+
// synthesizes a mouse-shaped move for every tap, and
|
|
449
|
+
// that fake float must never make touch hoverable.
|
|
450
|
+
const touch_sourced = pointer_event.pointer.pointer_id & platform.touch_pointer_id_bit != 0;
|
|
451
|
+
if (pointer_event.pointer.phase == .hover and !touch_sourced) {
|
|
452
|
+
self.views[index].canvas_widget_hover_pointer_live = true;
|
|
453
|
+
self.views[index].canvas_widget_hover_pointer_id = pointer_event.pointer.pointer_id;
|
|
454
|
+
self.views[index].canvas_widget_hover_pointer_position = pointer_event.pointer.point;
|
|
455
|
+
self.views[index].setCanvasWidgetHoverMsgChainForHit(hover_raw_hit);
|
|
456
|
+
} else if (hover_pointer_proven) {
|
|
457
|
+
self.views[index].canvas_widget_hover_pointer_position = pointer_event.pointer.point;
|
|
458
|
+
self.views[index].setCanvasWidgetHoverMsgChainForHit(hover_raw_hit);
|
|
459
|
+
}
|
|
380
460
|
},
|
|
381
461
|
.down => {
|
|
382
462
|
next_hovered_id = hover_target_id;
|
|
383
463
|
next_pressed_id = target_id;
|
|
384
464
|
next_cursor = platformCursorFromCanvas(layout_tree.cursorForHit(hover_target));
|
|
465
|
+
if (hover_pointer_proven) {
|
|
466
|
+
self.views[index].canvas_widget_hover_pointer_position = pointer_event.pointer.point;
|
|
467
|
+
// The down's routed target is interactive-only;
|
|
468
|
+
// containment keeps its own resolution.
|
|
469
|
+
self.views[index].setCanvasWidgetHoverMsgChainForHit(hover_raw_hit);
|
|
470
|
+
}
|
|
385
471
|
},
|
|
386
472
|
.up => {
|
|
387
473
|
next_hovered_id = hit_target_id;
|
|
388
474
|
next_pressed_id = 0;
|
|
389
475
|
next_cursor = hit_cursor;
|
|
476
|
+
if (hover_pointer_proven) {
|
|
477
|
+
if (geometry.RectF.fromSize(self.views[index].gpu_size).containsPoint(pointer_event.pointer.point)) {
|
|
478
|
+
self.views[index].canvas_widget_hover_pointer_position = pointer_event.pointer.point;
|
|
479
|
+
self.views[index].setCanvasWidgetHoverMsgChainForHit(hover_raw_hit);
|
|
480
|
+
} else {
|
|
481
|
+
// A captured release OUTSIDE the surface is
|
|
482
|
+
// the pointer already gone — the leave the
|
|
483
|
+
// press suppressed: hosts hold a grab
|
|
484
|
+
// through the drag (no motion-leave fired)
|
|
485
|
+
// and send no later cancel, so containment
|
|
486
|
+
// must retire here or an overflowing
|
|
487
|
+
// listener stays entered at an off-view
|
|
488
|
+
// point — and the anchor must not park
|
|
489
|
+
// off-view for a later rebuild to re-hit.
|
|
490
|
+
// The consumed secondary release has the
|
|
491
|
+
// same rule in gpu_surface_events.
|
|
492
|
+
self.views[index].canvas_widget_hover_msg_chain_len = 0;
|
|
493
|
+
self.views[index].canvas_widget_hover_pointer_live = false;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
390
496
|
},
|
|
391
497
|
.cancel => {
|
|
392
498
|
next_hovered_id = 0;
|
|
393
499
|
next_pressed_id = 0;
|
|
394
500
|
next_cursor = .arrow;
|
|
501
|
+
// Only the proven pointer's departure retires the
|
|
502
|
+
// containment (a lifted touch finger's cancel must
|
|
503
|
+
// not clear a mouse's standing hover); a cancel
|
|
504
|
+
// before any proof clears nothing because nothing
|
|
505
|
+
// stands.
|
|
506
|
+
if (hover_pointer_proven) {
|
|
507
|
+
self.views[index].canvas_widget_hover_msg_chain_len = 0;
|
|
508
|
+
self.views[index].canvas_widget_hover_pointer_live = false;
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
.wheel => {
|
|
512
|
+
// The proven pointer's wheel carries its CURRENT
|
|
513
|
+
// position: refresh the chain's re-hit anchor before
|
|
514
|
+
// the scroll reconcile resolves against it, so a
|
|
515
|
+
// wheel arriving ahead of its coalesced motion event
|
|
516
|
+
// still derives containment from where the pointer
|
|
517
|
+
// really is (the wash resolves from this same wheel
|
|
518
|
+
// point).
|
|
519
|
+
if (hover_pointer_proven) {
|
|
520
|
+
self.views[index].canvas_widget_hover_pointer_position = pointer_event.pointer.point;
|
|
521
|
+
}
|
|
395
522
|
},
|
|
396
|
-
.wheel => {},
|
|
397
523
|
}
|
|
398
524
|
|
|
399
525
|
// Hover-detail chrome (chart cursor + floating card) tracks
|
|
@@ -1647,7 +1773,7 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1647
1773
|
// live tokens, so the dirty region must measure the same way.
|
|
1648
1774
|
const local_dirty = self.views[view_index].widgetLayoutTree().renderStateDirtyBoundsWithTokens(previous, next, self.views[view_index].widget_tokens);
|
|
1649
1775
|
invalidateForCanvasWidgetRenderStateDirty(self, view_index, local_dirty);
|
|
1650
|
-
const publish_accessibility = previous.focused_id != next.focused_id;
|
|
1776
|
+
const publish_accessibility = previous.focused_id != next.focused_id or previous.keyboard_active != next.keyboard_active;
|
|
1651
1777
|
_ = try runtime_canvas_widget_display.RuntimeCanvasWidgetDisplay(Runtime).refreshCanvasWidgetDisplayListIfOwnedWithAccessibility(self, view_index, publish_accessibility);
|
|
1652
1778
|
}
|
|
1653
1779
|
|
|
@@ -1665,6 +1791,7 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1665
1791
|
pub fn canvasWidgetRenderStateAfterLayout(previous: canvas.WidgetRenderState, layout: canvas.WidgetLayoutTree) canvas.WidgetRenderState {
|
|
1666
1792
|
const next_focused_id = if (previous.focused_id) |id| if (layout.focusTargetById(id) != null) id else null else null;
|
|
1667
1793
|
return .{
|
|
1794
|
+
.keyboard_active = previous.keyboard_active,
|
|
1668
1795
|
.focused_id = next_focused_id,
|
|
1669
1796
|
.focus_visible_id = if (previous.focus_visible_id) |id| if (next_focused_id != null and next_focused_id.? == id and layout.focusTargetById(id) != null) id else null else null,
|
|
1670
1797
|
.hovered_id = if (previous.hovered_id) |id| if (canvasWidgetInteractionTargetExists(layout, id)) id else null else null,
|
|
@@ -1676,7 +1803,8 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1676
1803
|
}
|
|
1677
1804
|
|
|
1678
1805
|
pub fn canvasWidgetRenderStatesEqual(a: canvas.WidgetRenderState, b: canvas.WidgetRenderState) bool {
|
|
1679
|
-
return a.
|
|
1806
|
+
return a.keyboard_active == b.keyboard_active and
|
|
1807
|
+
a.focused_id == b.focused_id and
|
|
1680
1808
|
a.focus_visible_id == b.focus_visible_id and
|
|
1681
1809
|
a.hovered_id == b.hovered_id and
|
|
1682
1810
|
a.pressed_id == b.pressed_id and
|
|
@@ -1775,7 +1903,7 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1775
1903
|
const index = runtimeFindViewIndex(self, pointer_event.window_id, pointer_event.view_label) orelse return;
|
|
1776
1904
|
if (self.views[index].kind != .gpu_surface) return;
|
|
1777
1905
|
|
|
1778
|
-
const dirty = try self.views[index].applyCanvasWidgetScrollRoute(pointer_event.route, pointer_event.pointer.delta
|
|
1906
|
+
const dirty = try self.views[index].applyCanvasWidgetScrollRoute(pointer_event.route, pointer_event.pointer.delta, .wheel) orelse return;
|
|
1779
1907
|
const previous_cursor = self.views[index].canvas_widget_cursor;
|
|
1780
1908
|
try reconcileCanvasWidgetRenderStateAfterScrollWithTooltipIntent(self, index, pointer_event.pointer.point);
|
|
1781
1909
|
if (previous_cursor != self.views[index].canvas_widget_cursor) try syncCanvasWidgetCursorForView(self, index);
|
|
@@ -1796,12 +1924,13 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1796
1924
|
/// - cut: copy, then stamp a delete-selection edit onto the routed
|
|
1797
1925
|
/// keyboard event so runtime widget and app model apply the same
|
|
1798
1926
|
/// removal.
|
|
1799
|
-
/// - paste:
|
|
1800
|
-
/// for
|
|
1801
|
-
///
|
|
1802
|
-
///
|
|
1803
|
-
///
|
|
1804
|
-
///
|
|
1927
|
+
/// - paste: a terminal target becomes provenance-tagged committed
|
|
1928
|
+
/// input for its dedicated VT paste encoder; editable text reads
|
|
1929
|
+
/// the clipboard into `paste_buffer`, sanitizes it for the target
|
|
1930
|
+
/// kind and THEN clamps to the view's text capacity (setting
|
|
1931
|
+
/// `edit_truncated` loudly) — order matters: clamping first would
|
|
1932
|
+
/// spend capacity on line-break bytes the seam strips anyway —
|
|
1933
|
+
/// and stamps the insertion onto the routed keyboard event.
|
|
1805
1934
|
///
|
|
1806
1935
|
/// Platforms without a clipboard capability report
|
|
1807
1936
|
/// `UnsupportedService`; the shortcut degrades to a no-op instead
|
|
@@ -1840,6 +1969,28 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1840
1969
|
const target = event.target orelse return;
|
|
1841
1970
|
const node_index = self.views[index].canvasWidgetNodeIndexById(target.id) orelse return;
|
|
1842
1971
|
const widget = self.views[index].widget_layout_nodes[node_index].widget;
|
|
1972
|
+
if (widget.kind == .terminal and !widget.state.disabled and widget.terminal.pty != 0) {
|
|
1973
|
+
// A terminal paste is committed input, but it must
|
|
1974
|
+
// stay distinct from typing: the session's paste
|
|
1975
|
+
// encoder owns bracketed-paste framing, newline
|
|
1976
|
+
// conversion, and unsafe-control stripping. Shape
|
|
1977
|
+
// the shortcut exactly like context-menu Paste.
|
|
1978
|
+
const focused_id = event.keyboard.focused_id;
|
|
1979
|
+
event.keyboard = .{ .phase = .text_input, .focused_id = focused_id };
|
|
1980
|
+
event.terminal_paste = true;
|
|
1981
|
+
self.views[index].canvas_widget_terminal_paste_v_held = true;
|
|
1982
|
+
|
|
1983
|
+
// Mark the shortcut as consumed before touching
|
|
1984
|
+
// the clipboard. An unavailable/empty clipboard
|
|
1985
|
+
// must not turn Cmd+V into a key sent to the child.
|
|
1986
|
+
const grid = widget.terminal.grid orelse return;
|
|
1987
|
+
if (!grid.running) return;
|
|
1988
|
+
const text = self.readClipboard(paste_buffer) catch return;
|
|
1989
|
+
if (text.len == 0) return;
|
|
1990
|
+
event.keyboard.text = text;
|
|
1991
|
+
event.keyboard.edit = .{ .insert_text = text };
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1843
1994
|
if (!canvas_widget_runtime.canvasWidgetEditableTextKind(widget.kind) or widget.state.disabled) return;
|
|
1844
1995
|
// An empty or unavailable clipboard pastes nothing.
|
|
1845
1996
|
const text = self.readClipboard(paste_buffer) catch return;
|
|
@@ -1929,6 +2080,11 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1929
2080
|
}
|
|
1930
2081
|
}
|
|
1931
2082
|
if (target_id == 0) return;
|
|
2083
|
+
const target_index = self.views[index].canvasWidgetNodeIndexById(target_id) orelse return;
|
|
2084
|
+
const target_widget = self.views[index].widget_layout_nodes[target_index].widget;
|
|
2085
|
+
const mirrors_editable_selection =
|
|
2086
|
+
canvas_widget_runtime.canvasWidgetEditableTextKind(target_widget.kind) and
|
|
2087
|
+
!target_widget.state.disabled;
|
|
1932
2088
|
|
|
1933
2089
|
// The search field's built-in clear affordance: a press
|
|
1934
2090
|
// inside the trailing clear region clears through the
|
|
@@ -1947,8 +2103,29 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
1947
2103
|
pointer_event.pointer.point,
|
|
1948
2104
|
pointer_event.pointer.phase == .move,
|
|
1949
2105
|
pointer_event.pointer.click_count,
|
|
1950
|
-
)
|
|
1951
|
-
|
|
2106
|
+
);
|
|
2107
|
+
// Pointer placement lives first in the retained editor, but a
|
|
2108
|
+
// controlled field's model owns the TextBuffer that the next
|
|
2109
|
+
// keyboard edit will reduce. Stamp the resulting selection
|
|
2110
|
+
// onto the SAME pointer event so `UiApp` delivers
|
|
2111
|
+
// `.set_selection` through `on_input` before a later delete,
|
|
2112
|
+
// insert, or IME edit reaches that model. Without this echo,
|
|
2113
|
+
// the highlight was honest only in the runtime: selecting a
|
|
2114
|
+
// middle span and pressing Backspace let the model delete at
|
|
2115
|
+
// its stale end caret, and its rebuild overwrote the runtime's
|
|
2116
|
+
// correct optimistic edit.
|
|
2117
|
+
//
|
|
2118
|
+
// Stamp even when the retained state did not change. This is
|
|
2119
|
+
// the pointer counterpart of keyboard clear's resync rule: a
|
|
2120
|
+
// divergent model mirror must still hear the selection the
|
|
2121
|
+
// user established.
|
|
2122
|
+
if (mirrors_editable_selection) {
|
|
2123
|
+
const edited_widget = self.views[index].widget_layout_nodes[target_index].widget;
|
|
2124
|
+
const selection = edited_widget.text_selection orelse canvas.TextSelection.collapsed(edited_widget.text.len);
|
|
2125
|
+
pointer_event.edit = .{ .set_selection = selection };
|
|
2126
|
+
}
|
|
2127
|
+
const dirty_bounds = dirty orelse return;
|
|
2128
|
+
if (canvasDirtyRegionForView(self.views[index].frame, dirty_bounds)) |dirty_region| {
|
|
1952
2129
|
self.invalidateFor(.state, dirty_region);
|
|
1953
2130
|
} else {
|
|
1954
2131
|
self.invalidateFor(.state, self.views[index].frame);
|
|
@@ -2162,6 +2339,40 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2162
2339
|
try dispatchCanvasWidgetCommandForId(self, app, index, target.id);
|
|
2163
2340
|
}
|
|
2164
2341
|
|
|
2342
|
+
/// Returns true for an auto-repeat or release belonging to the
|
|
2343
|
+
/// physical Tab gesture that moved focus into a live terminal.
|
|
2344
|
+
/// The caller suppresses that transition; the release also
|
|
2345
|
+
/// retires the gesture latch.
|
|
2346
|
+
pub fn consumeCanvasWidgetTerminalFocusEntryTab(self: *Runtime, input_event: GpuSurfaceInputEvent) bool {
|
|
2347
|
+
if (input_event.kind != .key_down and input_event.kind != .key_up) return false;
|
|
2348
|
+
if (!std.ascii.eqlIgnoreCase(input_event.key, "tab")) return false;
|
|
2349
|
+
const index = runtimeFindViewIndex(self, input_event.window_id, input_event.label) orelse return false;
|
|
2350
|
+
if (self.views[index].kind != .gpu_surface) return false;
|
|
2351
|
+
if (!self.views[index].canvas_widget_terminal_focus_entry_tab_held) return false;
|
|
2352
|
+
if (input_event.kind == .key_up) {
|
|
2353
|
+
self.views[index].canvas_widget_terminal_focus_entry_tab_held = false;
|
|
2354
|
+
}
|
|
2355
|
+
return true;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
/// Consume the physical V release paired with a terminal Paste
|
|
2359
|
+
/// shortcut. Modifier flags describe the release instant, not
|
|
2360
|
+
/// the original key-down: Command/Ctrl may already be up, so the
|
|
2361
|
+
/// key-down classification is latched on the view instead of
|
|
2362
|
+
/// reconstructed here. A fresh V down retires a stale latch
|
|
2363
|
+
/// first (native menu Paste synthesizes a down with no release);
|
|
2364
|
+
/// the clipboard pass later in this input cycle re-arms it when
|
|
2365
|
+
/// that fresh down is another terminal Paste.
|
|
2366
|
+
pub fn consumeCanvasWidgetTerminalPasteKeyLifetime(self: *Runtime, input_event: GpuSurfaceInputEvent) bool {
|
|
2367
|
+
if (input_event.kind != .key_down and input_event.kind != .key_up) return false;
|
|
2368
|
+
if (!std.ascii.eqlIgnoreCase(input_event.key, "v")) return false;
|
|
2369
|
+
const index = runtimeFindViewIndex(self, input_event.window_id, input_event.label) orelse return false;
|
|
2370
|
+
if (self.views[index].kind != .gpu_surface) return false;
|
|
2371
|
+
if (!self.views[index].canvas_widget_terminal_paste_v_held) return false;
|
|
2372
|
+
self.views[index].canvas_widget_terminal_paste_v_held = false;
|
|
2373
|
+
return input_event.kind == .key_up;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2165
2376
|
/// Returns true when the key moved keyboard focus to a DIFFERENT
|
|
2166
2377
|
/// widget — the caller stamps it onto the routed keyboard event
|
|
2167
2378
|
/// (`focus_moved`) so tree rows can tell selection-follows-focus
|
|
@@ -2172,17 +2383,40 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2172
2383
|
if (self.views[index].kind != .gpu_surface) return false;
|
|
2173
2384
|
|
|
2174
2385
|
const current_id: ?canvas.ObjectId = if (self.views[index].canvas_widget_focused_id == 0) null else self.views[index].canvas_widget_focused_id;
|
|
2386
|
+
const layout = self.views[index].widgetLayoutTree();
|
|
2175
2387
|
if (std.ascii.eqlIgnoreCase(input_event.key, "tab")) {
|
|
2388
|
+
// A terminal owns Tab as INPUT (completion, indentation,
|
|
2389
|
+
// and TUI navigation), not as focus traversal. Decide
|
|
2390
|
+
// against the pre-key focus before choosing the next
|
|
2391
|
+
// target: the routed keyboard pass below will therefore
|
|
2392
|
+
// address this same terminal and its emulator can encode
|
|
2393
|
+
// Tab/Shift+Tab for the pty. Disabled/hidden terminals
|
|
2394
|
+
// cannot occupy the focus register because
|
|
2395
|
+
// focusTargetById rejects them, so stale focus still
|
|
2396
|
+
// falls through to the ordinary traversal repair.
|
|
2397
|
+
if (current_id) |id| {
|
|
2398
|
+
if (layout.focusTargetById(id)) |current| {
|
|
2399
|
+
if (canvasWidgetTerminalOwnsTabInput(layout, current)) return false;
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2176
2402
|
const direction: canvas.WidgetFocusDirection = if (input_event.modifiers.shift) .backward else .forward;
|
|
2177
2403
|
const target = if (current_id) |id|
|
|
2178
|
-
self.views[index].canvasWidgetScopedFocusTarget(id, direction) orelse
|
|
2404
|
+
self.views[index].canvasWidgetScopedFocusTarget(id, direction) orelse layout.focusTarget(current_id, direction) orelse return false
|
|
2179
2405
|
else
|
|
2180
|
-
|
|
2181
|
-
|
|
2406
|
+
layout.focusTarget(current_id, direction) orelse return false;
|
|
2407
|
+
const moved = try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id);
|
|
2408
|
+
if (moved and canvasWidgetTerminalOwnsTabInput(layout, target)) {
|
|
2409
|
+
// The key-down moved focus INTO this live terminal;
|
|
2410
|
+
// it is traversal, not terminal input. Hold that
|
|
2411
|
+
// classification through auto-repeat and key-up so
|
|
2412
|
+
// the same physical gesture cannot leak a Tab press
|
|
2413
|
+
// (legacy) or orphan release (kitty) into the pty.
|
|
2414
|
+
self.views[index].canvas_widget_terminal_focus_entry_tab_held = true;
|
|
2415
|
+
}
|
|
2416
|
+
return moved;
|
|
2182
2417
|
}
|
|
2183
2418
|
|
|
2184
2419
|
const focused_id = current_id orelse return false;
|
|
2185
|
-
const layout = self.views[index].widgetLayoutTree();
|
|
2186
2420
|
const focused = layout.focusTargetById(focused_id) orelse return false;
|
|
2187
2421
|
// FRAMEWORK BEHAVIOR CHANGE (deliberate, scoped — the same
|
|
2188
2422
|
// seam as the keyboard-routing gate below): arrows and
|
|
@@ -2315,6 +2549,14 @@ fn runtimeFindViewIndex(self: anytype, window_id: platform.WindowId, label: []co
|
|
|
2315
2549
|
return null;
|
|
2316
2550
|
}
|
|
2317
2551
|
|
|
2552
|
+
fn canvasWidgetTerminalOwnsTabInput(layout: canvas.WidgetLayoutTree, target: canvas.WidgetFocusTarget) bool {
|
|
2553
|
+
if (target.kind != .terminal or target.index >= layout.nodes.len) return false;
|
|
2554
|
+
const terminal = layout.nodes[target.index].widget.terminal;
|
|
2555
|
+
if (terminal.pty == 0) return false;
|
|
2556
|
+
const grid = terminal.grid orelse return false;
|
|
2557
|
+
return grid.running;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2318
2560
|
fn canvasDirtyRegionForView(view_frame: geometry.RectF, local_dirty: geometry.RectF) ?geometry.RectF {
|
|
2319
2561
|
const normalized_view = view_frame.normalized();
|
|
2320
2562
|
const surface_bounds = geometry.RectF.init(0, 0, normalized_view.width, normalized_view.height);
|