@native-sdk/cli 0.6.2 → 0.7.0
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/skill-data/native-ui/SKILL.md +17 -2
- 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/code.zig +590 -0
- package/src/primitives/canvas/code_tests.zig +1062 -0
- package/src/primitives/canvas/equality.zig +3 -1
- package/src/primitives/canvas/events.zig +4 -0
- package/src/primitives/canvas/layout_audit.zig +3 -1
- package/src/primitives/canvas/markdown.zig +13 -11
- package/src/primitives/canvas/markdown_tests.zig +167 -4
- package/src/primitives/canvas/root.zig +15 -2
- package/src/primitives/canvas/tests.zig +1 -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_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/text_tests.zig +86 -0
- package/src/primitives/canvas/themes/geist.zig +29 -0
- package/src/primitives/canvas/tokens.zig +72 -2
- package/src/primitives/canvas/ui.zig +325 -21
- package/src/primitives/canvas/ui_markup.zig +59 -2
- package/src/primitives/canvas/ui_markup_compiled.zig +76 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +33 -0
- package/src/primitives/canvas/ui_markup_contract.zig +34 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +20 -3
- package/src/primitives/canvas/ui_markup_view.zig +73 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +101 -0
- package/src/primitives/canvas/ui_schema.zig +17 -6
- package/src/primitives/canvas/ui_schema_tests.zig +7 -6
- package/src/primitives/canvas/ui_tests.zig +6 -0
- package/src/primitives/canvas/widget_invalidation.zig +3 -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 +30 -1
- package/src/primitives/canvas/widget_render.zig +454 -9
- package/src/primitives/canvas/widget_runtime.zig +1 -0
- package/src/primitives/canvas/widget_text_input.zig +23 -11
- package/src/primitives/canvas/widget_text_select.zig +2 -2
- package/src/primitives/canvas/widgets.zig +13 -0
- package/src/root.zig +1 -0
- 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 +146 -0
- package/src/runtime/canvas_widget_context_menu.zig +12 -2
- package/src/runtime/canvas_widget_display.zig +15 -1
- package/src/runtime/canvas_widget_events.zig +50 -20
- package/src/runtime/canvas_widget_runtime.zig +74 -12
- package/src/runtime/canvas_widget_state.zig +1 -0
- package/src/runtime/canvas_widget_text_tests.zig +1935 -70
- package/src/runtime/gpu_surface_events.zig +38 -0
- package/src/runtime/view.zig +37 -3
- package/src/runtime/view_widget_text.zig +1242 -14
- package/src/runtime/view_widget_tree.zig +2 -0
|
@@ -1185,6 +1185,7 @@ const Checker = struct {
|
|
|
1185
1185
|
fn checkElement(self: *Checker, node: markup.MarkupNode) CheckErr!void {
|
|
1186
1186
|
if (std.mem.eql(u8, node.name, "span")) return self.checkSpan(node);
|
|
1187
1187
|
if (std.mem.eql(u8, node.name, "markdown")) return self.checkMarkdown(node);
|
|
1188
|
+
if (std.mem.eql(u8, node.name, "code")) return self.checkCode(node);
|
|
1188
1189
|
if (std.mem.eql(u8, node.name, "stepper")) return self.checkStepper(node);
|
|
1189
1190
|
if (std.mem.eql(u8, node.name, "timeline-item")) return self.checkTimelineItem(node);
|
|
1190
1191
|
if (std.mem.eql(u8, node.name, "chart")) return self.checkChart(node);
|
|
@@ -1338,6 +1339,39 @@ const Checker = struct {
|
|
|
1338
1339
|
}
|
|
1339
1340
|
}
|
|
1340
1341
|
|
|
1342
|
+
fn checkCode(self: *Checker, node: markup.MarkupNode) CheckErr!void {
|
|
1343
|
+
for (node.attrs) |attribute| {
|
|
1344
|
+
if (std.mem.eql(u8, attribute.name, "source")) {
|
|
1345
|
+
const expression = markup.parseAttrExpression(attribute.value) orelse continue;
|
|
1346
|
+
if (expression != .binding) continue;
|
|
1347
|
+
const resolved = try self.resolveBinding(node, expression.binding, true);
|
|
1348
|
+
try self.requireAttrKind(node, attribute, resolved.kind, &.{.string}, markup.code_source_message);
|
|
1349
|
+
continue;
|
|
1350
|
+
}
|
|
1351
|
+
if (std.mem.eql(u8, attribute.name, "line-numbers") or std.mem.eql(u8, attribute.name, "wrap")) {
|
|
1352
|
+
if (attribute.value.len == 0) continue;
|
|
1353
|
+
_ = try self.attrKind(node, attribute, attribute.value);
|
|
1354
|
+
continue;
|
|
1355
|
+
}
|
|
1356
|
+
if (std.mem.eql(u8, attribute.name, "width") or
|
|
1357
|
+
std.mem.eql(u8, attribute.name, "height") or
|
|
1358
|
+
std.mem.eql(u8, attribute.name, "min-width") or
|
|
1359
|
+
std.mem.eql(u8, attribute.name, "grow"))
|
|
1360
|
+
{
|
|
1361
|
+
try self.checkClassAttr(node, attribute, .number);
|
|
1362
|
+
continue;
|
|
1363
|
+
}
|
|
1364
|
+
if (std.mem.eql(u8, attribute.name, "key") or std.mem.eql(u8, attribute.name, "global-key")) {
|
|
1365
|
+
try self.checkKeyAttr(node, attribute);
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
if (std.mem.eql(u8, attribute.name, "label")) {
|
|
1369
|
+
const kind = try self.attrKind(node, attribute, attribute.value);
|
|
1370
|
+
try self.requireAttrKind(node, attribute, kind, &.{.string}, label_attr_message);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1341
1375
|
fn checkStepper(self: *Checker, node: markup.MarkupNode) CheckErr!void {
|
|
1342
1376
|
for (node.attrs) |attribute| {
|
|
1343
1377
|
if (std.mem.eql(u8, attribute.name, "active")) {
|
|
@@ -116,6 +116,10 @@ pub const text_caret_direction_members = [_][]const u8{
|
|
|
116
116
|
"previous", "next", "previous_word", "next_word", "start", "end",
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
pub const text_caret_affinity_members = [_][]const u8{
|
|
120
|
+
"upstream", "downstream",
|
|
121
|
+
};
|
|
122
|
+
|
|
119
123
|
/// A Msg arm payload union DECLARING the text-input event shape rather than
|
|
120
124
|
/// being `canvas.TextInputEvent` by identity — the transpiled-core case,
|
|
121
125
|
/// where the emitted module declares its own mirror union (type identity
|
|
@@ -125,7 +129,8 @@ pub const text_caret_direction_members = [_][]const u8{
|
|
|
125
129
|
/// - `insert_text` a bytes payload; the seven verb arms void;
|
|
126
130
|
/// - `move_caret` a record of `direction` (an enum with exactly the six
|
|
127
131
|
/// caret-direction member names) and `extend: bool`;
|
|
128
|
-
/// - `set_selection` a record of numeric `anchor`/`focus
|
|
132
|
+
/// - `set_selection` a record of numeric `anchor`/`focus`, optionally
|
|
133
|
+
/// plus the native `upstream`/`downstream` caret-affinity enum;
|
|
129
134
|
/// - `set_composition` a record of bytes `text` and optional numeric
|
|
130
135
|
/// `cursor`.
|
|
131
136
|
/// Numeric fields accept integer or float (the transpiler's number model
|
|
@@ -323,11 +328,23 @@ fn isSelectionRecord(comptime T: type) bool {
|
|
|
323
328
|
.@"struct" => |s| s,
|
|
324
329
|
else => return false,
|
|
325
330
|
};
|
|
326
|
-
if (info.fields.len != 2) return false;
|
|
331
|
+
if (info.fields.len != 2 and info.fields.len != 3) return false;
|
|
327
332
|
if (!@hasField(T, "anchor") or !@hasField(T, "focus")) return false;
|
|
328
333
|
inline for (info.fields) |field| {
|
|
329
|
-
if (
|
|
334
|
+
if (comptime std.mem.eql(u8, field.name, "affinity")) {
|
|
335
|
+
const members = switch (@typeInfo(field.type)) {
|
|
336
|
+
.@"enum" => |e| e.fields,
|
|
337
|
+
else => return false,
|
|
338
|
+
};
|
|
339
|
+
if (members.len != text_caret_affinity_members.len) return false;
|
|
340
|
+
inline for (text_caret_affinity_members) |name| {
|
|
341
|
+
if (!@hasField(field.type, name)) return false;
|
|
342
|
+
}
|
|
343
|
+
} else if (!isNumeric(field.type)) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
330
346
|
}
|
|
347
|
+
if (info.fields.len == 3 and !@hasField(T, "affinity")) return false;
|
|
331
348
|
return true;
|
|
332
349
|
}
|
|
333
350
|
|
|
@@ -213,6 +213,9 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
213
213
|
if (std.mem.eql(u8, node.name, "markdown")) {
|
|
214
214
|
return self.buildMarkdown(ui, scope, node);
|
|
215
215
|
}
|
|
216
|
+
if (std.mem.eql(u8, node.name, "code")) {
|
|
217
|
+
return self.buildCode(ui, scope, node);
|
|
218
|
+
}
|
|
216
219
|
if (std.mem.eql(u8, node.name, "stepper")) {
|
|
217
220
|
return self.buildStepper(ui, scope, node);
|
|
218
221
|
}
|
|
@@ -798,6 +801,76 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
798
801
|
return Md.view(ui, source_value, options);
|
|
799
802
|
}
|
|
800
803
|
|
|
804
|
+
// ----------------------------------------------------------- code
|
|
805
|
+
|
|
806
|
+
fn buildCode(self: *Self, ui: *Ui, scope: *Scope, node: markup.MarkupNode) BuildError!Ui.Node {
|
|
807
|
+
if (node.children.len != 0) return self.failNode(node.children[0], markup.code_children_message);
|
|
808
|
+
var options: Ui.CodeOptions = .{};
|
|
809
|
+
var source_text: ?[]const u8 = null;
|
|
810
|
+
for (node.attrs) |attribute| {
|
|
811
|
+
if (std.mem.eql(u8, attribute.name, "kind")) continue;
|
|
812
|
+
if (std.mem.eql(u8, attribute.name, "source")) {
|
|
813
|
+
const typed = markup.attrTyped(attribute);
|
|
814
|
+
if (typed != .binding) return self.failNode(node, markup.code_source_message);
|
|
815
|
+
source_text = switch (try self.evalBinding(scope, node, typed.binding, true)) {
|
|
816
|
+
.string => |text| text,
|
|
817
|
+
else => return self.failNode(node, markup.code_source_message),
|
|
818
|
+
};
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
if (std.mem.eql(u8, attribute.name, "language")) {
|
|
822
|
+
const typed = markup.attrTyped(attribute);
|
|
823
|
+
if (typed != .literal) return self.failNode(node, markup.code_language_message);
|
|
824
|
+
if (!canvas.code.isLanguageName(typed.literal)) return self.failNode(node, markup.code_language_message);
|
|
825
|
+
options.language = canvas.code.languageFromName(typed.literal);
|
|
826
|
+
continue;
|
|
827
|
+
}
|
|
828
|
+
if (std.mem.eql(u8, attribute.name, "line-numbers")) {
|
|
829
|
+
options.line_numbers = try self.codeFlagAttr(scope, node, attribute);
|
|
830
|
+
continue;
|
|
831
|
+
}
|
|
832
|
+
if (std.mem.eql(u8, attribute.name, "wrap")) {
|
|
833
|
+
options.wrap = try self.codeFlagAttr(scope, node, attribute);
|
|
834
|
+
continue;
|
|
835
|
+
}
|
|
836
|
+
if (std.mem.eql(u8, attribute.name, "width")) {
|
|
837
|
+
options.width = try self.floatAttr(scope, node, attribute);
|
|
838
|
+
continue;
|
|
839
|
+
}
|
|
840
|
+
if (std.mem.eql(u8, attribute.name, "height")) {
|
|
841
|
+
options.height = try self.floatAttr(scope, node, attribute);
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
if (std.mem.eql(u8, attribute.name, "min-width")) {
|
|
845
|
+
options.min_width = try self.floatAttr(scope, node, attribute);
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
if (std.mem.eql(u8, attribute.name, "grow")) {
|
|
849
|
+
options.grow = try self.floatAttr(scope, node, attribute);
|
|
850
|
+
continue;
|
|
851
|
+
}
|
|
852
|
+
if (std.mem.eql(u8, attribute.name, "key")) {
|
|
853
|
+
options.key = try self.attrKey(scope, node, attribute);
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
if (std.mem.eql(u8, attribute.name, "global-key")) {
|
|
857
|
+
options.global_key = try self.attrKey(scope, node, attribute);
|
|
858
|
+
continue;
|
|
859
|
+
}
|
|
860
|
+
if (std.mem.eql(u8, attribute.name, "label")) {
|
|
861
|
+
options.semantics.label = try self.stringAttr(scope, node, attribute, "label expects text");
|
|
862
|
+
continue;
|
|
863
|
+
}
|
|
864
|
+
return self.failNode(node, markup.code_attr_message);
|
|
865
|
+
}
|
|
866
|
+
return ui.code(options, source_text orelse return self.failNode(node, markup.code_source_message));
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
fn codeFlagAttr(self: *Self, scope: *Scope, node: markup.MarkupNode, attribute: markup.MarkupAttr) BuildError!bool {
|
|
870
|
+
if (attribute.value.len == 0) return true;
|
|
871
|
+
return (try self.evalAttrExpression(scope, node, attribute)).truthy();
|
|
872
|
+
}
|
|
873
|
+
|
|
801
874
|
// ------------------------------------------------ stepper/timeline
|
|
802
875
|
|
|
803
876
|
/// `<stepper active="{stage_index}"><step>Work</step>...</stepper>`:
|
|
@@ -1926,6 +1926,91 @@ test "markdown misuse is caught by the model-agnostic validator with positions"
|
|
|
1926
1926
|
try testing.expectEqual(@as(?canvas.ui_markup.MarkupErrorInfo, null), canvas.ui_markup.validate(try parser.parse()));
|
|
1927
1927
|
}
|
|
1928
1928
|
|
|
1929
|
+
// ------------------------------------------------------- code component
|
|
1930
|
+
|
|
1931
|
+
pub const CodeMsg = union(enum) { noop };
|
|
1932
|
+
|
|
1933
|
+
pub const CodeModel = struct {
|
|
1934
|
+
snippet: []const u8 =
|
|
1935
|
+
\\<Accordion defaultValue={["item-1"]}>
|
|
1936
|
+
\\ <AccordionTrigger>Accessible?</AccordionTrigger>
|
|
1937
|
+
\\</Accordion>
|
|
1938
|
+
,
|
|
1939
|
+
show_lines: bool = true,
|
|
1940
|
+
wrap_code: bool = false,
|
|
1941
|
+
count: usize = 3,
|
|
1942
|
+
};
|
|
1943
|
+
|
|
1944
|
+
pub const code_markup_source =
|
|
1945
|
+
\\<code source="{snippet}" language="tsx" line-numbers="{show_lines}" wrap="{wrap_code}" width="240" label="Example code" />
|
|
1946
|
+
;
|
|
1947
|
+
|
|
1948
|
+
pub const CodeUi = canvas.Ui(CodeMsg);
|
|
1949
|
+
|
|
1950
|
+
pub fn handCodeView(ui: *CodeUi, model: *const CodeModel) CodeUi.Node {
|
|
1951
|
+
return ui.code(.{
|
|
1952
|
+
.language = .html,
|
|
1953
|
+
.line_numbers = model.show_lines,
|
|
1954
|
+
.wrap = model.wrap_code,
|
|
1955
|
+
.width = 240,
|
|
1956
|
+
.semantics = .{ .label = "Example code" },
|
|
1957
|
+
}, model.snippet);
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
test "code markup builds the reusable component with opt-in numbers and horizontal scrolling" {
|
|
1961
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1962
|
+
defer arena_state.deinit();
|
|
1963
|
+
const arena = arena_state.allocator();
|
|
1964
|
+
const model = CodeModel{};
|
|
1965
|
+
const CodeMarkup = markup_view.MarkupView(CodeModel, CodeMsg);
|
|
1966
|
+
|
|
1967
|
+
var view = try CodeMarkup.init(arena, code_markup_source);
|
|
1968
|
+
var markup_ui = CodeUi.init(arena);
|
|
1969
|
+
const markup_tree = try markup_ui.finalize(try view.build(&markup_ui, &model));
|
|
1970
|
+
var hand_ui = CodeUi.init(arena);
|
|
1971
|
+
const hand_tree = try hand_ui.finalize(handCodeView(&hand_ui, &model));
|
|
1972
|
+
|
|
1973
|
+
var markup_ids: std.ArrayListUnmanaged(canvas.ObjectId) = .empty;
|
|
1974
|
+
defer markup_ids.deinit(testing.allocator);
|
|
1975
|
+
var hand_ids: std.ArrayListUnmanaged(canvas.ObjectId) = .empty;
|
|
1976
|
+
defer hand_ids.deinit(testing.allocator);
|
|
1977
|
+
try collectIds(markup_tree.root, &markup_ids, testing.allocator);
|
|
1978
|
+
try collectIds(hand_tree.root, &hand_ids, testing.allocator);
|
|
1979
|
+
try testing.expectEqualSlices(canvas.ObjectId, hand_ids.items, markup_ids.items);
|
|
1980
|
+
try testing.expectEqual(canvas.ScrollAxes.horizontal, findByKind(markup_tree.root, .scroll_view).?.scroll_axes);
|
|
1981
|
+
const source = findByText(markup_tree.root, .text, model.snippet).?;
|
|
1982
|
+
try testing.expectEqual(@as(u8, 1), source.code_line_number_digits);
|
|
1983
|
+
try testing.expectEqualStrings("Example code", markup_tree.root.semantics.label);
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
test "code markup misuse reports the component's closed contract" {
|
|
1987
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
1988
|
+
defer arena_state.deinit();
|
|
1989
|
+
const arena = arena_state.allocator();
|
|
1990
|
+
const model = CodeModel{};
|
|
1991
|
+
const CodeMarkup = markup_view.MarkupView(CodeModel, CodeMsg);
|
|
1992
|
+
const cases = [_]struct { source: []const u8, message: []const u8, model_agnostic: bool = true }{
|
|
1993
|
+
.{ .source = "<code language=\"zig\" />", .message = canvas.ui_markup.code_source_message },
|
|
1994
|
+
.{ .source = "<code source=\"literal\" />", .message = canvas.ui_markup.code_source_message },
|
|
1995
|
+
.{ .source = "<code source=\"{count}\" />", .message = canvas.ui_markup.code_source_message, .model_agnostic = false },
|
|
1996
|
+
.{ .source = "<code source=\"{snippet}\" language=\"brainwave\" />", .message = canvas.ui_markup.code_language_message },
|
|
1997
|
+
.{ .source = "<code source=\"{snippet}\" padding=\"8\" />", .message = canvas.ui_markup.code_attr_message },
|
|
1998
|
+
.{ .source = "<code source=\"{snippet}\">text</code>", .message = canvas.ui_markup.code_children_message },
|
|
1999
|
+
};
|
|
2000
|
+
for (cases) |case| {
|
|
2001
|
+
var view = try CodeMarkup.init(arena, case.source);
|
|
2002
|
+
var ui = CodeUi.init(arena);
|
|
2003
|
+
try testing.expectError(error.MarkupBuild, view.build(&ui, &model));
|
|
2004
|
+
try testing.expectEqualStrings(case.message, view.diagnostic.message);
|
|
2005
|
+
|
|
2006
|
+
if (case.model_agnostic) {
|
|
2007
|
+
var parser = canvas.ui_markup.Parser.init(arena, case.source);
|
|
2008
|
+
const info = canvas.ui_markup.validate(try parser.parse()) orelse return error.TestUnexpectedResult;
|
|
2009
|
+
try testing.expectEqualStrings(case.message, info.message);
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
|
|
1929
2014
|
// -------------------------------------------------- component catalog fixture
|
|
1930
2015
|
|
|
1931
2016
|
pub const CatalogRow = struct {
|
|
@@ -4428,6 +4513,8 @@ test "reactions misuse fails the build with the pinned teaching messages" {
|
|
|
4428
4513
|
pub const MirrorCaretDirection = enum(u8) { previous = 0, next = 1, previous_word = 2, next_word = 3, start = 4, end = 5 };
|
|
4429
4514
|
pub const MirrorCaretMove = struct { direction: MirrorCaretDirection, extend: bool };
|
|
4430
4515
|
pub const MirrorSelection = struct { anchor: i64, focus: i64 };
|
|
4516
|
+
pub const MirrorCaretAffinity = enum(u8) { upstream = 0, downstream = 1 };
|
|
4517
|
+
pub const MirrorSelectionWithAffinity = struct { anchor: i64, focus: i64, affinity: MirrorCaretAffinity };
|
|
4431
4518
|
pub const MirrorTextInputEvent = union(enum) {
|
|
4432
4519
|
insert_text: []const u8,
|
|
4433
4520
|
delete_backward,
|
|
@@ -4455,6 +4542,20 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
|
|
|
4455
4542
|
try testing.expect(markup_view.declaredTextInputUnion(MirrorTextInputEvent));
|
|
4456
4543
|
// The canvas union itself matches structurally too (usize numerics).
|
|
4457
4544
|
try testing.expect(markup_view.declaredTextInputUnion(canvas.TextInputEvent));
|
|
4545
|
+
const MirrorTextInputEventWithAffinity = union(enum) {
|
|
4546
|
+
insert_text: []const u8,
|
|
4547
|
+
delete_backward,
|
|
4548
|
+
delete_forward,
|
|
4549
|
+
delete_word_backward,
|
|
4550
|
+
delete_word_forward,
|
|
4551
|
+
clear,
|
|
4552
|
+
move_caret: MirrorCaretMove,
|
|
4553
|
+
set_selection: MirrorSelectionWithAffinity,
|
|
4554
|
+
set_composition: struct { text: []const u8, cursor: ?i64 },
|
|
4555
|
+
commit_composition,
|
|
4556
|
+
cancel_composition,
|
|
4557
|
+
};
|
|
4558
|
+
try testing.expect(markup_view.declaredTextInputUnion(MirrorTextInputEventWithAffinity));
|
|
4458
4559
|
// Near-misses stay out: a missing arm, a non-bytes insert payload, a
|
|
4459
4560
|
// wrong caret vocabulary.
|
|
4460
4561
|
const MissingArm = union(enum) {
|
|
@@ -353,6 +353,11 @@ pub const elements = [_]ElementInfo{
|
|
|
353
353
|
// owns the keyboard, so it must carry a name — the runtime then
|
|
354
354
|
// announces the live screen text as its content.
|
|
355
355
|
.{ .code = 69, .name = "terminal", .widget_kind = "terminal", .a11y_name = .control },
|
|
356
|
+
// The reusable code surface: a source-bound composite that lowers
|
|
357
|
+
// through `Ui.code` to a highlighted panel, optionally with logical
|
|
358
|
+
// line numbers or one horizontal scroll region for unwrapped lines.
|
|
359
|
+
// Markdown fences use the same builder component.
|
|
360
|
+
.{ .code = 70, .name = "code", .rule_hook = "code", .hit_target = false },
|
|
356
361
|
};
|
|
357
362
|
|
|
358
363
|
// ------------------------------------------------------------- attributes
|
|
@@ -553,6 +558,11 @@ pub const attrs = [_]AttrInfo{
|
|
|
553
558
|
// back here and user scrollback survives rebuilds; move it
|
|
554
559
|
// model-side to scroll programmatically. 0 is pinned to the bottom.
|
|
555
560
|
.{ .code = 89, .name = "scrollback", .class = .whole, .group = .option, .field = "scrollback" },
|
|
561
|
+
// Code-surface declarations (the <code> composite; its rule hook
|
|
562
|
+
// owns the closed set). Language is a literal lexer name and line
|
|
563
|
+
// numbers are opt-in; wrapping reuses generic attr code 16.
|
|
564
|
+
.{ .code = 90, .name = "language", .class = .option, .group = .composite },
|
|
565
|
+
.{ .code = 91, .name = "line-numbers", .class = .flag, .group = .composite },
|
|
556
566
|
};
|
|
557
567
|
|
|
558
568
|
// ----------------------------------------------------------------- events
|
|
@@ -597,12 +607,13 @@ pub const events = [_]EventInfo{
|
|
|
597
607
|
// tests in ui_markup_view_tests.zig hold them equal to the live structs).
|
|
598
608
|
|
|
599
609
|
pub const color_token_names = [_][]const u8{
|
|
600
|
-
"background",
|
|
601
|
-
"text",
|
|
602
|
-
"
|
|
603
|
-
"
|
|
604
|
-
"
|
|
605
|
-
"
|
|
610
|
+
"background", "surface", "surface_subtle", "surface_pressed",
|
|
611
|
+
"text", "text_muted", "syntax_plain", "syntax_comment",
|
|
612
|
+
"syntax_keyword", "syntax_literal", "syntax_function", "syntax_property",
|
|
613
|
+
"syntax_constant", "border", "accent", "accent_text",
|
|
614
|
+
"destructive", "destructive_text", "success", "success_text",
|
|
615
|
+
"warning", "warning_text", "info", "info_text",
|
|
616
|
+
"focus_ring", "shadow", "scrim", "disabled",
|
|
606
617
|
};
|
|
607
618
|
|
|
608
619
|
pub const radius_token_names = [_][]const u8{ "sm", "md", "lg", "xl" };
|
|
@@ -21,15 +21,15 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
21
21
|
// (append or slot them anywhere — order carries no meaning) and pin
|
|
22
22
|
// the new fingerprint ONLY for additions; renames/renumbers are
|
|
23
23
|
// schema-version-bump events, not silent edits.
|
|
24
|
-
try testing.expectEqual(@as(usize,
|
|
25
|
-
try testing.expectEqual(@as(usize,
|
|
24
|
+
try testing.expectEqual(@as(usize, 70), schema.elements.len);
|
|
25
|
+
try testing.expectEqual(@as(usize, 91), schema.attrs.len);
|
|
26
26
|
try testing.expectEqual(@as(usize, 13), schema.events.len);
|
|
27
27
|
// The element table runs through the span composite (64), the
|
|
28
28
|
// bubble-reactions composite (65), the media surface (66), the
|
|
29
29
|
// runtime-image leaf (67), the video playback composite (68), and
|
|
30
|
-
// the terminal leaf (69).
|
|
30
|
+
// the terminal leaf (69), and the reusable code composite (70).
|
|
31
31
|
try testing.expectEqual(
|
|
32
|
-
@as(u64,
|
|
32
|
+
@as(u64, 0x180108eb2382ba60),
|
|
33
33
|
tableFingerprint(schema.ElementInfo, &schema.elements),
|
|
34
34
|
);
|
|
35
35
|
// The attr table runs through the split layout-tween attributes
|
|
@@ -42,9 +42,10 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
42
42
|
// surface (81), the video element attributes controls (82),
|
|
43
43
|
// autoplay (83), loop (84), and muted (85), the scroll-axis
|
|
44
44
|
// attributes axis (86) and value-x (87), and the terminal
|
|
45
|
-
// attributes pty (88) and scrollback (89)
|
|
45
|
+
// attributes pty (88) and scrollback (89), and the code language
|
|
46
|
+
// (90) and line-numbers (91) declarations.
|
|
46
47
|
try testing.expectEqual(
|
|
47
|
-
@as(u64,
|
|
48
|
+
@as(u64, 0x8c9311ac81d2a800),
|
|
48
49
|
tableFingerprint(schema.AttrInfo, &schema.attrs),
|
|
49
50
|
);
|
|
50
51
|
// The event table runs through the pointer-hover containment pair
|
|
@@ -382,6 +382,12 @@ test "single-line keyboard fallback derivation sanitizes line breaks like the ru
|
|
|
382
382
|
// A STAMPED edit (the runtime already sanitized it) passes through.
|
|
383
383
|
const stamped = canvas.WidgetKeyboardEvent{ .phase = .key_down, .edit = .{ .insert_text = "clean" } };
|
|
384
384
|
try testing.expectEqualStrings("clean", tree.msgForKeyboard(field.id, stamped).?.draft.insert_text);
|
|
385
|
+
|
|
386
|
+
// History replay stamps retained bytes, not new input. A raw newline
|
|
387
|
+
// already present in a controlled single-line value must survive the
|
|
388
|
+
// app-side mirror unchanged.
|
|
389
|
+
const stamped_history = canvas.WidgetKeyboardEvent{ .phase = .key_down, .edit = .{ .insert_text = "\n" } };
|
|
390
|
+
try testing.expectEqualStrings("\n", tree.msgForKeyboard(field.id, stamped_history).?.draft.insert_text);
|
|
385
391
|
}
|
|
386
392
|
|
|
387
393
|
test "typed handlers imply accessibility actions" {
|
|
@@ -265,9 +265,12 @@ fn widgetChange(previous: WidgetLayoutNode, next: WidgetLayoutNode, previous_ind
|
|
|
265
265
|
previous.depth != next.depth or
|
|
266
266
|
previous.parent_index != next.parent_index or
|
|
267
267
|
!rectsEqual(previous.frame, next.frame) or
|
|
268
|
+
previous.widget.code_line_number_digits != next.widget.code_line_number_digits or
|
|
268
269
|
!widgetLayoutStylesEqual(previous.widget.layout, next.widget.layout);
|
|
269
270
|
const content_dirty = !std.mem.eql(u8, previous.widget.text, next.widget.text) or
|
|
270
271
|
!textSpansEqual(previous.widget.spans, next.widget.spans) or
|
|
272
|
+
previous.widget.static_text_group_id != next.widget.static_text_group_id or
|
|
273
|
+
previous.widget.static_text_group_offset != next.widget.static_text_group_offset or
|
|
271
274
|
!chartDataEqual(previous.widget.chart, next.widget.chart) or
|
|
272
275
|
!std.mem.eql(u8, previous.widget.placeholder, next.widget.placeholder) or
|
|
273
276
|
!std.mem.eql(u8, previous.widget.icon, next.widget.icon) or
|
|
@@ -42,6 +42,7 @@ const widgetControlInset = widget_metrics.widgetControlInset;
|
|
|
42
42
|
const widgetSizedDensityValue = widget_metrics.widgetSizedDensityValue;
|
|
43
43
|
const densityValue = widget_metrics.densityValue;
|
|
44
44
|
const widgetControlHeight = widget_metrics.widgetControlHeight;
|
|
45
|
+
const widgetCodeLineNumberGutterWidth = widget_metrics.widgetCodeLineNumberGutterWidth;
|
|
45
46
|
const widgetStatusBarPadding = widget_render.widgetStatusBarPadding;
|
|
46
47
|
const controlStrokeWidth = widget_render.controlStrokeWidth;
|
|
47
48
|
const componentControlVisualTokens = widget_render.componentControlVisualTokens;
|
|
@@ -103,7 +104,7 @@ pub fn layoutWidgetDepth(
|
|
|
103
104
|
.scroll_view => if (widget.layout.virtualized)
|
|
104
105
|
try layoutVirtualVerticalChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens)
|
|
105
106
|
else
|
|
106
|
-
try layoutScrollChildren(widget.children, content, index, depth, output, len, scrollLayoutOffset(widget), tokens),
|
|
107
|
+
try layoutScrollChildren(widget.children, content, index, depth, output, len, widget.scroll_axes, scrollLayoutOffset(widget), tokens),
|
|
107
108
|
.list => if (widget.layout.virtualized)
|
|
108
109
|
try layoutVirtualVerticalChildren(widget.children, content, index, depth, output, len, widget.value, widget.layout, tokens)
|
|
109
110
|
else
|
|
@@ -825,7 +826,11 @@ fn rowChildWidth(row: Widget, available_width: f32, index: usize, tokens: Design
|
|
|
825
826
|
fn spanParagraphHeight(widget: Widget, width: f32, tokens: DesignTokens) f32 {
|
|
826
827
|
return text_spans_model.textSpansWrappedHeight(
|
|
827
828
|
widget.spans,
|
|
828
|
-
widgetTextSpanLayoutOptions(
|
|
829
|
+
widgetTextSpanLayoutOptions(
|
|
830
|
+
widget,
|
|
831
|
+
tokens,
|
|
832
|
+
@max(0, width - widgetCodeLineNumberGutterWidth(widget, tokens)),
|
|
833
|
+
),
|
|
829
834
|
);
|
|
830
835
|
}
|
|
831
836
|
|
|
@@ -836,7 +841,7 @@ fn spanParagraphHeight(widget: Widget, width: f32, tokens: DesignTokens) f32 {
|
|
|
836
841
|
/// an empty frame (never hit-testable).
|
|
837
842
|
fn layoutTextSpanLinkChildren(
|
|
838
843
|
widget: Widget,
|
|
839
|
-
|
|
844
|
+
raw_content: geometry.RectF,
|
|
840
845
|
parent_index: usize,
|
|
841
846
|
depth: usize,
|
|
842
847
|
output: []WidgetLayoutNode,
|
|
@@ -845,6 +850,12 @@ fn layoutTextSpanLinkChildren(
|
|
|
845
850
|
) Error!void {
|
|
846
851
|
if (widget.children.len == 0) return;
|
|
847
852
|
if (widget.spans.len == 0) return;
|
|
853
|
+
var content = raw_content;
|
|
854
|
+
if (widget.kind == .text) {
|
|
855
|
+
const gutter = @min(content.width, widgetCodeLineNumberGutterWidth(widget, tokens));
|
|
856
|
+
content.x += gutter;
|
|
857
|
+
content.width -= gutter;
|
|
858
|
+
}
|
|
848
859
|
|
|
849
860
|
var runs: [text_spans_model.max_text_span_runs_per_paragraph]text_spans_model.TextSpanRun = undefined;
|
|
850
861
|
const layout = text_spans_model.layoutTextSpans(
|
|
@@ -1051,13 +1062,22 @@ fn layoutScrollChildren(
|
|
|
1051
1062
|
depth: usize,
|
|
1052
1063
|
output: []WidgetLayoutNode,
|
|
1053
1064
|
len: *usize,
|
|
1065
|
+
axes: canvas.ScrollAxes,
|
|
1054
1066
|
scroll_offset: geometry.OffsetF,
|
|
1055
1067
|
tokens: DesignTokens,
|
|
1056
1068
|
) Error!void {
|
|
1057
1069
|
const scrolled_content = content.translate(geometry.OffsetF.init(-scroll_offset.dx, -scroll_offset.dy));
|
|
1058
1070
|
for (children) |child| {
|
|
1059
1071
|
if (child.layout.anchor != null) continue;
|
|
1060
|
-
|
|
1072
|
+
var child_frame = stackChildFrame(scrolled_content, child);
|
|
1073
|
+
// A `both` region must retain the same intrinsic width as a
|
|
1074
|
+
// horizontal-only shelf; otherwise its horizontal axis has no
|
|
1075
|
+
// content range even when its child paints a long no-wrap line.
|
|
1076
|
+
if (axes.scrollsHorizontally() and child.frame.width <= 0) {
|
|
1077
|
+
const intrinsic = intrinsicChildSize(child, tokens, depth + 1);
|
|
1078
|
+
child_frame.width = @max(child_frame.width, intrinsic.width);
|
|
1079
|
+
}
|
|
1080
|
+
_ = try layoutWidgetDepth(child, child_frame, parent_index, depth + 1, output, len, tokens);
|
|
1061
1081
|
}
|
|
1062
1082
|
}
|
|
1063
1083
|
|
|
@@ -1615,8 +1635,11 @@ fn intrinsicWidgetSizeDepth(widget: Widget, tokens: DesignTokens, depth: usize)
|
|
|
1615
1635
|
.dialog, .drawer, .sheet => intrinsicModalSurfaceWidgetSize(widget, tokens, depth),
|
|
1616
1636
|
// Containers measure their children (matching the stacking axis the
|
|
1617
1637
|
// layout pass uses), bounded by the widget depth cap. Scroll
|
|
1618
|
-
// viewports and virtualized containers stay zero
|
|
1619
|
-
// allowed to overflow the space they're
|
|
1638
|
+
// viewports and virtualized containers stay zero on each axis they
|
|
1639
|
+
// scroll: their content is allowed to overflow the space they're
|
|
1640
|
+
// given. A horizontal-only viewport still reports its child's
|
|
1641
|
+
// height, so an inline code scroller hugs its rows instead of
|
|
1642
|
+
// collapsing to a zero-height clip.
|
|
1620
1643
|
.row, .breadcrumb, .button_group, .pagination, .radio_group, .tabs, .toggle_group => intrinsicAxisChildrenSize(widget, tokens, .horizontal, depth),
|
|
1621
1644
|
.column, .menu_surface, .dropdown_menu, .input_group => intrinsicAxisChildrenSize(widget, tokens, .vertical, depth),
|
|
1622
1645
|
.list, .data_grid, .table => if (widget.layout.virtualized)
|
|
@@ -1640,7 +1663,10 @@ fn intrinsicWidgetSizeDepth(widget: Widget, tokens: DesignTokens, depth: usize)
|
|
|
1640
1663
|
// Terminals join them: the grid derives its cols/rows FROM the
|
|
1641
1664
|
// space it is given (the runtime resizes the pty to fit), so
|
|
1642
1665
|
// reporting an intrinsic size would invert the contract.
|
|
1643
|
-
.scroll_view
|
|
1666
|
+
.scroll_view => if (!widget.layout.virtualized and widget.scroll_axes == .horizontal) blk: {
|
|
1667
|
+
break :blk intrinsicHorizontalScrollSize(widget, tokens, depth);
|
|
1668
|
+
} else geometry.SizeF.zero(),
|
|
1669
|
+
.image, .split, .media_surface, .terminal => geometry.SizeF.zero(),
|
|
1644
1670
|
};
|
|
1645
1671
|
}
|
|
1646
1672
|
|
|
@@ -1723,6 +1749,28 @@ fn intrinsicOverlayChildrenSize(widget: Widget, tokens: DesignTokens, depth: usi
|
|
|
1723
1749
|
return paddedIntrinsicSize(widget, geometry.SizeF.init(width_max, height_max));
|
|
1724
1750
|
}
|
|
1725
1751
|
|
|
1752
|
+
/// A horizontal viewport stays width-neutral but hugs the full vertical
|
|
1753
|
+
/// extent of its unwrapped content. Span paragraphs report a one-line
|
|
1754
|
+
/// intrinsic height, so measure each child through the width-aware seam at
|
|
1755
|
+
/// its natural width; explicit newlines then contribute every painted row.
|
|
1756
|
+
fn intrinsicHorizontalScrollSize(widget: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
1757
|
+
if (depth >= max_widget_depth or widget.children.len == 0) {
|
|
1758
|
+
return geometry.SizeF.init(0, intrinsicOwnMinSize(widget).height);
|
|
1759
|
+
}
|
|
1760
|
+
var height_max: f32 = 0;
|
|
1761
|
+
for (widget.children) |child| {
|
|
1762
|
+
if (child.layout.anchor != null) continue;
|
|
1763
|
+
const intrinsic = intrinsicChildSize(child, tokens, depth + 1);
|
|
1764
|
+
const child_width = if (child.frame.width > 0) child.frame.width else intrinsic.width;
|
|
1765
|
+
height_max = @max(
|
|
1766
|
+
height_max,
|
|
1767
|
+
wrappedVerticalExtentForWidth(child, child_width, tokens, depth + 1),
|
|
1768
|
+
);
|
|
1769
|
+
}
|
|
1770
|
+
const padded = paddedIntrinsicSize(widget, geometry.SizeF.init(0, height_max));
|
|
1771
|
+
return geometry.SizeF.init(0, padded.height);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1726
1774
|
fn intrinsicGridChildrenSize(widget: Widget, tokens: DesignTokens, depth: usize) geometry.SizeF {
|
|
1727
1775
|
if (depth >= max_widget_depth or widget.children.len == 0) return intrinsicOwnMinSize(widget);
|
|
1728
1776
|
var cell_width: f32 = 0;
|
|
@@ -1761,7 +1809,8 @@ fn intrinsicTextWidgetSize(widget: Widget, tokens: DesignTokens, text_size: f32)
|
|
|
1761
1809
|
if (widgetIsSpanParagraph(widget)) {
|
|
1762
1810
|
const options = widgetTextSpanLayoutOptions(widget, tokens, 0);
|
|
1763
1811
|
return geometry.SizeF.init(
|
|
1764
|
-
text_spans_model.textSpansIntrinsicWidth(widget.spans, options)
|
|
1812
|
+
text_spans_model.textSpansIntrinsicWidth(widget.spans, options) +
|
|
1813
|
+
widgetCodeLineNumberGutterWidth(widget, tokens),
|
|
1765
1814
|
widgetLineHeight(text_size * text_spans_model.textSpansMaxScale(widget.spans)),
|
|
1766
1815
|
);
|
|
1767
1816
|
}
|
|
@@ -2669,6 +2669,41 @@ fn doubledTextMeasure(context: ?*anyopaque, font_id: FontId, size: f32, text: []
|
|
|
2669
2669
|
|
|
2670
2670
|
const doubled_text_measure = support.TextMeasureProvider{ .measure_fn = doubledTextMeasure };
|
|
2671
2671
|
|
|
2672
|
+
fn countingTextMeasure(context: ?*anyopaque, font_id: FontId, size: f32, text: []const u8) f32 {
|
|
2673
|
+
const calls: *usize = @ptrCast(@alignCast(context.?));
|
|
2674
|
+
calls.* += 1;
|
|
2675
|
+
_ = font_id;
|
|
2676
|
+
return size * @as(f32, @floatFromInt(text.len));
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
test "vertical scroll layout does not intrinsically remeasure its child" {
|
|
2680
|
+
var calls: usize = 0;
|
|
2681
|
+
const measure = support.TextMeasureProvider{
|
|
2682
|
+
.context = &calls,
|
|
2683
|
+
.measure_fn = countingTextMeasure,
|
|
2684
|
+
};
|
|
2685
|
+
const children = [_]Widget{.{
|
|
2686
|
+
.id = 2,
|
|
2687
|
+
.kind = .text,
|
|
2688
|
+
.text = "transcript row",
|
|
2689
|
+
}};
|
|
2690
|
+
const scroll = Widget{
|
|
2691
|
+
.id = 1,
|
|
2692
|
+
.kind = .scroll_view,
|
|
2693
|
+
.scroll_axes = .vertical,
|
|
2694
|
+
.children = &children,
|
|
2695
|
+
};
|
|
2696
|
+
|
|
2697
|
+
var nodes: [2]WidgetLayoutNode = undefined;
|
|
2698
|
+
_ = try layoutWidgetTreeWithTokens(
|
|
2699
|
+
scroll,
|
|
2700
|
+
geometry.RectF.init(0, 0, 240, 120),
|
|
2701
|
+
.{ .text_measure = &measure },
|
|
2702
|
+
&nodes,
|
|
2703
|
+
);
|
|
2704
|
+
try std.testing.expectEqual(@as(usize, 0), calls);
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2672
2707
|
test "intrinsic text sizing defaults to the estimator and honors an injected provider" {
|
|
2673
2708
|
const widget = Widget{ .id = 1, .kind = .text, .text = "Refresh dashboard" };
|
|
2674
2709
|
const default_tokens = DesignTokens{};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
|
+
const geometry = @import("geometry");
|
|
2
3
|
const token_model = @import("tokens.zig");
|
|
3
4
|
const widget_model = @import("widgets.zig");
|
|
5
|
+
const text_model = @import("text.zig");
|
|
4
6
|
const text_spans_model = @import("text_spans.zig");
|
|
5
7
|
|
|
6
8
|
const Density = token_model.Density;
|
|
@@ -103,13 +105,40 @@ pub fn widgetTextSpanLayoutOptions(widget: Widget, tokens: DesignTokens, max_wid
|
|
|
103
105
|
return .{
|
|
104
106
|
.size = widgetBodyTextSize(widget, tokens),
|
|
105
107
|
.max_width = max_width,
|
|
106
|
-
.wrap = .word,
|
|
108
|
+
.wrap = if (widget.text_no_wrap) .none else .word,
|
|
107
109
|
.alignment = widget.text_alignment,
|
|
108
110
|
.typography = tokens.typography,
|
|
109
111
|
.measure = tokens.text_measure,
|
|
110
112
|
};
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
/// Width reserved before a numbered code paragraph: the largest muted
|
|
116
|
+
/// monospace marker plus the component's fixed marker-to-source gap.
|
|
117
|
+
/// Marker bytes never live in `Widget.text`; paint selects them from a
|
|
118
|
+
/// compile-time table.
|
|
119
|
+
pub fn widgetCodeLineNumberGutterWidth(widget: Widget, tokens: DesignTokens) f32 {
|
|
120
|
+
if (widget.code_line_number_digits == 0) return 0;
|
|
121
|
+
const zeros: [20]u8 = @splat('0');
|
|
122
|
+
const digits = @min(@as(usize, widget.code_line_number_digits), zeros.len);
|
|
123
|
+
return text_model.measureTextWidthForFont(
|
|
124
|
+
tokens.text_measure,
|
|
125
|
+
tokens.typography.mono_font_id,
|
|
126
|
+
zeros[0..digits],
|
|
127
|
+
widgetBodyTextSize(widget, tokens),
|
|
128
|
+
) + 12;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// Span paragraph content after authored padding and the engine-owned code
|
|
132
|
+
/// gutter. Layout, painting, hit mapping, and selection all use this exact
|
|
133
|
+
/// frame so numbered source stays one coherent text model.
|
|
134
|
+
pub fn widgetTextSpanContentFrame(widget: Widget, tokens: DesignTokens) geometry.RectF {
|
|
135
|
+
var content = widget.frame.inset(widget.layout.padding);
|
|
136
|
+
const gutter = @min(content.width, widgetCodeLineNumberGutterWidth(widget, tokens));
|
|
137
|
+
content.x += gutter;
|
|
138
|
+
content.width -= gutter;
|
|
139
|
+
return content;
|
|
140
|
+
}
|
|
141
|
+
|
|
113
142
|
/// The ONE control height register — buttons, inputs, and select
|
|
114
143
|
/// triggers all sit on the whole-pixel token ladder
|
|
115
144
|
/// (`metrics.control_height_sm`/`control_height`/`control_height_lg`,
|