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,430 @@
1
+ /**
2
+ * An editable text field with a dropdown of completions (NSComboBox)
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
+ * Items live in the combo box's own internal list (no data source); the
10
+ * text is polled per frame like every other control (stringValue), and
11
+ * `selected_index` reports -1 once the user edits the text freely.
12
+ * macOS-only (NSComboBox has no iOS counterpart — see GUI_PLAN Tier 2; the
13
+ * iOS blocks are TODO stubs).
14
+ **/
15
+ pub mv struct ComboBox : Control {
16
+ var uint64 handle = 0
17
+
18
+ pub func #init = (self, Window window) {
19
+ ```
20
+ #arch: c
21
+ #platform: macos
22
+ id cb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
23
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSComboBox"), sel_registerName("alloc")),
24
+ sel_registerName("initWithFrame:"),
25
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 26));
26
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(cb, sel_registerName("setCompletes:"), 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:"), cb);
31
+ // NSComboBox sends its action on USER selection (list pick or
32
+ // Return) — arm it so on_select drains fire.
33
+ extern void nomen_control_arm_selects(unsigned long long);
34
+ nomen_control_arm_selects((unsigned long long)cb);
35
+ self.handle = (uint64_t)cb;
36
+ ```
37
+ ```
38
+ #arch: aarch64_use_c
39
+ #platform: macos
40
+ id cb = ((id(*)(id, SEL, CGRect))objc_msgSend)(
41
+ ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSComboBox"), sel_registerName("alloc")),
42
+ sel_registerName("initWithFrame:"),
43
+ ((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 26));
44
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(cb, sel_registerName("setCompletes:"), 1);
45
+ id contentView = ((id(*)(id, SEL))objc_msgSend)(
46
+ (id)window->handle, sel_registerName("contentView"));
47
+ ((void(*)(id, SEL, id))objc_msgSend)(
48
+ contentView, sel_registerName("addSubview:"), cb);
49
+ extern void nomen_control_arm_selects(unsigned long long) __asm__("nomen_control_arm_selects");
50
+ nomen_control_arm_selects((unsigned long long)cb);
51
+ self->handle = (uint64_t)cb;
52
+ ```
53
+ ```
54
+ #arch: c
55
+ #platform: ios
56
+ /* TODO: iOS — no NSComboBox counterpart (compose a UITextField +
57
+ * picker; see GUI_PLAN Tier 2; defer). */
58
+ ```
59
+ ```
60
+ #arch: aarch64_use_c
61
+ #platform: ios
62
+ /* TODO: iOS (see #init) */
63
+ ```
64
+ }
65
+
66
+ pub func set_frame = (ref self, int x, int y, int width, int height) {
67
+ ```
68
+ #arch: c
69
+ #platform: macos
70
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
71
+ (id)self->handle, sel_registerName("setFrame:"),
72
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
73
+ ```
74
+ ```
75
+ #arch: aarch64_use_c
76
+ #platform: macos
77
+ ((void(*)(id, SEL, CGRect))objc_msgSend)(
78
+ (id)self->handle, sel_registerName("setFrame:"),
79
+ ((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
80
+ ```
81
+ ```
82
+ #arch: c
83
+ #platform: ios
84
+ /* TODO: iOS (see #init) */
85
+ ```
86
+ ```
87
+ #arch: aarch64_use_c
88
+ #platform: ios
89
+ /* TODO: iOS (see #init) */
90
+ ```
91
+ }
92
+
93
+ pub func add_item = (self, string title) {
94
+ ```
95
+ #arch: c
96
+ #platform: macos
97
+ ((void(*)(id, SEL, id))objc_msgSend)(
98
+ (id)self->handle, sel_registerName("addItemWithObjectValue:"),
99
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
100
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
101
+ ```
102
+ ```
103
+ #arch: aarch64_use_c
104
+ #platform: macos
105
+ ((void(*)(id, SEL, id))objc_msgSend)(
106
+ (id)self->handle, sel_registerName("addItemWithObjectValue:"),
107
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
108
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
109
+ ```
110
+ ```
111
+ #arch: c
112
+ #platform: ios
113
+ /* TODO: iOS (see #init) */
114
+ ```
115
+ ```
116
+ #arch: aarch64_use_c
117
+ #platform: ios
118
+ /* TODO: iOS (see #init) */
119
+ ```
120
+ }
121
+
122
+ pub func remove_all = (self) {
123
+ ```
124
+ #arch: c
125
+ #platform: macos
126
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeAllItems"));
127
+ ```
128
+ ```
129
+ #arch: aarch64_use_c
130
+ #platform: macos
131
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeAllItems"));
132
+ ```
133
+ ```
134
+ #arch: c
135
+ #platform: ios
136
+ /* TODO: iOS (see #init) */
137
+ ```
138
+ ```
139
+ #arch: aarch64_use_c
140
+ #platform: ios
141
+ /* TODO: iOS (see #init) */
142
+ ```
143
+ }
144
+
145
+ pub func item_count = (self, out int) {
146
+ ```
147
+ #arch: c
148
+ #platform: macos
149
+ return (int)((long(*)(id, SEL))objc_msgSend)(
150
+ (id)self->handle, sel_registerName("numberOfItems"));
151
+ ```
152
+ ```
153
+ #arch: aarch64_use_c
154
+ #platform: macos
155
+ return (int)((long(*)(id, SEL))objc_msgSend)(
156
+ (id)self->handle, sel_registerName("numberOfItems"));
157
+ ```
158
+ ```
159
+ #arch: c
160
+ #platform: ios
161
+ /* TODO: iOS (see #init) */
162
+ return 0;
163
+ ```
164
+ ```
165
+ #arch: aarch64_use_c
166
+ #platform: ios
167
+ /* TODO: iOS (see #init) */
168
+ return 0;
169
+ ```
170
+ }
171
+
172
+ // A fresh copy of item `index`'s text (mv — the caller owns it).
173
+ pub func item = (self, int index, out string) {
174
+ ```
175
+ #arch: c
176
+ #platform: macos
177
+ id value = ((id(*)(id, SEL, long))objc_msgSend)(
178
+ (id)self->handle, sel_registerName("itemObjectValueAtIndex:"), (long)index);
179
+ if (!value) return (nomen_string){ strdup(""), 0 };
180
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(value, sel_registerName("UTF8String"));
181
+ if (!cstr) return (nomen_string){ strdup(""), 0 };
182
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
183
+ ```
184
+ ```
185
+ #arch: aarch64_use_c
186
+ #platform: macos
187
+ id value = ((id(*)(id, SEL, long))objc_msgSend)(
188
+ (id)self->handle, sel_registerName("itemObjectValueAtIndex:"), (long)index);
189
+ if (!value) return (nomen_string){ strdup(""), 0 };
190
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(value, sel_registerName("UTF8String"));
191
+ if (!cstr) return (nomen_string){ strdup(""), 0 };
192
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
193
+ ```
194
+ ```
195
+ #arch: c
196
+ #platform: ios
197
+ /* TODO: iOS (see #init) */
198
+ return (nomen_string){ strdup(""), 0 };
199
+ ```
200
+ ```
201
+ #arch: aarch64_use_c
202
+ #platform: ios
203
+ /* TODO: iOS (see #init) */
204
+ return (nomen_string){ strdup(""), 0 };
205
+ ```
206
+ }
207
+
208
+ // The edited/selected text, polled (a fresh copy — the caller owns it).
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
+ if (!str) return (nomen_string){ strdup(""), 0 };
216
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(str, sel_registerName("UTF8String"));
217
+ if (!cstr) return (nomen_string){ strdup(""), 0 };
218
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
219
+ ```
220
+ ```
221
+ #arch: aarch64_use_c
222
+ #platform: macos
223
+ id str = ((id(*)(id, SEL))objc_msgSend)(
224
+ (id)self->handle, sel_registerName("stringValue"));
225
+ if (!str) return (nomen_string){ strdup(""), 0 };
226
+ const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(str, sel_registerName("UTF8String"));
227
+ if (!cstr) return (nomen_string){ strdup(""), 0 };
228
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
229
+ ```
230
+ ```
231
+ #arch: c
232
+ #platform: ios
233
+ /* TODO: iOS (see #init) */
234
+ return (nomen_string){ strdup(""), 0 };
235
+ ```
236
+ ```
237
+ #arch: aarch64_use_c
238
+ #platform: ios
239
+ /* TODO: iOS (see #init) */
240
+ return (nomen_string){ strdup(""), 0 };
241
+ ```
242
+ }
243
+
244
+ pub func set_text = (self, string text) {
245
+ ```
246
+ #arch: c
247
+ #platform: macos
248
+ ((void(*)(id, SEL, id))objc_msgSend)(
249
+ (id)self->handle, sel_registerName("setStringValue:"),
250
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
251
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
252
+ ```
253
+ ```
254
+ #arch: aarch64_use_c
255
+ #platform: macos
256
+ ((void(*)(id, SEL, id))objc_msgSend)(
257
+ (id)self->handle, sel_registerName("setStringValue:"),
258
+ ((id(*)(id, SEL, const char*))objc_msgSend)(
259
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
260
+ ```
261
+ ```
262
+ #arch: c
263
+ #platform: ios
264
+ /* TODO: iOS (see #init) */
265
+ ```
266
+ ```
267
+ #arch: aarch64_use_c
268
+ #platform: ios
269
+ /* TODO: iOS (see #init) */
270
+ ```
271
+ }
272
+
273
+ // The selected item's index, polled; -1 = no selection. (User free-typing
274
+ // clears it; a programmatic set_text does not.)
275
+ pub func selected_index = (self, out int) {
276
+ ```
277
+ #arch: c
278
+ #platform: macos
279
+ return (int)((long(*)(id, SEL))objc_msgSend)(
280
+ (id)self->handle, sel_registerName("indexOfSelectedItem"));
281
+ ```
282
+ ```
283
+ #arch: aarch64_use_c
284
+ #platform: macos
285
+ return (int)((long(*)(id, SEL))objc_msgSend)(
286
+ (id)self->handle, sel_registerName("indexOfSelectedItem"));
287
+ ```
288
+ ```
289
+ #arch: c
290
+ #platform: ios
291
+ /* TODO: iOS (see #init) */
292
+ return -1;
293
+ ```
294
+ ```
295
+ #arch: aarch64_use_c
296
+ #platform: ios
297
+ /* TODO: iOS (see #init) */
298
+ return -1;
299
+ ```
300
+ }
301
+
302
+ // The on_select desugar's drain (docs/HANDLERS.md): true when the user
303
+ // selected a list entry (or pressed Return) since the last drain — the
304
+ // record is consumed. User-driven only: AppKit sends the combo's action
305
+ // for user selections, not programmatic ones. The handler body reads
306
+ // the item through selected_index().
307
+ pub func take_select = (self, out bool) {
308
+ ```
309
+ #arch: c
310
+ #platform: macos
311
+ extern long nomen_select_take(unsigned long long);
312
+ return (long)nomen_select_take((unsigned long long)self->handle);
313
+ ```
314
+ ```
315
+ #arch: aarch64_use_c
316
+ #platform: macos
317
+ extern long nomen_select_take(unsigned long long);
318
+ return (long)nomen_select_take((unsigned long long)self->handle);
319
+ ```
320
+ ```
321
+ #arch: c
322
+ #platform: ios
323
+ /* TODO: iOS (see #init) */
324
+ return false;
325
+ ```
326
+ ```
327
+ #arch: aarch64_use_c
328
+ #platform: ios
329
+ /* TODO: iOS (see #init) */
330
+ return false;
331
+ ```
332
+ }
333
+
334
+ pub func set_selected = (self, int index) {
335
+ ```
336
+ #arch: c
337
+ #platform: macos
338
+ ((void(*)(id, SEL, long))objc_msgSend)(
339
+ (id)self->handle, sel_registerName("selectItemAtIndex:"), (long)index);
340
+ ```
341
+ ```
342
+ #arch: aarch64_use_c
343
+ #platform: macos
344
+ ((void(*)(id, SEL, long))objc_msgSend)(
345
+ (id)self->handle, sel_registerName("selectItemAtIndex:"), (long)index);
346
+ ```
347
+ ```
348
+ #arch: c
349
+ #platform: ios
350
+ /* TODO: iOS (see #init) */
351
+ ```
352
+ ```
353
+ #arch: aarch64_use_c
354
+ #platform: ios
355
+ /* TODO: iOS (see #init) */
356
+ ```
357
+ }
358
+
359
+ pub func set_hidden = (self, bool hidden) {
360
+ ```
361
+ #arch: c
362
+ #platform: macos
363
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
364
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
365
+ ```
366
+ ```
367
+ #arch: aarch64_use_c
368
+ #platform: macos
369
+ ((void(*)(id, SEL, BOOL))objc_msgSend)(
370
+ (id)self->handle, sel_registerName("setHidden:"), hidden ? 1 : 0);
371
+ ```
372
+ }
373
+
374
+ // ── Control trait conformance ──
375
+ pub func intrinsic_size = (self, out Size) {
376
+ var [w, h] = native_intrinsic(self.handle)
377
+ var s = Size()
378
+ s.width = w
379
+ s.height = h
380
+ return s
381
+ }
382
+
383
+ pub func measure = (self, BoxConstraints constraints, out Size) {
384
+ var Size s = self.intrinsic_size()
385
+ if s.width > constraints.max_width {
386
+ s.width = constraints.max_width
387
+ }
388
+ if s.width < constraints.min_width {
389
+ s.width = constraints.min_width
390
+ }
391
+ if s.height > constraints.max_height {
392
+ s.height = constraints.max_height
393
+ }
394
+ if s.height < constraints.min_height {
395
+ s.height = constraints.min_height
396
+ }
397
+ return s
398
+ }
399
+
400
+ func #destroy = () {
401
+ ```
402
+ #arch: c
403
+ #platform: macos
404
+ if (self->handle) {
405
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
406
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
407
+ self->handle = 0;
408
+ }
409
+ ```
410
+ ```
411
+ #arch: aarch64_use_c
412
+ #platform: macos
413
+ if (self->handle) {
414
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
415
+ ((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
416
+ self->handle = 0;
417
+ }
418
+ ```
419
+ ```
420
+ #arch: c
421
+ #platform: ios
422
+ /* TODO: iOS (see #init) */
423
+ ```
424
+ ```
425
+ #arch: aarch64_use_c
426
+ #platform: ios
427
+ /* TODO: iOS (see #init) */
428
+ ```
429
+ }
430
+ }