@native-sdk/cli 0.6.2 → 0.6.3
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.zig +8 -0
- 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 +62 -21
- package/src/platform/macos/appkit_host.h +2 -0
- package/src/platform/macos/appkit_host.m +36 -10
- package/src/platform/macos/root.zig +7 -1
- package/src/platform/types.zig +2 -0
- package/src/primitives/canvas/equality.zig +3 -1
- package/src/primitives/canvas/events.zig +4 -0
- package/src/primitives/canvas/root.zig +11 -0
- package/src/primitives/canvas/text.zig +10 -0
- package/src/primitives/canvas/text_interaction.zig +164 -22
- package/src/primitives/canvas/text_layout.zig +107 -21
- package/src/primitives/canvas/text_tests.zig +86 -0
- package/src/primitives/canvas/ui.zig +21 -16
- package/src/primitives/canvas/ui_markup_reflect.zig +20 -3
- package/src/primitives/canvas/ui_markup_view_tests.zig +16 -0
- package/src/primitives/canvas/ui_tests.zig +6 -0
- package/src/primitives/canvas/widget_runtime.zig +1 -0
- package/src/primitives/canvas/widget_text_input.zig +23 -11
- package/src/runtime/api.zig +9 -0
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_limits.zig +7 -0
- package/src/runtime/canvas_widget_accessibility_tests.zig +27 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +16 -0
- package/src/runtime/canvas_widget_display.zig +15 -1
- package/src/runtime/canvas_widget_events.zig +43 -19
- package/src/runtime/canvas_widget_runtime.zig +67 -10
- package/src/runtime/canvas_widget_state.zig +1 -0
- package/src/runtime/canvas_widget_text_tests.zig +1878 -70
- package/src/runtime/gpu_surface_events.zig +38 -0
- package/src/runtime/view.zig +30 -0
- package/src/runtime/view_widget_text.zig +1048 -10
- package/src/runtime/view_widget_tree.zig +2 -0
|
@@ -637,6 +637,44 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
637
637
|
if (widget_keyboard_event) |keyboard_event| {
|
|
638
638
|
try CanvasWidgetEventMethods().dispatchCanvasWidgetCommandFromKeyboard(self, app, keyboard_event);
|
|
639
639
|
try self.dispatchEvent(app, .{ .canvas_widget_keyboard = keyboard_event });
|
|
640
|
+
// A logical undo/redo can require select -> replace ->
|
|
641
|
+
// restore-selection. Apply and dispatch each continuation
|
|
642
|
+
// only after the previous on-input Msg rebuilt the
|
|
643
|
+
// controlled tree, keeping runtime and model lockstep at
|
|
644
|
+
// every intermediate state. These synthetic edit carriers
|
|
645
|
+
// are key_down-shaped (not committed text), so a target
|
|
646
|
+
// removed, hidden, or replaced with another editor kind by
|
|
647
|
+
// the rebuild can never receive stale replacement bytes.
|
|
648
|
+
// The route and focus-target snapshot are tree-relative too:
|
|
649
|
+
// re-resolve both after every rebuild so custom event
|
|
650
|
+
// consumers never observe ancestors, indices, bounds, or
|
|
651
|
+
// state from the tree that handled the previous step.
|
|
652
|
+
for (0..2) |_| {
|
|
653
|
+
if (keyboard_event.history_replay_serial == 0) break;
|
|
654
|
+
const view_index = runtimeFindViewIndex(self, keyboard_event.window_id, keyboard_event.view_label) orelse break;
|
|
655
|
+
const target = keyboard_event.target orelse break;
|
|
656
|
+
if (self.views[view_index].kind != .gpu_surface) break;
|
|
657
|
+
const edit = self.views[view_index].canvasWidgetTextHistoryReplayNext(
|
|
658
|
+
target,
|
|
659
|
+
keyboard_event.history_replay_serial,
|
|
660
|
+
keyboard_event.history_replay_redo,
|
|
661
|
+
) orelse break;
|
|
662
|
+
var followup = keyboard_event;
|
|
663
|
+
followup.keyboard = .{
|
|
664
|
+
.phase = .key_down,
|
|
665
|
+
.focused_id = keyboard_event.keyboard.focused_id,
|
|
666
|
+
.edit = edit,
|
|
667
|
+
};
|
|
668
|
+
const route = try self.views[view_index].widgetLayoutTree().routeKeyboardEvent(
|
|
669
|
+
followup.keyboard,
|
|
670
|
+
&self.widget_event_route_entries,
|
|
671
|
+
);
|
|
672
|
+
followup.target = route.target orelse break;
|
|
673
|
+
followup.route = route.entries;
|
|
674
|
+
followup.history_replay = true;
|
|
675
|
+
try CanvasWidgetEventMethods().updateCanvasWidgetTextFromKeyboard(self, &followup);
|
|
676
|
+
try self.dispatchEvent(app, .{ .canvas_widget_keyboard = followup });
|
|
677
|
+
}
|
|
640
678
|
} else if ((input_event.kind == .key_down or input_event.kind == .key_up) and
|
|
641
679
|
!widget_surface_dismissed and !terminal_key_lifetime_suppressed)
|
|
642
680
|
{
|
package/src/runtime/view.zig
CHANGED
|
@@ -31,6 +31,8 @@ const max_canvas_widget_nodes_per_view = canvas_limits.max_canvas_widget_nodes_p
|
|
|
31
31
|
const max_canvas_widget_semantics_per_view = canvas_limits.max_canvas_widget_semantics_per_view;
|
|
32
32
|
const max_canvas_widget_text_bytes_per_view = canvas_limits.max_canvas_widget_text_bytes_per_view;
|
|
33
33
|
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
|
+
const max_canvas_widget_text_history_entries_per_view = canvas_limits.max_canvas_widget_text_history_entries_per_view;
|
|
34
36
|
|
|
35
37
|
const CanvasWidgetSourceTextEntry = canvas_widget_runtime.CanvasWidgetSourceTextEntry;
|
|
36
38
|
const CanvasWidgetSourceScrollEntry = canvas_widget_runtime.CanvasWidgetSourceScrollEntry;
|
|
@@ -750,10 +752,38 @@ pub const RuntimeView = struct {
|
|
|
750
752
|
accessibility_label_storage: [platform.max_view_accessibility_label_bytes]u8 = undefined,
|
|
751
753
|
text_storage: [platform.max_view_text_bytes]u8 = undefined,
|
|
752
754
|
command_storage: [platform.max_view_command_bytes]u8 = undefined,
|
|
755
|
+
/// Per-view, per-widget undo/redo deltas. Kept at the tail so adding
|
|
756
|
+
/// editor history does not move the established hot render/layout
|
|
757
|
+
/// fields inside RuntimeView. Text bytes are shared across entries, so
|
|
758
|
+
/// ordinary typing costs one byte per step rather than a full document
|
|
759
|
+
/// snapshot.
|
|
760
|
+
canvas_widget_text_history_entries: [max_canvas_widget_text_history_entries_per_view]view_widget_text.CanvasWidgetTextHistoryEntry = undefined,
|
|
761
|
+
canvas_widget_text_history_entry_count: usize = 0,
|
|
762
|
+
canvas_widget_text_history_bytes: [max_canvas_widget_text_history_bytes_per_view]u8 = undefined,
|
|
763
|
+
canvas_widget_text_history_byte_count: usize = 0,
|
|
764
|
+
canvas_widget_text_history_next_serial: u64 = 1,
|
|
765
|
+
/// Native textarea Up/Down retains its painted x coordinate while a
|
|
766
|
+
/// consecutive vertical-navigation run crosses shorter visual lines.
|
|
767
|
+
canvas_widget_text_vertical_goal_id: canvas.ObjectId = 0,
|
|
768
|
+
/// Preferred x in widget-local coordinates, so moving a textarea does
|
|
769
|
+
/// not move the logical column with respect to its text container.
|
|
770
|
+
canvas_widget_text_vertical_goal_x: f32 = 0,
|
|
771
|
+
canvas_widget_text_vertical_goal_text_len: usize = 0,
|
|
772
|
+
canvas_widget_text_vertical_goal_text_hash: u64 = 0,
|
|
773
|
+
canvas_widget_text_vertical_goal_focus: usize = 0,
|
|
774
|
+
canvas_widget_text_vertical_goal_affinity: canvas.TextCaretAffinity = .upstream,
|
|
775
|
+
canvas_widget_text_vertical_goal_frame: geometry.RectF = .{},
|
|
753
776
|
|
|
754
777
|
const CanvasWidgetTextMethods = view_widget_text.RuntimeViewCanvasWidgetText(RuntimeView);
|
|
755
778
|
pub const applyCanvasWidgetTextEdit = CanvasWidgetTextMethods.applyCanvasWidgetTextEdit;
|
|
779
|
+
pub const applyCanvasWidgetTextEditWithoutHistory = CanvasWidgetTextMethods.applyCanvasWidgetTextEditWithoutHistory;
|
|
756
780
|
pub const canvasWidgetKeyboardTextEdit = CanvasWidgetTextMethods.canvasWidgetKeyboardTextEdit;
|
|
781
|
+
pub const canvasWidgetTextHistoryShortcut = CanvasWidgetTextMethods.canvasWidgetTextHistoryShortcut;
|
|
782
|
+
pub const canvasWidgetTextHistoryAvailability = CanvasWidgetTextMethods.canvasWidgetTextHistoryAvailability;
|
|
783
|
+
pub const canvasWidgetTextHistoryReplayNext = CanvasWidgetTextMethods.canvasWidgetTextHistoryReplayNext;
|
|
784
|
+
pub const commitCanvasWidgetTextHistoryReplayIfComplete = CanvasWidgetTextMethods.commitCanvasWidgetTextHistoryReplayIfComplete;
|
|
785
|
+
pub const pruneCanvasWidgetTextHistory = CanvasWidgetTextMethods.pruneCanvasWidgetTextHistory;
|
|
786
|
+
pub const clearCanvasWidgetTextVerticalGoal = CanvasWidgetTextMethods.clearCanvasWidgetTextVerticalGoal;
|
|
757
787
|
pub const canEditCanvasWidgetText = CanvasWidgetTextMethods.canEditCanvasWidgetText;
|
|
758
788
|
pub const applyCanvasWidgetTextPointer = CanvasWidgetTextMethods.applyCanvasWidgetTextPointer;
|
|
759
789
|
pub const clearCanvasWidgetStaticTextSelection = CanvasWidgetTextMethods.clearCanvasWidgetStaticTextSelection;
|