nomen-lang 0.7.1 → 0.8.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.
Files changed (50) hide show
  1. package/core/System/Buffer.nm +32 -0
  2. package/core/System/ClassBuffer.nm +24 -0
  3. package/core/System/Controls/Alert.nm +326 -0
  4. package/core/System/Controls/App.nm +147 -0
  5. package/core/System/Controls/Button.nm +119 -1
  6. package/core/System/Controls/CheckBox.nm +24 -0
  7. package/core/System/Controls/ColorPicker.nm +307 -0
  8. package/core/System/Controls/ComboBox.nm +430 -0
  9. package/core/System/Controls/Container.nm +837 -9
  10. package/core/System/Controls/Control.nm +443 -0
  11. package/core/System/Controls/DatePicker.nm +288 -0
  12. package/core/System/Controls/Form.nm +70 -0
  13. package/core/System/Controls/GroupBox.nm +267 -0
  14. package/core/System/Controls/ImageView.nm +311 -0
  15. package/core/System/Controls/LevelIndicator.nm +305 -0
  16. package/core/System/Controls/ListView.nm +633 -0
  17. package/core/System/Controls/Menu.nm +428 -0
  18. package/core/System/Controls/NumberInput.nm +56 -0
  19. package/core/System/Controls/OtpInput.nm +50 -0
  20. package/core/System/Controls/OutlineView.nm +598 -0
  21. package/core/System/Controls/Pagination.nm +142 -0
  22. package/core/System/Controls/Popover.nm +296 -0
  23. package/core/System/Controls/Progress.nm +348 -0
  24. package/core/System/Controls/Radio.nm +292 -0
  25. package/core/System/Controls/Scrollable.nm +584 -0
  26. package/core/System/Controls/SearchField.nm +326 -0
  27. package/core/System/Controls/SecureField.nm +344 -0
  28. package/core/System/Controls/Segmented.nm +380 -0
  29. package/core/System/Controls/Select.nm +340 -0
  30. package/core/System/Controls/Separator.nm +198 -0
  31. package/core/System/Controls/Sheet.nm +329 -0
  32. package/core/System/Controls/Slider.nm +315 -0
  33. package/core/System/Controls/Spinner.nm +287 -0
  34. package/core/System/Controls/SplitView.nm +509 -0
  35. package/core/System/Controls/Stepper.nm +349 -0
  36. package/core/System/Controls/Switch.nm +259 -0
  37. package/core/System/Controls/Table.nm +833 -0
  38. package/core/System/Controls/Tabs.nm +500 -0
  39. package/core/System/Controls/Text.nm +108 -11
  40. package/core/System/Controls/TextBox.nm +112 -1
  41. package/core/System/Controls/TextView.nm +329 -0
  42. package/core/System/Controls/Toggle.nm +346 -0
  43. package/core/System/Controls/Toolbar.nm +501 -0
  44. package/core/System/Controls/Tooltip.nm +76 -0
  45. package/core/System/Controls/Window.nm +1549 -91
  46. package/core/System/List.nm +34 -0
  47. package/core/System/Map.nm +21 -4
  48. package/core/System/Set.nm +14 -0
  49. package/dist/index.mjs +2556 -656
  50. package/package.json +1 -1
@@ -0,0 +1,326 @@
1
+ /**
2
+ * A search input — a TextBox with the system's search affordances
3
+ *
4
+ * An OWNING STRUCT (STRUCT_PLAN_3 Phase R, tranche 4 — the shape menu): the
5
+ * single field is a platform handle, so the value is movable and its
6
+ * `#destroy` releases what the handle names. The constructor's `self` is
7
+ * the inline instance (the `.` accessor); methods keep the pointer form.
8
+ *
9
+ * NSSearchField gives the magnifier icon, placeholder, and Cancel button for
10
+ * free; UISearchTextField is the iOS 13+ equivalent.
11
+ **/
12
+ pub mv struct SearchField : Control {
13
+ var uint64 handle = 0
14
+
15
+ pub func #init = (self, Window window) {
16
+ ```
17
+ #arch: c
18
+ #platform: macos
19
+ id field = ((id(*)(id, SEL, CGRect))objc_msgSend)(
20
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSSearchField"), sel_registerName("alloc")),
21
+ sel_registerName("initWithFrame:"),
22
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 24));
23
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
24
+ field, sel_registerName("setEditable:"), 1);
25
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
26
+ field, sel_registerName("setSelectable:"), 1);
27
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
28
+ (id)window->handle, sel_registerName("contentView"));
29
+ ((void(*)(id, SEL, id))objc_msgSend)(
30
+ contentView, sel_registerName("addSubview:"), field);
31
+ // NSSearchField sends its action on the USER commit (Return) — arm
32
+ // it so on_submit drains fire (programmatic set_text stays silent).
33
+ extern void nomen_control_arm_submits(unsigned long long);
34
+ nomen_control_arm_submits((unsigned long long)field);
35
+ self.handle = (uint64_t)field;
36
+ ```
37
+ ```
38
+ #arch: aarch64_use_c
39
+ #platform: macos
40
+ id field = ((id(*)(id, SEL, CGRect))objc_msgSend)(
41
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSSearchField"), sel_registerName("alloc")),
42
+ sel_registerName("initWithFrame:"),
43
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 24));
44
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
45
+ field, sel_registerName("setEditable:"), 1);
46
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
47
+ field, sel_registerName("setSelectable:"), 1);
48
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
49
+ (id)window->handle, sel_registerName("contentView"));
50
+ ((void(*)(id, SEL, id))objc_msgSend)(
51
+ contentView, sel_registerName("addSubview:"), field);
52
+ extern void nomen_control_arm_submits(unsigned long long) __asm__("nomen_control_arm_submits");
53
+ nomen_control_arm_submits((unsigned long long)field);
54
+ self->handle = (uint64_t)field;
55
+ ```
56
+ ```
57
+ #arch: c
58
+ #platform: ios
59
+ id field = ((id(*)(id, SEL, CGRect))objc_msgSend)(
60
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UISearchTextField"), sel_registerName("alloc")),
61
+ sel_registerName("initWithFrame:"),
62
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 30));
63
+ id parentView = ((id(*)(id, SEL))objc_msgSend)(
64
+ ((id(*)(id, SEL))objc_msgSend)(
65
+ (id)window->handle, sel_registerName("rootViewController")),
66
+ sel_registerName("view"));
67
+ ((void(*)(id, SEL, id))objc_msgSend)(
68
+ parentView, sel_registerName("addSubview:"), field);
69
+ self.handle = (uint64_t)field;
70
+ ```
71
+ ```
72
+ #arch: aarch64_use_c
73
+ #platform: ios
74
+ id field = ((id(*)(id, SEL, CGRect))objc_msgSend)(
75
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UISearchTextField"), sel_registerName("alloc")),
76
+ sel_registerName("initWithFrame:"),
77
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 30));
78
+ id parentView = ((id(*)(id, SEL))objc_msgSend)(
79
+ ((id(*)(id, SEL))objc_msgSend)(
80
+ (id)window->handle, sel_registerName("rootViewController")),
81
+ sel_registerName("view"));
82
+ ((void(*)(id, SEL, id))objc_msgSend)(
83
+ parentView, sel_registerName("addSubview:"), field);
84
+ self->handle = (uint64_t)field;
85
+ ```
86
+ }
87
+
88
+ pub func set_frame = (ref self, int x, int y, int width, int height) {
89
+ ```
90
+ #arch: c
91
+ #platform: macos
92
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
93
+ (id)self->handle, sel_registerName("setFrame:"),
94
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
95
+ ```
96
+ ```
97
+ #arch: aarch64_use_c
98
+ #platform: macos
99
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
100
+ (id)self->handle, sel_registerName("setFrame:"),
101
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
102
+ ```
103
+ ```
104
+ #arch: c
105
+ #platform: ios
106
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
107
+ (id)self->handle, sel_registerName("setFrame:"),
108
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
109
+ ```
110
+ ```
111
+ #arch: aarch64_use_c
112
+ #platform: ios
113
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
114
+ (id)self->handle, sel_registerName("setFrame:"),
115
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
116
+ ```
117
+ }
118
+
119
+ pub func set_text = (self, string text) {
120
+ ```
121
+ #arch: c
122
+ #platform: macos
123
+ ((void(*)(id, SEL, id))objc_msgSend)(
124
+ (id)self->handle, sel_registerName("setStringValue:"),
125
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
126
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
127
+ ```
128
+ ```
129
+ #arch: aarch64_use_c
130
+ #platform: macos
131
+ ((void(*)(id, SEL, id))objc_msgSend)(
132
+ (id)self->handle, sel_registerName("setStringValue:"),
133
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
134
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
135
+ ```
136
+ ```
137
+ #arch: c
138
+ #platform: ios
139
+ ((void(*)(id, SEL, id))objc_msgSend)(
140
+ (id)self->handle, sel_registerName("setText:"),
141
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
142
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
143
+ ```
144
+ ```
145
+ #arch: aarch64_use_c
146
+ #platform: ios
147
+ ((void(*)(id, SEL, id))objc_msgSend)(
148
+ (id)self->handle, sel_registerName("setText:"),
149
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
150
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
151
+ ```
152
+ }
153
+
154
+ // The gray hint text shown while the field is empty; not the value —
155
+ // get_text still reports "" until the user types.
156
+ pub func set_placeholder = (self, string text) {
157
+ ```
158
+ #arch: c
159
+ #platform: macos
160
+ ((void(*)(id, SEL, id))objc_msgSend)(
161
+ (id)self->handle, sel_registerName("setPlaceholderString:"),
162
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
163
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
164
+ ```
165
+ ```
166
+ #arch: aarch64_use_c
167
+ #platform: macos
168
+ ((void(*)(id, SEL, id))objc_msgSend)(
169
+ (id)self->handle, sel_registerName("setPlaceholderString:"),
170
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
171
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
172
+ ```
173
+ ```
174
+ #arch: c
175
+ #platform: ios
176
+ ((void(*)(id, SEL, id))objc_msgSend)(
177
+ (id)self->handle, sel_registerName("setPlaceholder:"),
178
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
179
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
180
+ ```
181
+ ```
182
+ #arch: aarch64_use_c
183
+ #platform: ios
184
+ ((void(*)(id, SEL, id))objc_msgSend)(
185
+ (id)self->handle, sel_registerName("setPlaceholder:"),
186
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
187
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
188
+ ```
189
+ }
190
+
191
+ pub func get_text = (self, out string) {
192
+ ```
193
+ #arch: c
194
+ #platform: macos
195
+ id str = ((id(*)(id, SEL))objc_msgSend)(
196
+ (id)self->handle, sel_registerName("stringValue"));
197
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
198
+ str, sel_registerName("UTF8String"));
199
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
200
+ ```
201
+ ```
202
+ #arch: aarch64_use_c
203
+ #platform: macos
204
+ id str = ((id(*)(id, SEL))objc_msgSend)(
205
+ (id)self->handle, sel_registerName("stringValue"));
206
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
207
+ str, sel_registerName("UTF8String"));
208
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
209
+ ```
210
+ ```
211
+ #arch: c
212
+ #platform: ios
213
+ id str = ((id(*)(id, SEL))objc_msgSend)(
214
+ (id)self->handle, sel_registerName("text"));
215
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
216
+ str, sel_registerName("UTF8String"));
217
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
218
+ ```
219
+ ```
220
+ #arch: aarch64_use_c
221
+ #platform: ios
222
+ id str = ((id(*)(id, SEL))objc_msgSend)(
223
+ (id)self->handle, sel_registerName("text"));
224
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
225
+ str, sel_registerName("UTF8String"));
226
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
227
+ ```
228
+ }
229
+
230
+ // The on_submit desugar's drain (docs/HANDLERS.md tier 2): true when
231
+ // the user committed this field (Return) since the last drain — the
232
+ // record is consumed, one commit fires an arm exactly once.
233
+ // User-driven only. The handler body reads the committed text through
234
+ // get_text().
235
+ pub func take_submit = (self, out bool) {
236
+ ```
237
+ #arch: c
238
+ #platform: macos
239
+ extern long nomen_submit_take(unsigned long long);
240
+ return (long)nomen_submit_take((unsigned long long)self->handle);
241
+ ```
242
+ ```
243
+ #arch: aarch64_use_c
244
+ #platform: macos
245
+ extern long nomen_submit_take(unsigned long long);
246
+ return (long)nomen_submit_take((unsigned long long)self->handle);
247
+ ```
248
+ ```
249
+ #arch: c
250
+ #platform: ios
251
+ /* TODO: iOS (see #init) */
252
+ return false;
253
+ ```
254
+ ```
255
+ #arch: aarch64_use_c
256
+ #platform: ios
257
+ /* TODO: iOS (see #init) */
258
+ return false;
259
+ ```
260
+ }
261
+
262
+ // ── Control trait conformance ──
263
+ pub func intrinsic_size = (self, out Size) {
264
+ var [w, h] = native_intrinsic(self.handle)
265
+ var s = Size()
266
+ s.width = w
267
+ s.height = h
268
+ return s
269
+ }
270
+
271
+ pub func measure = (self, BoxConstraints constraints, out Size) {
272
+ var Size s = self.intrinsic_size()
273
+ if s.width > constraints.max_width {
274
+ s.width = constraints.max_width
275
+ }
276
+ if s.width < constraints.min_width {
277
+ s.width = constraints.min_width
278
+ }
279
+ if s.height > constraints.max_height {
280
+ s.height = constraints.max_height
281
+ }
282
+ if s.height < constraints.min_height {
283
+ s.height = constraints.min_height
284
+ }
285
+ return s
286
+ }
287
+
288
+ func #destroy = () {
289
+ ```
290
+ #arch: c
291
+ #platform: macos
292
+ if (self->handle) {
293
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
294
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
295
+ self->handle = 0;
296
+ }
297
+ ```
298
+ ```
299
+ #arch: aarch64_use_c
300
+ #platform: macos
301
+ if (self->handle) {
302
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
303
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
304
+ self->handle = 0;
305
+ }
306
+ ```
307
+ ```
308
+ #arch: c
309
+ #platform: ios
310
+ if (self->handle) {
311
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
312
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
313
+ self->handle = 0;
314
+ }
315
+ ```
316
+ ```
317
+ #arch: aarch64_use_c
318
+ #platform: ios
319
+ if (self->handle) {
320
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
321
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
322
+ self->handle = 0;
323
+ }
324
+ ```
325
+ }
326
+ }
@@ -0,0 +1,344 @@
1
+ /**
2
+ * A password input — a TextBox that masks what the user types
3
+ *
4
+ * An OWNING STRUCT (STRUCT_PLAN_3 Phase R, tranche 4 — the shape menu): the
5
+ * single field is a platform handle, so the value is movable and its
6
+ * `#destroy` releases what the handle names. The constructor's `self` is
7
+ * the inline instance (the `.` accessor); methods keep the pointer form.
8
+ *
9
+ * A distinct native class on both platforms (NSSecureTextField is NOT
10
+ * NSTextField), so it lands as its own control rather than a TextBox mode.
11
+ **/
12
+ pub mv struct SecureField : Control {
13
+ var uint64 handle = 0
14
+
15
+ pub func #init = (self, Window window) {
16
+ ```
17
+ #arch: c
18
+ #platform: macos
19
+ id field = ((id(*)(id, SEL, CGRect))objc_msgSend)(
20
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSSecureTextField"), sel_registerName("alloc")),
21
+ sel_registerName("initWithFrame:"),
22
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 24));
23
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
24
+ field, sel_registerName("setEditable:"), 1);
25
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
26
+ field, sel_registerName("setSelectable:"), 1);
27
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
28
+ field, sel_registerName("setBordered:"), 1);
29
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
30
+ field, sel_registerName("setBezeled:"), 1);
31
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
32
+ field, sel_registerName("setDrawsBackground:"), 1);
33
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
34
+ (id)window->handle, sel_registerName("contentView"));
35
+ ((void(*)(id, SEL, id))objc_msgSend)(
36
+ contentView, sel_registerName("addSubview:"), field);
37
+ // NSTextField (the secure subclass) sends its action on the USER
38
+ // commit (Return) — arm it so on_submit drains fire.
39
+ extern void nomen_control_arm_submits(unsigned long long);
40
+ nomen_control_arm_submits((unsigned long long)field);
41
+ self.handle = (uint64_t)field;
42
+ ```
43
+ ```
44
+ #arch: aarch64_use_c
45
+ #platform: macos
46
+ id field = ((id(*)(id, SEL, CGRect))objc_msgSend)(
47
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSSecureTextField"), sel_registerName("alloc")),
48
+ sel_registerName("initWithFrame:"),
49
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 24));
50
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
51
+ field, sel_registerName("setEditable:"), 1);
52
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
53
+ field, sel_registerName("setSelectable:"), 1);
54
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
55
+ field, sel_registerName("setBordered:"), 1);
56
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
57
+ field, sel_registerName("setBezeled:"), 1);
58
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
59
+ field, sel_registerName("setDrawsBackground:"), 1);
60
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
61
+ (id)window->handle, sel_registerName("contentView"));
62
+ ((void(*)(id, SEL, id))objc_msgSend)(
63
+ contentView, sel_registerName("addSubview:"), field);
64
+ extern void nomen_control_arm_submits(unsigned long long) __asm__("nomen_control_arm_submits");
65
+ nomen_control_arm_submits((unsigned long long)field);
66
+ self->handle = (uint64_t)field;
67
+ ```
68
+ ```
69
+ #arch: c
70
+ #platform: ios
71
+ id field = ((id(*)(id, SEL, CGRect))objc_msgSend)(
72
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UITextField"), sel_registerName("alloc")),
73
+ sel_registerName("initWithFrame:"),
74
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 30));
75
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
76
+ field, sel_registerName("setBorderStyle:"), 1); // UITextBorderStyleRoundedRect = 1
77
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
78
+ field, sel_registerName("setSecureTextEntry:"), 1);
79
+ id parentView = ((id(*)(id, SEL))objc_msgSend)(
80
+ ((id(*)(id, SEL))objc_msgSend)(
81
+ (id)window->handle, sel_registerName("rootViewController")),
82
+ sel_registerName("view"));
83
+ ((void(*)(id, SEL, id))objc_msgSend)(
84
+ parentView, sel_registerName("addSubview:"), field);
85
+ self.handle = (uint64_t)field;
86
+ ```
87
+ ```
88
+ #arch: aarch64_use_c
89
+ #platform: ios
90
+ id field = ((id(*)(id, SEL, CGRect))objc_msgSend)(
91
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UITextField"), sel_registerName("alloc")),
92
+ sel_registerName("initWithFrame:"),
93
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 30));
94
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
95
+ field, sel_registerName("setBorderStyle:"), 1); // UITextBorderStyleRoundedRect = 1
96
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
97
+ field, sel_registerName("setSecureTextEntry:"), 1);
98
+ id parentView = ((id(*)(id, SEL))objc_msgSend)(
99
+ ((id(*)(id, SEL))objc_msgSend)(
100
+ (id)window->handle, sel_registerName("rootViewController")),
101
+ sel_registerName("view"));
102
+ ((void(*)(id, SEL, id))objc_msgSend)(
103
+ parentView, sel_registerName("addSubview:"), field);
104
+ self->handle = (uint64_t)field;
105
+ ```
106
+ }
107
+
108
+ pub func set_frame = (ref self, int x, int y, int width, int height) {
109
+ ```
110
+ #arch: c
111
+ #platform: macos
112
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
113
+ (id)self->handle, sel_registerName("setFrame:"),
114
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
115
+ ```
116
+ ```
117
+ #arch: aarch64_use_c
118
+ #platform: macos
119
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
120
+ (id)self->handle, sel_registerName("setFrame:"),
121
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
122
+ ```
123
+ ```
124
+ #arch: c
125
+ #platform: ios
126
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
127
+ (id)self->handle, sel_registerName("setFrame:"),
128
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
129
+ ```
130
+ ```
131
+ #arch: aarch64_use_c
132
+ #platform: ios
133
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
134
+ (id)self->handle, sel_registerName("setFrame:"),
135
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
136
+ ```
137
+ }
138
+
139
+ pub func set_text = (self, string text) {
140
+ ```
141
+ #arch: c
142
+ #platform: macos
143
+ ((void(*)(id, SEL, id))objc_msgSend)(
144
+ (id)self->handle, sel_registerName("setStringValue:"),
145
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
146
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
147
+ ```
148
+ ```
149
+ #arch: aarch64_use_c
150
+ #platform: macos
151
+ ((void(*)(id, SEL, id))objc_msgSend)(
152
+ (id)self->handle, sel_registerName("setStringValue:"),
153
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
154
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
155
+ ```
156
+ ```
157
+ #arch: c
158
+ #platform: ios
159
+ ((void(*)(id, SEL, id))objc_msgSend)(
160
+ (id)self->handle, sel_registerName("setText:"),
161
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
162
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
163
+ ```
164
+ ```
165
+ #arch: aarch64_use_c
166
+ #platform: ios
167
+ ((void(*)(id, SEL, id))objc_msgSend)(
168
+ (id)self->handle, sel_registerName("setText:"),
169
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
170
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
171
+ ```
172
+ }
173
+
174
+ pub func set_placeholder = (self, string text) {
175
+ ```
176
+ #arch: c
177
+ #platform: macos
178
+ ((void(*)(id, SEL, id))objc_msgSend)(
179
+ (id)self->handle, sel_registerName("setPlaceholderString:"),
180
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
181
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
182
+ ```
183
+ ```
184
+ #arch: aarch64_use_c
185
+ #platform: macos
186
+ ((void(*)(id, SEL, id))objc_msgSend)(
187
+ (id)self->handle, sel_registerName("setPlaceholderString:"),
188
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
189
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
190
+ ```
191
+ ```
192
+ #arch: c
193
+ #platform: ios
194
+ ((void(*)(id, SEL, id))objc_msgSend)(
195
+ (id)self->handle, sel_registerName("setPlaceholder:"),
196
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
197
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
198
+ ```
199
+ ```
200
+ #arch: aarch64_use_c
201
+ #platform: ios
202
+ ((void(*)(id, SEL, id))objc_msgSend)(
203
+ (id)self->handle, sel_registerName("setPlaceholder:"),
204
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
205
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
206
+ ```
207
+ }
208
+
209
+ pub func get_text = (self, out string) {
210
+ ```
211
+ #arch: c
212
+ #platform: macos
213
+ id str = ((id(*)(id, SEL))objc_msgSend)(
214
+ (id)self->handle, sel_registerName("stringValue"));
215
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
216
+ str, sel_registerName("UTF8String"));
217
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
218
+ ```
219
+ ```
220
+ #arch: aarch64_use_c
221
+ #platform: macos
222
+ id str = ((id(*)(id, SEL))objc_msgSend)(
223
+ (id)self->handle, sel_registerName("stringValue"));
224
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
225
+ str, sel_registerName("UTF8String"));
226
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
227
+ ```
228
+ ```
229
+ #arch: c
230
+ #platform: ios
231
+ id str = ((id(*)(id, SEL))objc_msgSend)(
232
+ (id)self->handle, sel_registerName("text"));
233
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
234
+ str, sel_registerName("UTF8String"));
235
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
236
+ ```
237
+ ```
238
+ #arch: aarch64_use_c
239
+ #platform: ios
240
+ id str = ((id(*)(id, SEL))objc_msgSend)(
241
+ (id)self->handle, sel_registerName("text"));
242
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
243
+ str, sel_registerName("UTF8String"));
244
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
245
+ ```
246
+ }
247
+
248
+ // The on_submit desugar's drain (docs/HANDLERS.md tier 2): true when
249
+ // the user committed this field (Return) since the last drain — the
250
+ // record is consumed, one commit fires an arm exactly once.
251
+ // User-driven only. The handler body reads the committed text through
252
+ // get_text().
253
+ pub func take_submit = (self, out bool) {
254
+ ```
255
+ #arch: c
256
+ #platform: macos
257
+ extern long nomen_submit_take(unsigned long long);
258
+ return (long)nomen_submit_take((unsigned long long)self->handle);
259
+ ```
260
+ ```
261
+ #arch: aarch64_use_c
262
+ #platform: macos
263
+ extern long nomen_submit_take(unsigned long long);
264
+ return (long)nomen_submit_take((unsigned long long)self->handle);
265
+ ```
266
+ ```
267
+ #arch: c
268
+ #platform: ios
269
+ /* TODO: iOS (see #init) */
270
+ return false;
271
+ ```
272
+ ```
273
+ #arch: aarch64_use_c
274
+ #platform: ios
275
+ /* TODO: iOS (see #init) */
276
+ return false;
277
+ ```
278
+ }
279
+
280
+ // ── Control trait conformance ──
281
+ pub func intrinsic_size = (self, out Size) {
282
+ var [w, h] = native_intrinsic(self.handle)
283
+ var s = Size()
284
+ s.width = w
285
+ s.height = h
286
+ return s
287
+ }
288
+
289
+ pub func measure = (self, BoxConstraints constraints, out Size) {
290
+ var Size s = self.intrinsic_size()
291
+ if s.width > constraints.max_width {
292
+ s.width = constraints.max_width
293
+ }
294
+ if s.width < constraints.min_width {
295
+ s.width = constraints.min_width
296
+ }
297
+ if s.height > constraints.max_height {
298
+ s.height = constraints.max_height
299
+ }
300
+ if s.height < constraints.min_height {
301
+ s.height = constraints.min_height
302
+ }
303
+ return s
304
+ }
305
+
306
+ func #destroy = () {
307
+ ```
308
+ #arch: c
309
+ #platform: macos
310
+ if (self->handle) {
311
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
312
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
313
+ self->handle = 0;
314
+ }
315
+ ```
316
+ ```
317
+ #arch: aarch64_use_c
318
+ #platform: macos
319
+ if (self->handle) {
320
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
321
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
322
+ self->handle = 0;
323
+ }
324
+ ```
325
+ ```
326
+ #arch: c
327
+ #platform: ios
328
+ if (self->handle) {
329
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
330
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
331
+ self->handle = 0;
332
+ }
333
+ ```
334
+ ```
335
+ #arch: aarch64_use_c
336
+ #platform: ios
337
+ if (self->handle) {
338
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
339
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
340
+ self->handle = 0;
341
+ }
342
+ ```
343
+ }
344
+ }