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.
- package/core/System/Buffer.nm +32 -0
- package/core/System/ClassBuffer.nm +24 -0
- package/core/System/Controls/Alert.nm +326 -0
- package/core/System/Controls/App.nm +147 -0
- package/core/System/Controls/Button.nm +119 -1
- package/core/System/Controls/CheckBox.nm +24 -0
- package/core/System/Controls/ColorPicker.nm +307 -0
- package/core/System/Controls/ComboBox.nm +430 -0
- package/core/System/Controls/Container.nm +837 -9
- package/core/System/Controls/Control.nm +443 -0
- package/core/System/Controls/DatePicker.nm +288 -0
- package/core/System/Controls/Form.nm +70 -0
- package/core/System/Controls/GroupBox.nm +267 -0
- package/core/System/Controls/ImageView.nm +311 -0
- package/core/System/Controls/LevelIndicator.nm +305 -0
- package/core/System/Controls/ListView.nm +633 -0
- package/core/System/Controls/Menu.nm +428 -0
- package/core/System/Controls/NumberInput.nm +56 -0
- package/core/System/Controls/OtpInput.nm +50 -0
- package/core/System/Controls/OutlineView.nm +598 -0
- package/core/System/Controls/Pagination.nm +142 -0
- package/core/System/Controls/Popover.nm +296 -0
- package/core/System/Controls/Progress.nm +348 -0
- package/core/System/Controls/Radio.nm +292 -0
- package/core/System/Controls/Scrollable.nm +584 -0
- package/core/System/Controls/SearchField.nm +326 -0
- package/core/System/Controls/SecureField.nm +344 -0
- package/core/System/Controls/Segmented.nm +380 -0
- package/core/System/Controls/Select.nm +340 -0
- package/core/System/Controls/Separator.nm +198 -0
- package/core/System/Controls/Sheet.nm +329 -0
- package/core/System/Controls/Slider.nm +315 -0
- package/core/System/Controls/Spinner.nm +287 -0
- package/core/System/Controls/SplitView.nm +509 -0
- package/core/System/Controls/Stepper.nm +349 -0
- package/core/System/Controls/Switch.nm +259 -0
- package/core/System/Controls/Table.nm +833 -0
- package/core/System/Controls/Tabs.nm +500 -0
- package/core/System/Controls/Text.nm +108 -11
- package/core/System/Controls/TextBox.nm +112 -1
- package/core/System/Controls/TextView.nm +329 -0
- package/core/System/Controls/Toggle.nm +346 -0
- package/core/System/Controls/Toolbar.nm +501 -0
- package/core/System/Controls/Tooltip.nm +76 -0
- package/core/System/Controls/Window.nm +1549 -91
- package/core/System/List.nm +34 -0
- package/core/System/Map.nm +21 -4
- package/core/System/Set.nm +14 -0
- package/dist/index.mjs +2556 -656
- package/package.json +1 -1
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
pub mv struct TextBox : Control {
|
|
10
10
|
var uint64 handle = 0
|
|
11
11
|
|
|
12
|
+
// The `#handle` hook synthesizes `NameHandle` — a copyable, non-owning
|
|
13
|
+
// twin (same public bare-self methods, no destroy) so closures can
|
|
14
|
+
// capture this control without moving it. See GUI.md, "Handles".
|
|
15
|
+
#handle = () {}
|
|
16
|
+
|
|
12
17
|
pub func #init = (self, Window window) {
|
|
13
18
|
```
|
|
14
19
|
#arch: c
|
|
@@ -35,6 +40,10 @@ pub mv struct TextBox : Control {
|
|
|
35
40
|
(id)window->handle, sel_registerName("contentView"));
|
|
36
41
|
((void(*)(id, SEL, id))objc_msgSend)(
|
|
37
42
|
contentView, sel_registerName("addSubview:"), field);
|
|
43
|
+
// NSTextField sends its action on the USER commit (Return) — arm it
|
|
44
|
+
// so on_submit drains fire (programmatic set_text stays silent).
|
|
45
|
+
extern void nomen_control_arm_submits(unsigned long long);
|
|
46
|
+
nomen_control_arm_submits((unsigned long long)field);
|
|
38
47
|
self.handle = (uint64_t)field;
|
|
39
48
|
```
|
|
40
49
|
```
|
|
@@ -62,6 +71,8 @@ pub mv struct TextBox : Control {
|
|
|
62
71
|
(id)window->handle, sel_registerName("contentView"));
|
|
63
72
|
((void(*)(id, SEL, id))objc_msgSend)(
|
|
64
73
|
contentView, sel_registerName("addSubview:"), field);
|
|
74
|
+
extern void nomen_control_arm_submits(unsigned long long) __asm__("nomen_control_arm_submits");
|
|
75
|
+
nomen_control_arm_submits((unsigned long long)field);
|
|
65
76
|
self->handle = (uint64_t)field;
|
|
66
77
|
```
|
|
67
78
|
```
|
|
@@ -166,6 +177,73 @@ pub mv struct TextBox : Control {
|
|
|
166
177
|
```
|
|
167
178
|
}
|
|
168
179
|
|
|
180
|
+
// The placeholder: gray hint text shown while the field is empty. Unlike
|
|
181
|
+
// set_text, it is not the field's value — get_text still reports "" until
|
|
182
|
+
// the user types.
|
|
183
|
+
pub func set_placeholder = (self, string text) {
|
|
184
|
+
```
|
|
185
|
+
#arch: c
|
|
186
|
+
#platform: macos
|
|
187
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
188
|
+
(id)self->handle, sel_registerName("setPlaceholderString:"),
|
|
189
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
190
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
|
|
191
|
+
```
|
|
192
|
+
```
|
|
193
|
+
#arch: aarch64_use_c
|
|
194
|
+
#platform: macos
|
|
195
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
196
|
+
(id)self->handle, sel_registerName("setPlaceholderString:"),
|
|
197
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
198
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
|
|
199
|
+
```
|
|
200
|
+
```
|
|
201
|
+
#arch: c
|
|
202
|
+
#platform: ios
|
|
203
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
204
|
+
(id)self->handle, sel_registerName("setPlaceholder:"),
|
|
205
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
206
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
|
|
207
|
+
```
|
|
208
|
+
```
|
|
209
|
+
#arch: aarch64_use_c
|
|
210
|
+
#platform: ios
|
|
211
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
212
|
+
(id)self->handle, sel_registerName("setPlaceholder:"),
|
|
213
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
214
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
|
|
215
|
+
```
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ── Event drains (docs/HANDLERS.md): the on_click / on_focus / on_blur /
|
|
219
|
+
// on_input desugars poll these per frame — one method per event, the
|
|
220
|
+
// naming convention is the contract. Arming and native plumbing live
|
|
221
|
+
// inside the drains.
|
|
222
|
+
|
|
223
|
+
// Click edge (the gesture recognizer arms this view — see
|
|
224
|
+
// nomen_window_clicks_init; arming is idempotent per handle).
|
|
225
|
+
pub func take_click = (self, out bool) {
|
|
226
|
+
nomen_window_clicks_init(self.handle)
|
|
227
|
+
return nomen_control_take_click(self.handle)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Focus edge: true the frame this control GAINED first-responder status.
|
|
231
|
+
pub func take_focus = (self, out bool) {
|
|
232
|
+
return nomen_control_take_focus(self.handle)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Blur edge: true the frame this control LOST first-responder status.
|
|
236
|
+
pub func take_blur = (self, out bool) {
|
|
237
|
+
return nomen_control_take_blur(self.handle)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Text-input edge: true when the control's text changed since the last
|
|
241
|
+
// drain (the field editor writes through to stringValue while typing —
|
|
242
|
+
// each keystroke is one edge). First drain baselines silently.
|
|
243
|
+
pub func take_input = (self, out bool) {
|
|
244
|
+
return nomen_control_take_input(self.handle)
|
|
245
|
+
}
|
|
246
|
+
|
|
169
247
|
pub func get_text = (self, out string) {
|
|
170
248
|
```
|
|
171
249
|
#arch: c
|
|
@@ -198,13 +276,46 @@ pub mv struct TextBox : Control {
|
|
|
198
276
|
#arch: aarch64_use_c
|
|
199
277
|
#platform: ios
|
|
200
278
|
id str = ((id(*)(id, SEL))objc_msgSend)(
|
|
201
|
-
(id)self->handle, sel_registerName("text
|
|
279
|
+
(id)self->handle, sel_registerName("text"));
|
|
202
280
|
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
203
281
|
str, sel_registerName("UTF8String"));
|
|
204
282
|
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
205
283
|
```
|
|
206
284
|
}
|
|
207
285
|
|
|
286
|
+
// The on_submit desugar's drain (docs/HANDLERS.md tier 2): true when
|
|
287
|
+
// the user committed this field (Return) since the last drain — the
|
|
288
|
+
// record is consumed, one commit fires an arm exactly once.
|
|
289
|
+
// User-driven only (the field's action; programmatic set_text stays
|
|
290
|
+
// silent). The handler body reads the committed text through
|
|
291
|
+
// get_text().
|
|
292
|
+
pub func take_submit = (self, out bool) {
|
|
293
|
+
```
|
|
294
|
+
#arch: c
|
|
295
|
+
#platform: macos
|
|
296
|
+
extern long nomen_submit_take(unsigned long long);
|
|
297
|
+
return (long)nomen_submit_take((unsigned long long)self->handle);
|
|
298
|
+
```
|
|
299
|
+
```
|
|
300
|
+
#arch: aarch64_use_c
|
|
301
|
+
#platform: macos
|
|
302
|
+
extern long nomen_submit_take(unsigned long long);
|
|
303
|
+
return (long)nomen_submit_take((unsigned long long)self->handle);
|
|
304
|
+
```
|
|
305
|
+
```
|
|
306
|
+
#arch: c
|
|
307
|
+
#platform: ios
|
|
308
|
+
/* TODO: iOS (see #init) */
|
|
309
|
+
return false;
|
|
310
|
+
```
|
|
311
|
+
```
|
|
312
|
+
#arch: aarch64_use_c
|
|
313
|
+
#platform: ios
|
|
314
|
+
/* TODO: iOS (see #init) */
|
|
315
|
+
return false;
|
|
316
|
+
```
|
|
317
|
+
}
|
|
318
|
+
|
|
208
319
|
// ── Control trait conformance ──
|
|
209
320
|
pub func intrinsic_size = (self, out Size) {
|
|
210
321
|
var [w, h] = native_intrinsic(self.handle)
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A multiline editable text surface
|
|
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
|
+
* Sized explicitly by the container (`add(handle, w, h, …)`): a native text
|
|
10
|
+
* view has no useful intrinsic size (it scrolls its own document), so the
|
|
11
|
+
* Control-trait measure reports what the platform offers and clamps to the
|
|
12
|
+
* constraints like every other leaf.
|
|
13
|
+
**/
|
|
14
|
+
pub mv struct TextView: Control {
|
|
15
|
+
var uint64 handle = 0
|
|
16
|
+
|
|
17
|
+
// The `#handle` hook synthesizes `NameHandle` — a copyable, non-owning
|
|
18
|
+
// twin (same public bare-self methods, no destroy) so closures can
|
|
19
|
+
// capture this control without moving it. See GUI.md, "Handles".
|
|
20
|
+
#handle = () {}
|
|
21
|
+
|
|
22
|
+
pub func #init = (self, Window window) {
|
|
23
|
+
```
|
|
24
|
+
#arch: c
|
|
25
|
+
#platform: macos
|
|
26
|
+
id tv = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
27
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSTextView"), sel_registerName("alloc")),
|
|
28
|
+
sel_registerName("initWithFrame:"),
|
|
29
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 80));
|
|
30
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setEditable:"), 1);
|
|
31
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setSelectable:"), 1);
|
|
32
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setRichText:"), 0);
|
|
33
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
34
|
+
tv, sel_registerName("setUsesFindBar:"), 1);
|
|
35
|
+
// The NSTextView default is the small (12pt) system font; match the
|
|
36
|
+
// 13pt standard control size every field control uses.
|
|
37
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
38
|
+
tv, sel_registerName("setFont:"),
|
|
39
|
+
((id(*)(id, SEL, CGFloat))objc_msgSend)(
|
|
40
|
+
(id)objc_getClass("NSFont"), sel_registerName("systemFontOfSize:"),
|
|
41
|
+
((CGFloat(*)(id, SEL))objc_msgSend)(
|
|
42
|
+
(id)objc_getClass("NSFont"), sel_registerName("systemFontSize"))));
|
|
43
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
44
|
+
tv, sel_registerName("setString:"),
|
|
45
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
46
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), ""));
|
|
47
|
+
id contentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
48
|
+
(id)window->handle, sel_registerName("contentView"));
|
|
49
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
50
|
+
contentView, sel_registerName("addSubview:"), tv);
|
|
51
|
+
self.handle = (uint64_t)tv;
|
|
52
|
+
```
|
|
53
|
+
```
|
|
54
|
+
#arch: aarch64_use_c
|
|
55
|
+
#platform: macos
|
|
56
|
+
id tv = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
57
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSTextView"), sel_registerName("alloc")),
|
|
58
|
+
sel_registerName("initWithFrame:"),
|
|
59
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 80));
|
|
60
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setEditable:"), 1);
|
|
61
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setSelectable:"), 1);
|
|
62
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setRichText:"), 0);
|
|
63
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(
|
|
64
|
+
tv, sel_registerName("setUsesFindBar:"), 1);
|
|
65
|
+
// The NSTextView default is the small (12pt) system font; match the
|
|
66
|
+
// 13pt standard control size every field control uses.
|
|
67
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
68
|
+
tv, sel_registerName("setFont:"),
|
|
69
|
+
((id(*)(id, SEL, CGFloat))objc_msgSend)(
|
|
70
|
+
(id)objc_getClass("NSFont"), sel_registerName("systemFontOfSize:"),
|
|
71
|
+
((CGFloat(*)(id, SEL))objc_msgSend)(
|
|
72
|
+
(id)objc_getClass("NSFont"), sel_registerName("systemFontSize"))));
|
|
73
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
74
|
+
tv, sel_registerName("setString:"),
|
|
75
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
76
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), ""));
|
|
77
|
+
id contentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
78
|
+
(id)window->handle, sel_registerName("contentView"));
|
|
79
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
80
|
+
contentView, sel_registerName("addSubview:"), tv);
|
|
81
|
+
self->handle = (uint64_t)tv;
|
|
82
|
+
```
|
|
83
|
+
```
|
|
84
|
+
#arch: c
|
|
85
|
+
#platform: ios
|
|
86
|
+
id tv = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
87
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UITextView"), sel_registerName("alloc")),
|
|
88
|
+
sel_registerName("initWithFrame:"),
|
|
89
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 80));
|
|
90
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setEditable:"), 1);
|
|
91
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setSelectable:"), 1);
|
|
92
|
+
id parentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
93
|
+
((id(*)(id, SEL))objc_msgSend)(
|
|
94
|
+
(id)window->handle, sel_registerName("rootViewController")),
|
|
95
|
+
sel_registerName("view"));
|
|
96
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
97
|
+
parentView, sel_registerName("addSubview:"), tv);
|
|
98
|
+
self.handle = (uint64_t)tv;
|
|
99
|
+
```
|
|
100
|
+
```
|
|
101
|
+
#arch: aarch64_use_c
|
|
102
|
+
#platform: ios
|
|
103
|
+
id tv = ((id(*)(id, SEL, CGRect))objc_msgSend)(
|
|
104
|
+
((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("UITextView"), sel_registerName("alloc")),
|
|
105
|
+
sel_registerName("initWithFrame:"),
|
|
106
|
+
((CGRect(*)(double, double, double, double))CGRectMake)(0, 0, 200, 80));
|
|
107
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setEditable:"), 1);
|
|
108
|
+
((void(*)(id, SEL, BOOL))objc_msgSend)(tv, sel_registerName("setSelectable:"), 1);
|
|
109
|
+
id parentView = ((id(*)(id, SEL))objc_msgSend)(
|
|
110
|
+
((id(*)(id, SEL))objc_msgSend)(
|
|
111
|
+
(id)window->handle, sel_registerName("rootViewController")),
|
|
112
|
+
sel_registerName("view"));
|
|
113
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
114
|
+
parentView, sel_registerName("addSubview:"), tv);
|
|
115
|
+
self->handle = (uint64_t)tv;
|
|
116
|
+
```
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
pub func set_frame = (ref self, int x, int y, int width, int height) {
|
|
120
|
+
```
|
|
121
|
+
#arch: c
|
|
122
|
+
#platform: macos
|
|
123
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
124
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
125
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
126
|
+
```
|
|
127
|
+
```
|
|
128
|
+
#arch: aarch64_use_c
|
|
129
|
+
#platform: macos
|
|
130
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
131
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
132
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
133
|
+
```
|
|
134
|
+
```
|
|
135
|
+
#arch: c
|
|
136
|
+
#platform: ios
|
|
137
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
138
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
139
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
140
|
+
```
|
|
141
|
+
```
|
|
142
|
+
#arch: aarch64_use_c
|
|
143
|
+
#platform: ios
|
|
144
|
+
((void(*)(id, SEL, CGRect))objc_msgSend)(
|
|
145
|
+
(id)self->handle, sel_registerName("setFrame:"),
|
|
146
|
+
((CGRect(*)(double, double, double, double))CGRectMake)((double)x, (double)y, (double)width, (double)height));
|
|
147
|
+
```
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
pub func set_text = (self, string text) {
|
|
151
|
+
```
|
|
152
|
+
#arch: c
|
|
153
|
+
#platform: macos
|
|
154
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
155
|
+
(id)self->handle, sel_registerName("setString:"),
|
|
156
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
157
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
|
|
158
|
+
```
|
|
159
|
+
```
|
|
160
|
+
#arch: aarch64_use_c
|
|
161
|
+
#platform: macos
|
|
162
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
163
|
+
(id)self->handle, sel_registerName("setString:"),
|
|
164
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
165
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
|
|
166
|
+
```
|
|
167
|
+
```
|
|
168
|
+
#arch: c
|
|
169
|
+
#platform: ios
|
|
170
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
171
|
+
(id)self->handle, sel_registerName("setText:"),
|
|
172
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
173
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
|
|
174
|
+
```
|
|
175
|
+
```
|
|
176
|
+
#arch: aarch64_use_c
|
|
177
|
+
#platform: ios
|
|
178
|
+
((void(*)(id, SEL, id))objc_msgSend)(
|
|
179
|
+
(id)self->handle, sel_registerName("setText:"),
|
|
180
|
+
((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
181
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
|
|
182
|
+
```
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// The placeholder: gray hint text shown while the view is empty. Unlike
|
|
186
|
+
// set_text, it is not the view's value — get_text still reports "" until
|
|
187
|
+
// the user types. AppKit has no public NSTextView placeholder API, so this
|
|
188
|
+
// goes through the key-value-coded "placeholderString" the view supports;
|
|
189
|
+
// UITextView has none at all (a delegate-drawn overlay would be needed).
|
|
190
|
+
pub func set_placeholder = (self, string text) {
|
|
191
|
+
```
|
|
192
|
+
#arch: c
|
|
193
|
+
#platform: macos
|
|
194
|
+
id value = ((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
195
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr);
|
|
196
|
+
id key = ((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
197
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"),
|
|
198
|
+
"placeholderString");
|
|
199
|
+
((void(*)(id, SEL, id, id))objc_msgSend)(
|
|
200
|
+
(id)self->handle, sel_registerName("setValue:forKey:"), value, key);
|
|
201
|
+
```
|
|
202
|
+
```
|
|
203
|
+
#arch: aarch64_use_c
|
|
204
|
+
#platform: macos
|
|
205
|
+
id value = ((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
206
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr);
|
|
207
|
+
id key = ((id(*)(id, SEL, const char*))objc_msgSend)(
|
|
208
|
+
(id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"),
|
|
209
|
+
"placeholderString");
|
|
210
|
+
((void(*)(id, SEL, id, id))objc_msgSend)(
|
|
211
|
+
(id)self->handle, sel_registerName("setValue:forKey:"), value, key);
|
|
212
|
+
```
|
|
213
|
+
```
|
|
214
|
+
#arch: c
|
|
215
|
+
#platform: ios
|
|
216
|
+
/* TODO: iOS — UITextView has no placeholder; needs a delegate-drawn
|
|
217
|
+
* overlay (see GUI_PLAN Tier 3). */
|
|
218
|
+
```
|
|
219
|
+
```
|
|
220
|
+
#arch: aarch64_use_c
|
|
221
|
+
#platform: ios
|
|
222
|
+
/* TODO: iOS (see #init) */
|
|
223
|
+
```
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
pub func get_text = (self, out string) {
|
|
227
|
+
```
|
|
228
|
+
#arch: c
|
|
229
|
+
#platform: macos
|
|
230
|
+
id str = ((id(*)(id, SEL))objc_msgSend)(
|
|
231
|
+
(id)self->handle, sel_registerName("string"));
|
|
232
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
233
|
+
str, sel_registerName("UTF8String"));
|
|
234
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
235
|
+
```
|
|
236
|
+
```
|
|
237
|
+
#arch: aarch64_use_c
|
|
238
|
+
#platform: macos
|
|
239
|
+
id str = ((id(*)(id, SEL))objc_msgSend)(
|
|
240
|
+
(id)self->handle, sel_registerName("string"));
|
|
241
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
242
|
+
str, sel_registerName("UTF8String"));
|
|
243
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
244
|
+
```
|
|
245
|
+
```
|
|
246
|
+
#arch: c
|
|
247
|
+
#platform: ios
|
|
248
|
+
id str = ((id(*)(id, SEL))objc_msgSend)(
|
|
249
|
+
(id)self->handle, sel_registerName("text"));
|
|
250
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
251
|
+
str, sel_registerName("UTF8String"));
|
|
252
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
253
|
+
```
|
|
254
|
+
```
|
|
255
|
+
#arch: aarch64_use_c
|
|
256
|
+
#platform: ios
|
|
257
|
+
id str = ((id(*)(id, SEL))objc_msgSend)(
|
|
258
|
+
(id)self->handle, sel_registerName("text"));
|
|
259
|
+
const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
|
|
260
|
+
str, sel_registerName("UTF8String"));
|
|
261
|
+
return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
|
|
262
|
+
```
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ── Control trait conformance ──
|
|
266
|
+
pub func intrinsic_size = (self, out Size) {
|
|
267
|
+
var [w, h] = native_intrinsic(self.handle)
|
|
268
|
+
var s = Size()
|
|
269
|
+
s.width = w
|
|
270
|
+
s.height = h
|
|
271
|
+
return s
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
pub func measure = (self, BoxConstraints constraints, out Size) {
|
|
275
|
+
var Size s = self.intrinsic_size()
|
|
276
|
+
if s.width > constraints.max_width {
|
|
277
|
+
s.width = constraints.max_width
|
|
278
|
+
}
|
|
279
|
+
if s.width < constraints.min_width {
|
|
280
|
+
s.width = constraints.min_width
|
|
281
|
+
}
|
|
282
|
+
if s.height > constraints.max_height {
|
|
283
|
+
s.height = constraints.max_height
|
|
284
|
+
}
|
|
285
|
+
if s.height < constraints.min_height {
|
|
286
|
+
s.height = constraints.min_height
|
|
287
|
+
}
|
|
288
|
+
return s
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
func #destroy = () {
|
|
292
|
+
```
|
|
293
|
+
#arch: c
|
|
294
|
+
#platform: macos
|
|
295
|
+
if (self->handle) {
|
|
296
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
297
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
298
|
+
self->handle = 0;
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
```
|
|
302
|
+
#arch: aarch64_use_c
|
|
303
|
+
#platform: macos
|
|
304
|
+
if (self->handle) {
|
|
305
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
306
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
307
|
+
self->handle = 0;
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
```
|
|
311
|
+
#arch: c
|
|
312
|
+
#platform: ios
|
|
313
|
+
if (self->handle) {
|
|
314
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
315
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
316
|
+
self->handle = 0;
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
```
|
|
320
|
+
#arch: aarch64_use_c
|
|
321
|
+
#platform: ios
|
|
322
|
+
if (self->handle) {
|
|
323
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("removeFromSuperview"));
|
|
324
|
+
((void(*)(id, SEL))objc_msgSend)((id)self->handle, sel_registerName("release"));
|
|
325
|
+
self->handle = 0;
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
}
|
|
329
|
+
}
|