@native-sdk/cli 0.6.3 → 0.7.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.zig +65 -91
- 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 +23 -6
- package/src/platform/macos/appkit_host.m +25 -1
- package/src/platform/macos/cef_host.mm +24 -2
- package/src/platform/macos/root.zig +13 -0
- package/src/primitives/canvas/code.zig +1008 -0
- package/src/primitives/canvas/code_tests.zig +1912 -0
- package/src/primitives/canvas/events.zig +111 -1
- package/src/primitives/canvas/layout_audit.zig +3 -1
- package/src/primitives/canvas/markdown.zig +13 -11
- package/src/primitives/canvas/markdown_tests.zig +168 -6
- package/src/primitives/canvas/root.zig +8 -2
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text.zig +6 -0
- package/src/primitives/canvas/text_measure_cache.zig +4 -4
- package/src/primitives/canvas/text_span_tests.zig +254 -0
- package/src/primitives/canvas/text_spans.zig +556 -32
- package/src/primitives/canvas/themes/geist.zig +29 -0
- package/src/primitives/canvas/tokens.zig +72 -2
- package/src/primitives/canvas/ui.zig +400 -22
- package/src/primitives/canvas/ui_markup.zig +78 -7
- package/src/primitives/canvas/ui_markup_compiled.zig +89 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +45 -0
- package/src/primitives/canvas/ui_markup_contract.zig +41 -0
- package/src/primitives/canvas/ui_markup_view.zig +89 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +154 -3
- package/src/primitives/canvas/ui_schema.zig +30 -6
- package/src/primitives/canvas/ui_schema_tests.zig +13 -10
- package/src/primitives/canvas/ui_tests.zig +26 -0
- package/src/primitives/canvas/widget_invalidation.zig +4 -0
- package/src/primitives/canvas/widget_layout.zig +57 -8
- package/src/primitives/canvas/widget_layout_tests.zig +35 -0
- package/src/primitives/canvas/widget_metrics.zig +35 -1
- package/src/primitives/canvas/widget_render.zig +1077 -11
- package/src/primitives/canvas/widget_render_controls.zig +4 -4
- package/src/primitives/canvas/widget_runtime.zig +2 -0
- package/src/primitives/canvas/widget_text_input.zig +165 -8
- package/src/primitives/canvas/widget_text_select.zig +2 -2
- package/src/primitives/canvas/widget_tree.zig +6 -5
- package/src/primitives/canvas/widgets.zig +38 -0
- package/src/root.zig +1 -0
- package/src/runtime/canvas_budget_edge_tests.zig +3 -2
- package/src/runtime/canvas_limits.zig +13 -6
- package/src/runtime/canvas_widget_clipboard_tests.zig +137 -4
- package/src/runtime/canvas_widget_context_menu.zig +17 -2
- package/src/runtime/canvas_widget_event_tests.zig +18 -14
- package/src/runtime/canvas_widget_events.zig +58 -21
- package/src/runtime/canvas_widget_runtime.zig +112 -6
- 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 +383 -0
- package/src/runtime/core.zig +15 -5
- package/src/runtime/gpu_surface_events.zig +12 -12
- package/src/runtime/view.zig +61 -19
- package/src/runtime/view_widget_scroll.zig +48 -18
- package/src/runtime/view_widget_text.zig +248 -17
- package/src/runtime/window_view_runtime.zig +9 -0
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
|
|
@@ -538,12 +534,11 @@ pub const RuntimeView = struct {
|
|
|
538
534
|
/// one is still held, on hosts that emit input-method text before
|
|
539
535
|
/// its key_down) flows instead of being eaten by a stale latch.
|
|
540
536
|
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,
|
|
537
|
+
/// A physical Tab whose first key-down moved focus INTO a Tab-owning
|
|
538
|
+
/// editor (live terminal or editable code). Its auto-repeats and
|
|
539
|
+
/// eventual release still belong to focus traversal, not input for
|
|
540
|
+
/// the newly focused target.
|
|
541
|
+
canvas_widget_tab_input_focus_entry_held: bool = false,
|
|
547
542
|
/// A Cmd/Ctrl+V key-down the clipboard pass converted into terminal
|
|
548
543
|
/// paste input. Its physical V release belongs to that paste even if
|
|
549
544
|
/// the modifier came up first; the raw gpu-input pass consumes it
|
|
@@ -688,10 +683,14 @@ pub const RuntimeView = struct {
|
|
|
688
683
|
/// updateCanvasWidgetInteractionFromPointer), so a pointer gliding
|
|
689
684
|
/// within one sample repaints nothing.
|
|
690
685
|
canvas_widget_hover_point: ?geometry.PointF = null,
|
|
691
|
-
/// The static `.text` widget
|
|
692
|
-
/// selection (0 = none).
|
|
693
|
-
///
|
|
686
|
+
/// The static `.text` widget where the view's active click-drag
|
|
687
|
+
/// selection began (0 = none). Ordinary paragraphs keep their range
|
|
688
|
+
/// on that widget. Bounded code paragraphs additionally share the
|
|
689
|
+
/// global group range below so one gesture can cross internal chunks.
|
|
694
690
|
canvas_widget_selected_text_id: canvas.ObjectId = 0,
|
|
691
|
+
canvas_widget_selected_text_group_id: canvas.ObjectId = 0,
|
|
692
|
+
canvas_widget_selected_text_group_anchor: usize = 0,
|
|
693
|
+
canvas_widget_selected_text_group_focus: usize = 0,
|
|
695
694
|
/// Multi-click chain state for the double/triple-click text
|
|
696
695
|
/// gestures. The runtime derives a click count from consecutive
|
|
697
696
|
/// primary pointer-downs (recorded timestamps within the interval,
|
|
@@ -702,6 +701,11 @@ pub const RuntimeView = struct {
|
|
|
702
701
|
canvas_widget_click_count: u8 = 0,
|
|
703
702
|
canvas_widget_click_timestamp_ns: u64 = 0,
|
|
704
703
|
canvas_widget_click_point: geometry.PointF = .{},
|
|
704
|
+
/// A chain belongs to one physical pointer and one resolved press/text
|
|
705
|
+
/// target. Nearby controls must never donate the first click of another
|
|
706
|
+
/// control's double-click gesture.
|
|
707
|
+
canvas_widget_click_pointer_id: u64 = 0,
|
|
708
|
+
canvas_widget_click_target_id: canvas.ObjectId = 0,
|
|
705
709
|
/// The anchor RUN of an in-flight multi-click drag: the word (or
|
|
706
710
|
/// line) selected by the initiating double (triple) click. Drag
|
|
707
711
|
/// extension unions the run under the pointer with this range, so
|
|
@@ -720,7 +724,11 @@ pub const RuntimeView = struct {
|
|
|
720
724
|
canvas_widget_drag_regions: [canvas_limits.max_canvas_widget_window_drag_regions_per_view]platform.WindowDragRegion = undefined,
|
|
721
725
|
canvas_widget_drag_region_count: usize = 0,
|
|
722
726
|
canvas_widget_drag_regions_pushed: bool = false,
|
|
723
|
-
|
|
727
|
+
widget_text_inline_bytes: [canvas_limits.max_canvas_widget_inline_text_bytes_per_view]u8 = undefined,
|
|
728
|
+
/// Points at `widget_text_inline_bytes` for ordinary views and upgrades to
|
|
729
|
+
/// heap-owned large-file capacity only when a retained layout needs it.
|
|
730
|
+
widget_text_bytes: []u8 = &.{},
|
|
731
|
+
widget_text_bytes_heap_owned: bool = false,
|
|
724
732
|
widget_text_len: usize = 0,
|
|
725
733
|
widget_span_entries: [canvas_limits.max_canvas_widget_spans_per_view]canvas.TextSpan = undefined,
|
|
726
734
|
widget_span_len: usize = 0,
|
|
@@ -759,7 +767,9 @@ pub const RuntimeView = struct {
|
|
|
759
767
|
/// snapshot.
|
|
760
768
|
canvas_widget_text_history_entries: [max_canvas_widget_text_history_entries_per_view]view_widget_text.CanvasWidgetTextHistoryEntry = undefined,
|
|
761
769
|
canvas_widget_text_history_entry_count: usize = 0,
|
|
762
|
-
|
|
770
|
+
canvas_widget_text_history_inline_bytes: [canvas_limits.max_canvas_widget_inline_text_history_bytes_per_view]u8 = undefined,
|
|
771
|
+
canvas_widget_text_history_bytes: []u8 = &.{},
|
|
772
|
+
canvas_widget_text_history_bytes_heap_owned: bool = false,
|
|
763
773
|
canvas_widget_text_history_byte_count: usize = 0,
|
|
764
774
|
canvas_widget_text_history_next_serial: u64 = 1,
|
|
765
775
|
/// Native textarea Up/Down retains its painted x coordinate while a
|
|
@@ -777,6 +787,7 @@ pub const RuntimeView = struct {
|
|
|
777
787
|
const CanvasWidgetTextMethods = view_widget_text.RuntimeViewCanvasWidgetText(RuntimeView);
|
|
778
788
|
pub const applyCanvasWidgetTextEdit = CanvasWidgetTextMethods.applyCanvasWidgetTextEdit;
|
|
779
789
|
pub const applyCanvasWidgetTextEditWithoutHistory = CanvasWidgetTextMethods.applyCanvasWidgetTextEditWithoutHistory;
|
|
790
|
+
pub const canvasWidgetTextEditNeedsLargeStorage = CanvasWidgetTextMethods.canvasWidgetTextEditNeedsLargeStorage;
|
|
780
791
|
pub const canvasWidgetKeyboardTextEdit = CanvasWidgetTextMethods.canvasWidgetKeyboardTextEdit;
|
|
781
792
|
pub const canvasWidgetTextHistoryShortcut = CanvasWidgetTextMethods.canvasWidgetTextHistoryShortcut;
|
|
782
793
|
pub const canvasWidgetTextHistoryAvailability = CanvasWidgetTextMethods.canvasWidgetTextHistoryAvailability;
|
|
@@ -1195,7 +1206,21 @@ pub const RuntimeView = struct {
|
|
|
1195
1206
|
}
|
|
1196
1207
|
|
|
1197
1208
|
pub fn copyRuntimeStateFrom(self: *RuntimeView, source: *const RuntimeView, scratch: *canvas_widget_runtime.CanvasWidgetCopyScratch) void {
|
|
1209
|
+
const widget_text_bytes = self.widget_text_bytes;
|
|
1210
|
+
const widget_text_bytes_heap_owned = self.widget_text_bytes_heap_owned;
|
|
1211
|
+
const text_history_bytes = self.canvas_widget_text_history_bytes;
|
|
1212
|
+
const text_history_bytes_heap_owned = self.canvas_widget_text_history_bytes_heap_owned;
|
|
1198
1213
|
self.* = source.*;
|
|
1214
|
+
self.widget_text_bytes = widget_text_bytes;
|
|
1215
|
+
self.widget_text_bytes_heap_owned = widget_text_bytes_heap_owned;
|
|
1216
|
+
self.canvas_widget_text_history_bytes = text_history_bytes;
|
|
1217
|
+
self.canvas_widget_text_history_bytes_heap_owned = text_history_bytes_heap_owned;
|
|
1218
|
+
if (self.canvas_widget_text_history_bytes.ptr != source.canvas_widget_text_history_bytes.ptr) {
|
|
1219
|
+
@memcpy(
|
|
1220
|
+
self.canvas_widget_text_history_bytes[0..source.canvas_widget_text_history_byte_count],
|
|
1221
|
+
source.canvas_widget_text_history_bytes[0..source.canvas_widget_text_history_byte_count],
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1199
1224
|
self.label = copyInto(&self.label_storage, source.label) catch unreachable;
|
|
1200
1225
|
self.parent = if (source.parent) |parent| copyInto(&self.parent_storage, parent) catch unreachable else null;
|
|
1201
1226
|
self.role = copyInto(&self.role_storage, source.role) catch unreachable;
|
|
@@ -1209,4 +1234,21 @@ pub const RuntimeView = struct {
|
|
|
1209
1234
|
self.widget_revision = source.widget_revision;
|
|
1210
1235
|
@memcpy(self.widget_scroll_states[0..source.widget_layout_node_count], source.widget_scroll_states[0..source.widget_layout_node_count]);
|
|
1211
1236
|
}
|
|
1237
|
+
|
|
1238
|
+
pub fn ensureLargeCanvasWidgetTextStorage(self: *RuntimeView, allocator: std.mem.Allocator) !void {
|
|
1239
|
+
if (self.widget_text_bytes_heap_owned) return;
|
|
1240
|
+
const text_bytes = try allocator.alloc(u8, canvas_limits.max_canvas_widget_text_bytes_per_view);
|
|
1241
|
+
errdefer allocator.free(text_bytes);
|
|
1242
|
+
const history_bytes = try allocator.alloc(u8, canvas_limits.max_canvas_widget_text_history_bytes_per_view);
|
|
1243
|
+
errdefer allocator.free(history_bytes);
|
|
1244
|
+
@memcpy(text_bytes[0..self.widget_text_len], self.widget_text_bytes[0..self.widget_text_len]);
|
|
1245
|
+
@memcpy(
|
|
1246
|
+
history_bytes[0..self.canvas_widget_text_history_byte_count],
|
|
1247
|
+
self.canvas_widget_text_history_bytes[0..self.canvas_widget_text_history_byte_count],
|
|
1248
|
+
);
|
|
1249
|
+
self.widget_text_bytes = text_bytes;
|
|
1250
|
+
self.widget_text_bytes_heap_owned = true;
|
|
1251
|
+
self.canvas_widget_text_history_bytes = history_bytes;
|
|
1252
|
+
self.canvas_widget_text_history_bytes_heap_owned = true;
|
|
1253
|
+
}
|
|
1212
1254
|
};
|
|
@@ -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
|
}
|
|
@@ -1061,11 +1093,19 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1061
1093
|
|
|
1062
1094
|
/// Click-drag selection inside one static `.text` widget. Press
|
|
1063
1095
|
/// collapses at the hit offset, drag extends from the press
|
|
1064
|
-
/// anchor.
|
|
1065
|
-
///
|
|
1066
|
-
/// document model ordering text across widgets to extend into.
|
|
1096
|
+
/// anchor. Ordinary widgets remain independently selectable;
|
|
1097
|
+
/// bounded code paragraphs opt into one ordered source group.
|
|
1067
1098
|
fn applyCanvasWidgetStaticTextPointer(self: *RuntimeView, index: usize, target_id: canvas.ObjectId, point: geometry.PointF, extend: bool) anyerror!?geometry.RectF {
|
|
1068
1099
|
const widget = self.widget_layout_nodes[index].widget;
|
|
1100
|
+
if (widget.static_text_group_id != 0) {
|
|
1101
|
+
return applyCanvasWidgetStaticTextGroupPointer(
|
|
1102
|
+
self,
|
|
1103
|
+
target_id,
|
|
1104
|
+
point,
|
|
1105
|
+
extend,
|
|
1106
|
+
widget.static_text_group_id,
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1069
1109
|
if (extend and self.canvas_widget_selected_text_id != target_id) return null;
|
|
1070
1110
|
const current_selection = widget.text_selection orelse canvas.TextSelection.collapsed(0);
|
|
1071
1111
|
const anchor: ?usize = if (extend) current_selection.anchor else null;
|
|
@@ -1074,11 +1114,130 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1074
1114
|
|
|
1075
1115
|
self.widget_layout_nodes[index].widget.text_selection = next_selection;
|
|
1076
1116
|
self.canvas_widget_selected_text_id = target_id;
|
|
1117
|
+
self.canvas_widget_selected_text_group_id = 0;
|
|
1118
|
+
self.canvas_widget_selected_text_group_anchor = 0;
|
|
1119
|
+
self.canvas_widget_selected_text_group_focus = 0;
|
|
1077
1120
|
try self.refreshCanvasWidgetSemantics();
|
|
1078
1121
|
self.widget_revision += 1;
|
|
1079
1122
|
return self.canvasWidgetDirtyBounds(index, widget.frame);
|
|
1080
1123
|
}
|
|
1081
1124
|
|
|
1125
|
+
fn applyCanvasWidgetStaticTextGroupPointer(
|
|
1126
|
+
self: *RuntimeView,
|
|
1127
|
+
target_id: canvas.ObjectId,
|
|
1128
|
+
point: geometry.PointF,
|
|
1129
|
+
extend: bool,
|
|
1130
|
+
group_id: canvas.ObjectId,
|
|
1131
|
+
) anyerror!?geometry.RectF {
|
|
1132
|
+
if (extend and
|
|
1133
|
+
(self.canvas_widget_selected_text_id != target_id or
|
|
1134
|
+
self.canvas_widget_selected_text_group_id != group_id))
|
|
1135
|
+
{
|
|
1136
|
+
return null;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
var point_index: ?usize = null;
|
|
1140
|
+
var point_offset: usize = 0;
|
|
1141
|
+
var best_distance = std.math.inf(f32);
|
|
1142
|
+
const layout = self.widgetLayoutTree();
|
|
1143
|
+
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, candidate_index| {
|
|
1144
|
+
const candidate = node.widget;
|
|
1145
|
+
if (candidate.static_text_group_id != group_id or
|
|
1146
|
+
canvasWidgetLayoutNodeHidden(layout, candidate_index) or
|
|
1147
|
+
!canvas.widgetStaticTextSelectable(candidate))
|
|
1148
|
+
{
|
|
1149
|
+
continue;
|
|
1150
|
+
}
|
|
1151
|
+
const frame = candidate.frame.normalized();
|
|
1152
|
+
const dx = if (point.x < frame.x)
|
|
1153
|
+
frame.x - point.x
|
|
1154
|
+
else if (point.x > frame.maxX())
|
|
1155
|
+
point.x - frame.maxX()
|
|
1156
|
+
else
|
|
1157
|
+
0;
|
|
1158
|
+
const dy = if (point.y < frame.y)
|
|
1159
|
+
frame.y - point.y
|
|
1160
|
+
else if (point.y > frame.maxY())
|
|
1161
|
+
point.y - frame.maxY()
|
|
1162
|
+
else
|
|
1163
|
+
0;
|
|
1164
|
+
const distance = dx * dx + dy * dy;
|
|
1165
|
+
if (distance > best_distance) continue;
|
|
1166
|
+
const local = canvas.staticTextSelectionForWidgetPoint(
|
|
1167
|
+
candidate,
|
|
1168
|
+
point,
|
|
1169
|
+
null,
|
|
1170
|
+
self.widget_tokens,
|
|
1171
|
+
) orelse continue;
|
|
1172
|
+
if (distance == best_distance and point_index != null) continue;
|
|
1173
|
+
best_distance = distance;
|
|
1174
|
+
point_index = candidate_index;
|
|
1175
|
+
point_offset = local.focus;
|
|
1176
|
+
}
|
|
1177
|
+
const selected_index = point_index orelse return null;
|
|
1178
|
+
const selected_widget = self.widget_layout_nodes[selected_index].widget;
|
|
1179
|
+
const focus = selected_widget.static_text_group_offset + point_offset;
|
|
1180
|
+
const anchor = if (extend)
|
|
1181
|
+
self.canvas_widget_selected_text_group_anchor
|
|
1182
|
+
else
|
|
1183
|
+
focus;
|
|
1184
|
+
const selection_start = @min(anchor, focus);
|
|
1185
|
+
const selection_end = @max(anchor, focus);
|
|
1186
|
+
|
|
1187
|
+
var dirty: ?geometry.RectF = null;
|
|
1188
|
+
var changed = false;
|
|
1189
|
+
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |*node, candidate_index| {
|
|
1190
|
+
const candidate = node.widget;
|
|
1191
|
+
if (candidate.static_text_group_id != group_id) {
|
|
1192
|
+
continue;
|
|
1193
|
+
}
|
|
1194
|
+
const source_start = candidate.static_text_group_offset;
|
|
1195
|
+
const source_end = source_start +| candidate.text.len;
|
|
1196
|
+
const next_selection: ?canvas.TextSelection = if (selection_start == selection_end)
|
|
1197
|
+
if (candidate_index == selected_index)
|
|
1198
|
+
canvas.TextSelection.collapsed(point_offset)
|
|
1199
|
+
else
|
|
1200
|
+
null
|
|
1201
|
+
else if (@max(selection_start, source_start) < @min(selection_end, source_end))
|
|
1202
|
+
.{
|
|
1203
|
+
.anchor = @max(selection_start, source_start) - source_start,
|
|
1204
|
+
.focus = @min(selection_end, source_end) - source_start,
|
|
1205
|
+
}
|
|
1206
|
+
else
|
|
1207
|
+
null;
|
|
1208
|
+
const current_selection = candidate.text_selection;
|
|
1209
|
+
const same = if (current_selection) |current|
|
|
1210
|
+
if (next_selection) |next|
|
|
1211
|
+
canvasTextSelectionsEqual(current, next)
|
|
1212
|
+
else
|
|
1213
|
+
false
|
|
1214
|
+
else
|
|
1215
|
+
next_selection == null;
|
|
1216
|
+
if (same) continue;
|
|
1217
|
+
node.widget.text_selection = next_selection;
|
|
1218
|
+
changed = true;
|
|
1219
|
+
dirty = unionRects(
|
|
1220
|
+
dirty,
|
|
1221
|
+
self.canvasWidgetDirtyBounds(candidate_index, candidate.frame),
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
if (!changed and
|
|
1225
|
+
self.canvas_widget_selected_text_id == target_id and
|
|
1226
|
+
self.canvas_widget_selected_text_group_anchor == anchor and
|
|
1227
|
+
self.canvas_widget_selected_text_group_focus == focus)
|
|
1228
|
+
{
|
|
1229
|
+
return null;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
self.canvas_widget_selected_text_id = target_id;
|
|
1233
|
+
self.canvas_widget_selected_text_group_id = group_id;
|
|
1234
|
+
self.canvas_widget_selected_text_group_anchor = anchor;
|
|
1235
|
+
self.canvas_widget_selected_text_group_focus = focus;
|
|
1236
|
+
try self.refreshCanvasWidgetSemantics();
|
|
1237
|
+
self.widget_revision += 1;
|
|
1238
|
+
return dirty;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1082
1241
|
/// Drop the view's static text selection (pointer pressed
|
|
1083
1242
|
/// elsewhere, or the copy source went away). Returns the dirty
|
|
1084
1243
|
/// bounds of the widget that lost its highlight.
|
|
@@ -1086,6 +1245,31 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1086
1245
|
const id = self.canvas_widget_selected_text_id;
|
|
1087
1246
|
if (id == 0) return null;
|
|
1088
1247
|
self.canvas_widget_selected_text_id = 0;
|
|
1248
|
+
const group_id = self.canvas_widget_selected_text_group_id;
|
|
1249
|
+
self.canvas_widget_selected_text_group_id = 0;
|
|
1250
|
+
self.canvas_widget_selected_text_group_anchor = 0;
|
|
1251
|
+
self.canvas_widget_selected_text_group_focus = 0;
|
|
1252
|
+
if (group_id != 0) {
|
|
1253
|
+
var dirty: ?geometry.RectF = null;
|
|
1254
|
+
var changed = false;
|
|
1255
|
+
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |*node, index| {
|
|
1256
|
+
if (node.widget.static_text_group_id != group_id or
|
|
1257
|
+
node.widget.text_selection == null)
|
|
1258
|
+
{
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
node.widget.text_selection = null;
|
|
1262
|
+
changed = true;
|
|
1263
|
+
dirty = unionRects(
|
|
1264
|
+
dirty,
|
|
1265
|
+
self.canvasWidgetDirtyBounds(index, node.widget.frame),
|
|
1266
|
+
);
|
|
1267
|
+
}
|
|
1268
|
+
if (!changed) return null;
|
|
1269
|
+
try self.refreshCanvasWidgetSemantics();
|
|
1270
|
+
self.widget_revision += 1;
|
|
1271
|
+
return dirty;
|
|
1272
|
+
}
|
|
1089
1273
|
const index = self.canvasWidgetNodeIndexById(id) orelse return null;
|
|
1090
1274
|
if (self.widget_layout_nodes[index].widget.text_selection == null) return null;
|
|
1091
1275
|
self.widget_layout_nodes[index].widget.text_selection = null;
|
|
@@ -1098,7 +1282,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1098
1282
|
/// focused editable widget's selection or focused terminal's
|
|
1099
1283
|
/// emulator selection when it has one, else the view's static
|
|
1100
1284
|
/// text selection.
|
|
1101
|
-
pub fn canvasWidgetCopyText(self: *const RuntimeView) ?[]const u8 {
|
|
1285
|
+
pub fn canvasWidgetCopyText(self: *const RuntimeView, group_buffer: []u8) ?[]const u8 {
|
|
1102
1286
|
if (self.canvas_widget_focused_id != 0) {
|
|
1103
1287
|
if (self.canvasWidgetNodeIndexById(self.canvas_widget_focused_id)) |index| {
|
|
1104
1288
|
const focused = self.widget_layout_nodes[index].widget;
|
|
@@ -1111,11 +1295,49 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1111
1295
|
if (canvasWidgetSelectionSliceById(self, self.canvas_widget_focused_id, true)) |slice| return slice;
|
|
1112
1296
|
}
|
|
1113
1297
|
if (self.canvas_widget_selected_text_id != 0) {
|
|
1298
|
+
if (self.canvas_widget_selected_text_group_id != 0) {
|
|
1299
|
+
return canvasWidgetStaticTextGroupCopy(self, group_buffer);
|
|
1300
|
+
}
|
|
1114
1301
|
if (canvasWidgetSelectionSliceById(self, self.canvas_widget_selected_text_id, false)) |slice| return slice;
|
|
1115
1302
|
}
|
|
1116
1303
|
return null;
|
|
1117
1304
|
}
|
|
1118
1305
|
|
|
1306
|
+
fn canvasWidgetStaticTextGroupCopy(self: *const RuntimeView, output: []u8) ?[]const u8 {
|
|
1307
|
+
const group_id = self.canvas_widget_selected_text_group_id;
|
|
1308
|
+
if (group_id == 0) return null;
|
|
1309
|
+
const start = @min(
|
|
1310
|
+
self.canvas_widget_selected_text_group_anchor,
|
|
1311
|
+
self.canvas_widget_selected_text_group_focus,
|
|
1312
|
+
);
|
|
1313
|
+
const end = @max(
|
|
1314
|
+
self.canvas_widget_selected_text_group_anchor,
|
|
1315
|
+
self.canvas_widget_selected_text_group_focus,
|
|
1316
|
+
);
|
|
1317
|
+
if (start >= end or end - start > output.len) return null;
|
|
1318
|
+
var copied: usize = 0;
|
|
1319
|
+
for (self.widget_layout_nodes[0..self.widget_layout_node_count]) |node| {
|
|
1320
|
+
const widget = node.widget;
|
|
1321
|
+
if (widget.static_text_group_id != group_id) {
|
|
1322
|
+
continue;
|
|
1323
|
+
}
|
|
1324
|
+
const source_start = widget.static_text_group_offset;
|
|
1325
|
+
const source_end = source_start +| widget.text.len;
|
|
1326
|
+
const copy_start = @max(start, source_start);
|
|
1327
|
+
const copy_end = @min(end, source_end);
|
|
1328
|
+
if (copy_start >= copy_end) continue;
|
|
1329
|
+
const destination_start = copy_start - start;
|
|
1330
|
+
const len = copy_end - copy_start;
|
|
1331
|
+
@memcpy(
|
|
1332
|
+
output[destination_start..][0..len],
|
|
1333
|
+
widget.text[copy_start - source_start ..][0..len],
|
|
1334
|
+
);
|
|
1335
|
+
copied += len;
|
|
1336
|
+
}
|
|
1337
|
+
if (copied != end - start) return null;
|
|
1338
|
+
return output[0 .. end - start];
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1119
1341
|
fn canvasWidgetSelectionSliceById(self: *const RuntimeView, id: canvas.ObjectId, editable_only: bool) ?[]const u8 {
|
|
1120
1342
|
const index = self.canvasWidgetNodeIndexById(id) orelse return null;
|
|
1121
1343
|
const widget = self.widget_layout_nodes[index].widget;
|
|
@@ -1128,31 +1350,40 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1128
1350
|
|
|
1129
1351
|
pub fn rewriteCanvasWidgetTextStorage(self: *RuntimeView, edited_index: usize, next_state: canvas.TextEditState) anyerror!void {
|
|
1130
1352
|
try validateCanvasWidgetTextStorageRewrite(self, edited_index, next_state);
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
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();
|
|
1135
1359
|
var temp_len: usize = 0;
|
|
1136
1360
|
|
|
1137
1361
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, index| {
|
|
1138
1362
|
const text = if (index == edited_index) next_state.text else node.widget.text;
|
|
1139
|
-
text_ranges[index] = try appendWidgetTextStorageRange(&
|
|
1140
|
-
label_ranges[index] = try appendWidgetTextStorageRange(&
|
|
1141
|
-
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);
|
|
1142
1366
|
}
|
|
1143
1367
|
|
|
1144
|
-
@memcpy(self.widget_text_bytes[0..temp_len],
|
|
1368
|
+
@memcpy(self.widget_text_bytes[0..temp_len], scratch.rewrite_buffer[0..temp_len]);
|
|
1145
1369
|
self.widget_text_len = temp_len;
|
|
1146
1370
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |*node, index| {
|
|
1147
|
-
const text_range = text_ranges[index];
|
|
1148
|
-
const label_range = label_ranges[index];
|
|
1149
|
-
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];
|
|
1150
1374
|
node.widget.text = self.widget_text_bytes[text_range.start..text_range.end];
|
|
1151
1375
|
node.widget.semantics.label = self.widget_text_bytes[label_range.start..label_range.end];
|
|
1152
1376
|
node.widget.command = self.widget_text_bytes[command_range.start..command_range.end];
|
|
1153
1377
|
}
|
|
1154
1378
|
self.widget_layout_nodes[edited_index].widget.text_selection = next_state.selection;
|
|
1155
1379
|
self.widget_layout_nodes[edited_index].widget.text_composition = next_state.composition;
|
|
1380
|
+
if (text_changed) {
|
|
1381
|
+
self.widget_layout_nodes[edited_index].widget.code_content_width_generation = 0;
|
|
1382
|
+
canvas.cacheTextInputContentWidthForWidget(
|
|
1383
|
+
&self.widget_layout_nodes[edited_index].widget,
|
|
1384
|
+
self.widget_tokens,
|
|
1385
|
+
);
|
|
1386
|
+
}
|
|
1156
1387
|
}
|
|
1157
1388
|
|
|
1158
1389
|
/// Prove a retained text rewrite fits before any editor history is
|