@native-sdk/cli 0.6.1 → 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/native-sdk.d.ts +16 -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/app_runner/root.zig +19 -0
- package/src/platform/linux/gtk_host.c +167 -8
- package/src/platform/linux/gtk_host.h +3 -2
- package/src/platform/linux/root.zig +198 -9
- package/src/platform/macos/appkit_host.h +4 -2
- package/src/platform/macos/appkit_host.m +137 -38
- package/src/platform/macos/cef_host.mm +46 -11
- package/src/platform/macos/root.zig +150 -6
- package/src/platform/null_platform.zig +32 -4
- package/src/platform/types.zig +31 -4
- package/src/platform/windows/root.zig +220 -10
- package/src/platform/windows/webview2_host.cpp +330 -31
- package/src/primitives/app_manifest/comptime_scene.zig +4 -0
- package/src/primitives/app_manifest/types.zig +16 -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_render.zig +21 -2
- package/src/primitives/canvas/widget_runtime.zig +1 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +51 -0
- package/src/primitives/canvas/widget_text_input.zig +23 -11
- package/src/runtime/api.zig +9 -0
- package/src/runtime/bridge_payload.zig +9 -0
- package/src/runtime/bridge_responses.zig +2 -0
- package/src/runtime/builtin_bridge.zig +10 -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_floating_tests.zig +3 -3
- 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/effects.zig +5 -6
- package/src/runtime/flow.zig +45 -7
- package/src/runtime/gpu_surface_events.zig +46 -1
- package/src/runtime/runtime_event_tests.zig +9 -6
- package/src/runtime/shell_layout.zig +25 -11
- package/src/runtime/shell_layout_tests.zig +184 -0
- package/src/runtime/shell_view_tests.zig +9 -7
- package/src/runtime/state.zig +6 -0
- package/src/runtime/ui_app.zig +61 -14
- package/src/runtime/ui_app_window_tests.zig +107 -2
- 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
- package/src/runtime/window_command_bridge_tests.zig +82 -6
- package/src/runtime/window_storage.zig +14 -3
- package/src/runtime/window_views.zig +12 -11
- package/src/tooling/manifest.zig +38 -2
- package/src/tooling/raw_manifest.zig +8 -0
- package/src/tooling/templates.zig +17 -0
|
@@ -5,6 +5,7 @@ const platform = @import("../platform/root.zig");
|
|
|
5
5
|
const validation = @import("validation.zig");
|
|
6
6
|
const runtime_api = @import("api.zig");
|
|
7
7
|
const runtime_view = @import("view.zig");
|
|
8
|
+
const view_widget_text = @import("view_widget_text.zig");
|
|
8
9
|
const canvas_limits = @import("canvas_limits.zig");
|
|
9
10
|
const canvas_frame_helpers = @import("canvas_frame.zig");
|
|
10
11
|
const canvas_widget_runtime = @import("canvas_widget_runtime.zig");
|
|
@@ -41,6 +42,7 @@ pub fn RuntimeCanvasWidgetDisplay(comptime Runtime: type) type {
|
|
|
41
42
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
42
43
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
43
44
|
if (!std.meta.eql(self.views[index].widget_tokens, tokens)) {
|
|
45
|
+
self.views[index].clearCanvasWidgetTextVerticalGoal();
|
|
44
46
|
self.views[index].widget_tokens = tokens;
|
|
45
47
|
self.views[index].widget_revision += 1;
|
|
46
48
|
}
|
|
@@ -213,6 +215,14 @@ pub fn RuntimeCanvasWidgetDisplay(comptime Runtime: type) type {
|
|
|
213
215
|
const semantics = view.widgetSemantics();
|
|
214
216
|
const count = @min(semantics.len, nodes.len);
|
|
215
217
|
for (semantics[0..count], 0..) |node, index| {
|
|
218
|
+
const focused = node.state.focused or (view.keyboard_active and view.focused and node.id == view.canvas_widget_focused_id);
|
|
219
|
+
// Native menu validation only consults the focused editor.
|
|
220
|
+
// Resolving history for that one node also avoids searching
|
|
221
|
+
// the retained layout once per accessibility node.
|
|
222
|
+
const history = if (focused)
|
|
223
|
+
view.canvasWidgetTextHistoryAvailability(node.id)
|
|
224
|
+
else
|
|
225
|
+
view_widget_text.CanvasWidgetTextHistoryAvailability{};
|
|
216
226
|
nodes[index] = .{
|
|
217
227
|
.id = node.id,
|
|
218
228
|
.parent_id = canvasWidgetSemanticParentId(semantics, node.parent_index),
|
|
@@ -234,7 +244,7 @@ pub fn RuntimeCanvasWidgetDisplay(comptime Runtime: type) type {
|
|
|
234
244
|
.scroll_viewport_extent = if (node.scroll.present) node.scroll.viewport_extent else null,
|
|
235
245
|
.scroll_content_extent = if (node.scroll.present) node.scroll.content_extent else null,
|
|
236
246
|
.enabled = !node.state.disabled,
|
|
237
|
-
.focused =
|
|
247
|
+
.focused = focused,
|
|
238
248
|
.hovered = node.state.hovered or (node.id != 0 and node.id == view.canvas_widget_hovered_id),
|
|
239
249
|
.pressed = node.state.pressed or (node.id != 0 and node.id == view.canvas_widget_pressed_id),
|
|
240
250
|
.selected = canvasWidgetSelectedState(node),
|
|
@@ -242,6 +252,8 @@ pub fn RuntimeCanvasWidgetDisplay(comptime Runtime: type) type {
|
|
|
242
252
|
.required = node.state.required,
|
|
243
253
|
.read_only = node.state.read_only,
|
|
244
254
|
.invalid = node.state.invalid,
|
|
255
|
+
.can_undo = history.can_undo,
|
|
256
|
+
.can_redo = history.can_redo,
|
|
245
257
|
.focusable = node.focusable,
|
|
246
258
|
.actions = platformWidgetAccessibilityActions(node.actions),
|
|
247
259
|
};
|
|
@@ -594,6 +606,8 @@ fn hashWidgetAccessibilityNodes(nodes: []const platform.WidgetAccessibilityNode)
|
|
|
594
606
|
hashAccessibilityValue(&hasher, node.required);
|
|
595
607
|
hashAccessibilityValue(&hasher, node.read_only);
|
|
596
608
|
hashAccessibilityValue(&hasher, node.invalid);
|
|
609
|
+
hashAccessibilityValue(&hasher, node.can_undo);
|
|
610
|
+
hashAccessibilityValue(&hasher, node.can_redo);
|
|
597
611
|
hashAccessibilityValue(&hasher, node.focusable);
|
|
598
612
|
inline for (comptime std.meta.fieldNames(platform.WidgetAccessibilityActions)) |field_name| {
|
|
599
613
|
hashAccessibilityValue(&hasher, @field(node.actions, field_name));
|
|
@@ -2020,7 +2020,7 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2020
2020
|
/// and clear-button stamping precedent, made the rule). Before
|
|
2021
2021
|
/// the stamp, edits that only THIS derivation produced — Escape's
|
|
2022
2022
|
/// search-field clear, Escape's composition cancel, the
|
|
2023
|
-
///
|
|
2023
|
+
/// runtime's geometry-aware ArrowUp/Down caret jumps — mutated the editor
|
|
2024
2024
|
/// while the app-side dispatch re-derived the key on its own and
|
|
2025
2025
|
/// heard nothing: the field visibly cleared while `model.query`
|
|
2026
2026
|
/// kept the stale term, and the next keystroke dispatched
|
|
@@ -2031,27 +2031,50 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2031
2031
|
const index = runtimeFindViewIndex(self, keyboard_event.window_id, keyboard_event.view_label) orelse return;
|
|
2032
2032
|
if (self.views[index].kind != .gpu_surface) return;
|
|
2033
2033
|
const target = keyboard_event.target orelse return;
|
|
2034
|
-
const
|
|
2035
|
-
|
|
2034
|
+
const history_shortcut = if (!keyboard_event.history_replay)
|
|
2035
|
+
self.views[index].canvasWidgetTextHistoryShortcut(target, keyboard_event.keyboard)
|
|
2036
|
+
else
|
|
2037
|
+
null;
|
|
2038
|
+
const derived = if (history_shortcut) |shortcut|
|
|
2039
|
+
shortcut.edit
|
|
2040
|
+
else
|
|
2041
|
+
self.views[index].canvasWidgetKeyboardTextEdit(target, keyboard_event.keyboard) orelse return;
|
|
2042
|
+
if (history_shortcut) |shortcut| {
|
|
2043
|
+
keyboard_event.history_replay = true;
|
|
2044
|
+
keyboard_event.history_replay_serial = shortcut.serial;
|
|
2045
|
+
keyboard_event.history_replay_redo = shortcut.redo;
|
|
2046
|
+
}
|
|
2047
|
+
// New single-line input is sanitized HERE — after derivation,
|
|
2036
2048
|
// BEFORE the stamp — so the retained editor and the app's
|
|
2037
|
-
// `on_input` mirror hear byte-identical sanitized inserts
|
|
2038
|
-
//
|
|
2039
|
-
//
|
|
2040
|
-
//
|
|
2041
|
-
//
|
|
2042
|
-
//
|
|
2043
|
-
//
|
|
2044
|
-
//
|
|
2045
|
-
//
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2049
|
+
// `on_input` mirror hear byte-identical sanitized inserts.
|
|
2050
|
+
// Clipboard paste, typed and automation text_input, and IME
|
|
2051
|
+
// composition all flow through this seam. History replay is
|
|
2052
|
+
// the deliberate exception below: its payload is retained
|
|
2053
|
+
// state rather than new input.
|
|
2054
|
+
// History payloads are retained bytes, not new user input:
|
|
2055
|
+
// replay them exactly so Undo can restore a model-provided
|
|
2056
|
+
// single-line value that contains raw line breaks. Every
|
|
2057
|
+
// non-history insertion still crosses the sanitizer below.
|
|
2058
|
+
const edit = if (keyboard_event.history_replay)
|
|
2059
|
+
derived
|
|
2060
|
+
else
|
|
2061
|
+
canvas.sanitizedSingleLineTextInputEvent(target.kind, derived) orelse {
|
|
2062
|
+
keyboard_event.keyboard.edit = null;
|
|
2063
|
+
return;
|
|
2064
|
+
};
|
|
2052
2065
|
keyboard_event.keyboard.edit = edit;
|
|
2053
2066
|
|
|
2054
|
-
const dirty =
|
|
2067
|
+
const dirty = if (keyboard_event.history_replay)
|
|
2068
|
+
try self.views[index].applyCanvasWidgetTextEditWithoutHistory(target.id, edit) orelse return
|
|
2069
|
+
else
|
|
2070
|
+
try self.views[index].applyCanvasWidgetTextEdit(target.id, edit) orelse return;
|
|
2071
|
+
if (keyboard_event.history_replay) {
|
|
2072
|
+
self.views[index].commitCanvasWidgetTextHistoryReplayIfComplete(
|
|
2073
|
+
target,
|
|
2074
|
+
keyboard_event.history_replay_serial,
|
|
2075
|
+
keyboard_event.history_replay_redo,
|
|
2076
|
+
);
|
|
2077
|
+
}
|
|
2055
2078
|
if (canvasDirtyRegionForView(self.views[index].frame, dirty)) |dirty_region| {
|
|
2056
2079
|
self.invalidateFor(.state, dirty_region);
|
|
2057
2080
|
} else {
|
|
@@ -2102,6 +2125,7 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2102
2125
|
target_id,
|
|
2103
2126
|
pointer_event.pointer.point,
|
|
2104
2127
|
pointer_event.pointer.phase == .move,
|
|
2128
|
+
pointer_event.pointer.phase == .down and pointer_event.pointer.modifiers.shift,
|
|
2105
2129
|
pointer_event.pointer.click_count,
|
|
2106
2130
|
);
|
|
2107
2131
|
// Pointer placement lives first in the retained editor, but a
|
|
@@ -3214,7 +3214,7 @@ test "window key-loss hides tooltips in that window's views only, re-key reveals
|
|
|
3214
3214
|
const toolbar = try installTooltipToolbar(harness, app, arena.allocator());
|
|
3215
3215
|
|
|
3216
3216
|
// A second window with its own canvas view and a delay-0 tooltip.
|
|
3217
|
-
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools" });
|
|
3217
|
+
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools", .activate_on_show = false });
|
|
3218
3218
|
_ = try harness.runtime.createView(.{
|
|
3219
3219
|
.window_id = second.id,
|
|
3220
3220
|
.label = "canvas",
|
|
@@ -3287,7 +3287,7 @@ test "window key-loss announced loss-first (Windows/GTK ordering) hides the tool
|
|
|
3287
3287
|
|
|
3288
3288
|
// A second window with its own canvas view and a delay-0 tooltip,
|
|
3289
3289
|
// exactly like the gain-only key-loss test above.
|
|
3290
|
-
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools" });
|
|
3290
|
+
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools", .activate_on_show = false });
|
|
3291
3291
|
_ = try harness.runtime.createView(.{
|
|
3292
3292
|
.window_id = second.id,
|
|
3293
3293
|
.label = "canvas",
|
|
@@ -3452,7 +3452,7 @@ test "a tooltip mounting beneath a non-key window's hovered trigger reveals and
|
|
|
3452
3452
|
|
|
3453
3453
|
// A second window with its own canvas view and a bare trigger; the
|
|
3454
3454
|
// startup window keeps key throughout the mount.
|
|
3455
|
-
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools" });
|
|
3455
|
+
const second = try harness.runtime.createWindow(.{ .label = "tools", .title = "Tools", .activate_on_show = false });
|
|
3456
3456
|
_ = try harness.runtime.createView(.{
|
|
3457
3457
|
.window_id = second.id,
|
|
3458
3458
|
.label = "canvas",
|
|
@@ -151,6 +151,12 @@ pub const CanvasWidgetTextReconcileEntry = struct {
|
|
|
151
151
|
text: []const u8 = &.{},
|
|
152
152
|
source_text_len: usize = 0,
|
|
153
153
|
source_text_hash: u64 = 0,
|
|
154
|
+
/// The selection declared by the previous SOURCE tree, distinct from
|
|
155
|
+
/// the runtime-owned selection in `text_selection`. Legacy controlled
|
|
156
|
+
/// models always materialize the default `.upstream` affinity, so an
|
|
157
|
+
/// unchanged source affinity is an echo; a changed affinity is an
|
|
158
|
+
/// explicit source-side visual-caret move.
|
|
159
|
+
source_text_selection: ?canvas.TextSelection = null,
|
|
154
160
|
text_selection: ?canvas.TextSelection = null,
|
|
155
161
|
text_composition: ?canvas.TextRange = null,
|
|
156
162
|
value: f32 = 0,
|
|
@@ -246,6 +252,7 @@ pub const CanvasWidgetSourceTextEntry = struct {
|
|
|
246
252
|
kind: canvas.WidgetKind = .text_field,
|
|
247
253
|
text_len: usize = 0,
|
|
248
254
|
text_hash: u64 = 0,
|
|
255
|
+
text_selection: ?canvas.TextSelection = null,
|
|
249
256
|
};
|
|
250
257
|
|
|
251
258
|
/// The SOURCE-side selected state (and value, for sliders) of one
|
|
@@ -588,13 +595,18 @@ pub fn collectCanvasWidgetTextReconcileEntries(
|
|
|
588
595
|
if (node.widget.id == 0 or !canvasWidgetTextReconcileKind(node.widget)) continue;
|
|
589
596
|
if (len >= output.len) break;
|
|
590
597
|
const text_range = try appendWidgetTextStorageRange(text_storage, text_len, node.widget.text);
|
|
591
|
-
const
|
|
598
|
+
const source_entry = canvasWidgetSourceTextEntryByIdKind(source_entries, node.widget.id, node.widget.kind);
|
|
599
|
+
const source_text = if (source_entry) |entry|
|
|
600
|
+
CanvasWidgetSourceTextFingerprint{ .len = entry.text_len, .hash = entry.text_hash }
|
|
601
|
+
else
|
|
602
|
+
canvasWidgetSourceTextFingerprint(node.widget.text);
|
|
592
603
|
output[len] = .{
|
|
593
604
|
.id = node.widget.id,
|
|
594
605
|
.kind = node.widget.kind,
|
|
595
606
|
.text = text_storage[text_range.start..text_range.end],
|
|
596
607
|
.source_text_len = source_text.len,
|
|
597
608
|
.source_text_hash = source_text.hash,
|
|
609
|
+
.source_text_selection = if (source_entry) |entry| entry.text_selection else null,
|
|
598
610
|
.text_selection = node.widget.text_selection,
|
|
599
611
|
.text_composition = node.widget.text_composition,
|
|
600
612
|
.value = node.widget.value,
|
|
@@ -632,12 +644,21 @@ pub fn canvasWidgetSourceTextByIdKind(
|
|
|
632
644
|
id: canvas.ObjectId,
|
|
633
645
|
kind: canvas.WidgetKind,
|
|
634
646
|
) ?CanvasWidgetSourceTextFingerprint {
|
|
647
|
+
const entry = canvasWidgetSourceTextEntryByIdKind(entries, id, kind) orelse return null;
|
|
648
|
+
return .{
|
|
649
|
+
.len = entry.text_len,
|
|
650
|
+
.hash = entry.text_hash,
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
fn canvasWidgetSourceTextEntryByIdKind(
|
|
655
|
+
entries: []const CanvasWidgetSourceTextEntry,
|
|
656
|
+
id: canvas.ObjectId,
|
|
657
|
+
kind: canvas.WidgetKind,
|
|
658
|
+
) ?CanvasWidgetSourceTextEntry {
|
|
635
659
|
for (entries) |entry| {
|
|
636
660
|
if (entry.id != id or entry.kind != kind) continue;
|
|
637
|
-
return
|
|
638
|
-
.len = entry.text_len,
|
|
639
|
-
.hash = entry.text_hash,
|
|
640
|
-
};
|
|
661
|
+
return entry;
|
|
641
662
|
}
|
|
642
663
|
return null;
|
|
643
664
|
}
|
|
@@ -755,8 +776,10 @@ pub fn canvasWidgetLayoutNodeWithTextReconcileState(
|
|
|
755
776
|
previous: *const CanvasWidgetTextEntryIndex,
|
|
756
777
|
) canvas.WidgetLayoutNode {
|
|
757
778
|
var copy = node;
|
|
758
|
-
if (copy.widget.id == 0) return copy;
|
|
759
|
-
if (copy.widget.state.disabled or canvasWidgetLayoutNodeHidden(layout, node_index))
|
|
779
|
+
if (copy.widget.id == 0) return canvasWidgetLayoutNodeWithCaretSafeSelection(copy);
|
|
780
|
+
if (copy.widget.state.disabled or canvasWidgetLayoutNodeHidden(layout, node_index)) {
|
|
781
|
+
return canvasWidgetLayoutNodeWithCaretSafeSelection(copy);
|
|
782
|
+
}
|
|
760
783
|
|
|
761
784
|
if (copy.widget.kind == .text) {
|
|
762
785
|
// Static text selections survive rebuilds only while the source
|
|
@@ -766,7 +789,7 @@ pub fn canvasWidgetLayoutNodeWithTextReconcileState(
|
|
|
766
789
|
copy.widget.text_selection = entry.text_selection;
|
|
767
790
|
}
|
|
768
791
|
}
|
|
769
|
-
return copy;
|
|
792
|
+
return canvasWidgetLayoutNodeWithCaretSafeSelection(copy);
|
|
770
793
|
}
|
|
771
794
|
if (!canvasWidgetEditableTextKind(copy.widget.kind)) return copy;
|
|
772
795
|
|
|
@@ -780,7 +803,9 @@ pub fn canvasWidgetLayoutNodeWithTextReconcileState(
|
|
|
780
803
|
const next_source_text = canvasWidgetSourceTextFingerprint(copy.widget.text);
|
|
781
804
|
const source_unchanged = entry.source_text_len == next_source_text.len and entry.source_text_hash == next_source_text.hash;
|
|
782
805
|
const source_matches_runtime_text = std.mem.eql(u8, entry.text, copy.widget.text);
|
|
783
|
-
if (!source_unchanged and !source_matches_runtime_text)
|
|
806
|
+
if (!source_unchanged and !source_matches_runtime_text) {
|
|
807
|
+
return canvasWidgetLayoutNodeWithCaretSafeSelection(copy);
|
|
808
|
+
}
|
|
784
809
|
if (source_unchanged) copy.widget.text = entry.text;
|
|
785
810
|
// The retained scroll offset rides `value` for every editable
|
|
786
811
|
// text kind: the textarea's vertical offset and the single-line
|
|
@@ -792,8 +817,40 @@ pub fn canvasWidgetLayoutNodeWithTextReconcileState(
|
|
|
792
817
|
if (copy.widget.text_selection == null and copy.widget.text_composition == null) {
|
|
793
818
|
copy.widget.text_selection = entry.text_selection;
|
|
794
819
|
copy.widget.text_composition = entry.text_composition;
|
|
820
|
+
} else if (copy.widget.text_selection) |*source_selection| {
|
|
821
|
+
// Caret affinity is runtime geometry at a byte offset. Core
|
|
822
|
+
// and C-ABI controlled models historically echo only
|
|
823
|
+
// anchor/focus, so the bridge materializes `.upstream` on
|
|
824
|
+
// every rebuild. When those offsets faithfully echo the
|
|
825
|
+
// retained selection, keep the retained visual-line owner;
|
|
826
|
+
// changing either offset remains the source-authoritative
|
|
827
|
+
// way to move the selection.
|
|
828
|
+
if (entry.text_selection) |retained_selection| {
|
|
829
|
+
if (source_selection.anchor == retained_selection.anchor and
|
|
830
|
+
source_selection.focus == retained_selection.focus)
|
|
831
|
+
{
|
|
832
|
+
const source_affinity_changed = if (entry.source_text_selection) |previous_source_selection|
|
|
833
|
+
source_selection.affinity != previous_source_selection.affinity
|
|
834
|
+
else
|
|
835
|
+
// The legacy shape can only materialize upstream;
|
|
836
|
+
// a first downstream value is therefore explicit.
|
|
837
|
+
source_selection.affinity != .upstream;
|
|
838
|
+
if (!source_affinity_changed) {
|
|
839
|
+
source_selection.affinity = retained_selection.affinity;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
795
843
|
}
|
|
796
844
|
}
|
|
845
|
+
return canvasWidgetLayoutNodeWithCaretSafeSelection(copy);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
fn canvasWidgetLayoutNodeWithCaretSafeSelection(node: canvas.WidgetLayoutNode) canvas.WidgetLayoutNode {
|
|
849
|
+
var copy = node;
|
|
850
|
+
if (!canvasWidgetEditableTextKind(copy.widget.kind)) return copy;
|
|
851
|
+
if (copy.widget.text_selection) |selection| {
|
|
852
|
+
copy.widget.text_selection = canvas.snapTextCaretSelection(copy.widget.text, selection);
|
|
853
|
+
}
|
|
797
854
|
return copy;
|
|
798
855
|
}
|
|
799
856
|
|
|
@@ -1174,7 +1231,7 @@ pub fn canvasWidgetTextEditUnchanged(previous: canvas.TextEditState, next: canva
|
|
|
1174
1231
|
}
|
|
1175
1232
|
|
|
1176
1233
|
pub fn canvasTextSelectionsEqual(a: canvas.TextSelection, b: canvas.TextSelection) bool {
|
|
1177
|
-
return a.anchor == b.anchor and a.focus == b.focus;
|
|
1234
|
+
return a.anchor == b.anchor and a.focus == b.focus and a.affinity == b.affinity;
|
|
1178
1235
|
}
|
|
1179
1236
|
|
|
1180
1237
|
pub fn textSelectionCollapsedAt(selection: ?canvas.TextSelection, offset: usize) bool {
|
|
@@ -790,6 +790,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
790
790
|
const index = runtimeFindViewIndex(self, window_id, label) orelse return error.ViewNotFound;
|
|
791
791
|
if (self.views[index].kind != .gpu_surface) return error.InvalidViewOptions;
|
|
792
792
|
if (std.meta.eql(self.views[index].widget_tokens, tokens)) return self.views[index].info();
|
|
793
|
+
self.views[index].clearCanvasWidgetTextVerticalGoal();
|
|
793
794
|
self.views[index].widget_tokens = tokens;
|
|
794
795
|
self.views[index].widget_revision += 1;
|
|
795
796
|
if (self.views[index].canvas_display_list_widget_owned) {
|