create-mendix-widget-gleam 2.0.19 → 2.0.21
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/README.md +1 -1
- package/package.json +1 -1
- package/src/i18n.mjs +394 -334
- package/src/index.mjs +284 -231
- package/src/licenses.mjs +147 -0
- package/src/prompts.mjs +247 -142
- package/src/scaffold.mjs +108 -97
- package/src/templates/claude_md.mjs +3 -3
- package/src/templates/readme_md.mjs +10 -10
- package/template/gleam.toml +2 -2
- package/template/package.json +6 -6
- package/template/src/__WidgetName__.xml +1 -1
- package/template/src/package.xml +2 -2
- package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@command.cache +0 -0
- package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@cursor.cache +0 -0
- package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@cursor.cache_meta +0 -0
- package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@event.cache +0 -0
- package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@internal@consts.cache +0 -0
- package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@stdout.cache +0 -0
- package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@style.cache +0 -0
- package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@terminal.cache +0 -0
- package/tui/build/dev/javascript/etch/etch/event.mjs +36 -30
- package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@application.cache +0 -0
- package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@atom.cache +0 -0
- package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@charlist.cache +0 -0
- package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@node.cache +0 -0
- package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@port.cache +0 -0
- package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@process.cache +0 -0
- package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@reference.cache +0 -0
- package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@array.cache +0 -0
- package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@promise.cache +0 -0
- package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@symbol.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache_inline +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache_meta +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache_inline +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache_meta +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache +0 -0
- package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache +0 -0
- package/tui/build/dev/javascript/gleam_version +1 -1
- package/tui/build/dev/javascript/prelude.mjs +10 -26
- package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache +0 -0
- package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache_meta +0 -0
- package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache +0 -0
- package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache_meta +0 -0
- package/tui/build/dev/javascript/tui/tui/prompt.mjs +713 -52
- package/tui/build/dev/javascript/tui/tui.mjs +438 -51
- package/tui/build/dev/javascript/tui/tui_ffi.mjs +12 -0
- package/template/LICENSE +0 -15
|
@@ -10,16 +10,94 @@ import { None, Some } from "../../gleam_stdlib/gleam/option.mjs";
|
|
|
10
10
|
import * as $string from "../../gleam_stdlib/gleam/string.mjs";
|
|
11
11
|
import { Ok, Error, toList, Empty as $Empty } from "../gleam.mjs";
|
|
12
12
|
|
|
13
|
+
function draw_banner_lines(loop$lines) {
|
|
14
|
+
while (true) {
|
|
15
|
+
let lines = loop$lines;
|
|
16
|
+
if (lines instanceof $Empty) {
|
|
17
|
+
return undefined;
|
|
18
|
+
} else {
|
|
19
|
+
let rest = lines.tail;
|
|
20
|
+
let glendi = lines.head[0];
|
|
21
|
+
let lucy = lines.head[1];
|
|
22
|
+
$stdout.execute(
|
|
23
|
+
toList([
|
|
24
|
+
new $command.SetForegroundColor(new $style.Cyan()),
|
|
25
|
+
new $command.SetAttributes(toList([new $style.Bold()])),
|
|
26
|
+
new $command.Print(glendi),
|
|
27
|
+
new $command.ResetStyle(),
|
|
28
|
+
new $command.SetForegroundColor(new $style.Magenta()),
|
|
29
|
+
new $command.Println(lucy),
|
|
30
|
+
new $command.ResetStyle(),
|
|
31
|
+
]),
|
|
32
|
+
);
|
|
33
|
+
loop$lines = rest;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function banner_lines() {
|
|
39
|
+
return toList([
|
|
40
|
+
[
|
|
41
|
+
" ████ ████ ████",
|
|
42
|
+
"",
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
" ████ ████ ██████",
|
|
46
|
+
"",
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
" ████ ████ ████",
|
|
50
|
+
"",
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
" ████ ████",
|
|
54
|
+
" █▓█",
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
" ████████ ████ ████ ████████ ████ ███████ ███████ ████ ████",
|
|
58
|
+
" ▓░▓█",
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
" ███████████████ ████ ████████████ ██████████████ ██████████████ ████",
|
|
62
|
+
" ▓░░▓▓▓▓",
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
"█████ ██████ ████ ████ █████ █████ ████ █████ █████ ████",
|
|
66
|
+
" ▓▓░░░░░░▓",
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
"████ █████ ████ ████ ████ █████ ████ ████ █████ ████",
|
|
70
|
+
" ▓░░░░░▒░▒█",
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
"████ ████ ████ ███████████████ █████ ████ ████ ████ ████",
|
|
74
|
+
" █▓░▒░▒░░▓",
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
"█████ █████ ████ ████ █████ ████ ████ █████ ████",
|
|
78
|
+
" █▓░░▒░░▓",
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
" ███████████████ ████ █████ ██ █████ ████ █████ ██████ ████",
|
|
82
|
+
" ▓░░░░░▓",
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
" █████████ ████ ████ ████████████ █████ ████ ██████████████ ████",
|
|
86
|
+
" ▓░▒▓█▓▓",
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
" ████ ████ ████████ █████ ████ ██████ ████ ████",
|
|
90
|
+
" █▓█",
|
|
91
|
+
],
|
|
92
|
+
[" █ ████", ""],
|
|
93
|
+
[" █████████████", ""],
|
|
94
|
+
[" ██████████", ""],
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
|
|
13
98
|
export function draw_header() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
new $command.SetForegroundColor(new $style.Cyan()),
|
|
17
|
-
new $command.SetAttributes(toList([new $style.Bold()])),
|
|
18
|
-
new $command.Println(" create-mendix-widget-gleam"),
|
|
19
|
-
new $command.ResetStyle(),
|
|
20
|
-
new $command.Println(""),
|
|
21
|
-
]),
|
|
22
|
-
);
|
|
99
|
+
draw_banner_lines(banner_lines());
|
|
100
|
+
return $stdout.execute(toList([new $command.Println("")]));
|
|
23
101
|
}
|
|
24
102
|
|
|
25
103
|
export function draw_completed(steps) {
|
|
@@ -62,6 +140,26 @@ function clear_screen() {
|
|
|
62
140
|
);
|
|
63
141
|
}
|
|
64
142
|
|
|
143
|
+
function is_wide_char(code) {
|
|
144
|
+
return (((((((((code >= 0xAC00) && (code <= 0xD7A3)) || ((code >= 0x1100) && (code <= 0x11FF))) || ((code >= 0x3130) && (code <= 0x318F))) || ((code >= 0x3000) && (code <= 0x30FF))) || ((code >= 0x3400) && (code <= 0x4DBF))) || ((code >= 0x4E00) && (code <= 0x9FFF))) || ((code >= 0xF900) && (code <= 0xFAFF))) || ((code >= 0xFF01) && (code <= 0xFF60))) || ((code >= 0xFFE0) && (code <= 0xFFE6));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function display_width(str) {
|
|
148
|
+
let _pipe = $string.to_utf_codepoints(str);
|
|
149
|
+
return $list.fold(
|
|
150
|
+
_pipe,
|
|
151
|
+
0,
|
|
152
|
+
(acc, cp) => {
|
|
153
|
+
let $ = is_wide_char($string.utf_codepoint_to_int(cp));
|
|
154
|
+
if ($) {
|
|
155
|
+
return acc + 2;
|
|
156
|
+
} else {
|
|
157
|
+
return acc + 1;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
65
163
|
function render_items(loop$items, loop$selected, loop$i) {
|
|
66
164
|
while (true) {
|
|
67
165
|
let items = loop$items;
|
|
@@ -102,9 +200,13 @@ function render_select(completed, title, items, selected, hint) {
|
|
|
102
200
|
clear_screen();
|
|
103
201
|
draw_header();
|
|
104
202
|
draw_completed(completed);
|
|
203
|
+
if (completed instanceof $Empty) {
|
|
204
|
+
undefined
|
|
205
|
+
} else {
|
|
206
|
+
$stdout.execute(toList([new $command.Println("")]))
|
|
207
|
+
}
|
|
105
208
|
$stdout.execute(
|
|
106
209
|
toList([
|
|
107
|
-
new $command.Println(""),
|
|
108
210
|
new $command.SetAttributes(toList([new $style.Bold()])),
|
|
109
211
|
new $command.Println(" " + title),
|
|
110
212
|
new $command.ResetStyle(),
|
|
@@ -217,7 +319,15 @@ export function select(completed, title, items, default$, hint) {
|
|
|
217
319
|
);
|
|
218
320
|
}
|
|
219
321
|
|
|
220
|
-
function render_input(
|
|
322
|
+
function render_input(
|
|
323
|
+
completed,
|
|
324
|
+
title,
|
|
325
|
+
value,
|
|
326
|
+
cursor,
|
|
327
|
+
error,
|
|
328
|
+
preview_lines,
|
|
329
|
+
hint
|
|
330
|
+
) {
|
|
221
331
|
clear_screen();
|
|
222
332
|
draw_header();
|
|
223
333
|
draw_completed(completed);
|
|
@@ -261,8 +371,10 @@ function render_input(completed, title, value, error, preview_lines, hint) {
|
|
|
261
371
|
}
|
|
262
372
|
}
|
|
263
373
|
draw_hint(hint);
|
|
264
|
-
let input_row = (
|
|
265
|
-
let input_col =
|
|
374
|
+
let input_row = (17 + $list.length(completed)) + 1;
|
|
375
|
+
let input_col = display_width(prefix) + display_width(
|
|
376
|
+
$string.slice(value, 0, cursor),
|
|
377
|
+
);
|
|
266
378
|
return $stdout.execute(
|
|
267
379
|
toList([
|
|
268
380
|
new $command.MoveTo(input_col, input_row),
|
|
@@ -271,7 +383,7 @@ function render_input(completed, title, value, error, preview_lines, hint) {
|
|
|
271
383
|
);
|
|
272
384
|
}
|
|
273
385
|
|
|
274
|
-
function input_loop(completed, title, value, validate, preview, hint) {
|
|
386
|
+
function input_loop(completed, title, value, cursor, validate, preview, hint) {
|
|
275
387
|
return $promise.await$(
|
|
276
388
|
$event.read(),
|
|
277
389
|
(evt) => {
|
|
@@ -294,44 +406,214 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
294
406
|
completed,
|
|
295
407
|
title,
|
|
296
408
|
value,
|
|
409
|
+
cursor,
|
|
297
410
|
validate,
|
|
298
411
|
preview,
|
|
299
412
|
hint,
|
|
300
413
|
);
|
|
301
414
|
}
|
|
302
|
-
} else if ($4 instanceof $event.
|
|
303
|
-
let
|
|
304
|
-
|
|
305
|
-
|
|
415
|
+
} else if ($4 instanceof $event.LeftArrow) {
|
|
416
|
+
let $5 = cursor > 0;
|
|
417
|
+
if ($5) {
|
|
418
|
+
let cur = cursor - 1;
|
|
419
|
+
render_input(
|
|
420
|
+
completed,
|
|
421
|
+
title,
|
|
422
|
+
value,
|
|
423
|
+
cur,
|
|
424
|
+
validate(value),
|
|
425
|
+
preview(value),
|
|
426
|
+
hint,
|
|
427
|
+
);
|
|
306
428
|
return input_loop(
|
|
307
429
|
completed,
|
|
308
430
|
title,
|
|
309
431
|
value,
|
|
432
|
+
cur,
|
|
310
433
|
validate,
|
|
311
434
|
preview,
|
|
312
435
|
hint,
|
|
313
436
|
);
|
|
314
437
|
} else {
|
|
315
|
-
return
|
|
438
|
+
return input_loop(
|
|
439
|
+
completed,
|
|
440
|
+
title,
|
|
441
|
+
value,
|
|
442
|
+
cursor,
|
|
443
|
+
validate,
|
|
444
|
+
preview,
|
|
445
|
+
hint,
|
|
446
|
+
);
|
|
316
447
|
}
|
|
317
|
-
} else if ($4 instanceof $event.
|
|
318
|
-
let
|
|
448
|
+
} else if ($4 instanceof $event.RightArrow) {
|
|
449
|
+
let len = $string.length(value);
|
|
450
|
+
let $5 = cursor < len;
|
|
451
|
+
if ($5) {
|
|
452
|
+
let cur = cursor + 1;
|
|
453
|
+
render_input(
|
|
454
|
+
completed,
|
|
455
|
+
title,
|
|
456
|
+
value,
|
|
457
|
+
cur,
|
|
458
|
+
validate(value),
|
|
459
|
+
preview(value),
|
|
460
|
+
hint,
|
|
461
|
+
);
|
|
462
|
+
return input_loop(
|
|
463
|
+
completed,
|
|
464
|
+
title,
|
|
465
|
+
value,
|
|
466
|
+
cur,
|
|
467
|
+
validate,
|
|
468
|
+
preview,
|
|
469
|
+
hint,
|
|
470
|
+
);
|
|
471
|
+
} else {
|
|
472
|
+
return input_loop(
|
|
473
|
+
completed,
|
|
474
|
+
title,
|
|
475
|
+
value,
|
|
476
|
+
cursor,
|
|
477
|
+
validate,
|
|
478
|
+
preview,
|
|
479
|
+
hint,
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
} else if ($4 instanceof $event.Home) {
|
|
319
483
|
render_input(
|
|
320
484
|
completed,
|
|
321
485
|
title,
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
486
|
+
value,
|
|
487
|
+
0,
|
|
488
|
+
validate(value),
|
|
489
|
+
preview(value),
|
|
490
|
+
hint,
|
|
491
|
+
);
|
|
492
|
+
return input_loop(
|
|
493
|
+
completed,
|
|
494
|
+
title,
|
|
495
|
+
value,
|
|
496
|
+
0,
|
|
497
|
+
validate,
|
|
498
|
+
preview,
|
|
499
|
+
hint,
|
|
500
|
+
);
|
|
501
|
+
} else if ($4 instanceof $event.End) {
|
|
502
|
+
let len = $string.length(value);
|
|
503
|
+
render_input(
|
|
504
|
+
completed,
|
|
505
|
+
title,
|
|
506
|
+
value,
|
|
507
|
+
len,
|
|
508
|
+
validate(value),
|
|
509
|
+
preview(value),
|
|
325
510
|
hint,
|
|
326
511
|
);
|
|
327
512
|
return input_loop(
|
|
328
513
|
completed,
|
|
329
514
|
title,
|
|
330
|
-
|
|
515
|
+
value,
|
|
516
|
+
len,
|
|
331
517
|
validate,
|
|
332
518
|
preview,
|
|
333
519
|
hint,
|
|
334
520
|
);
|
|
521
|
+
} else if ($4 instanceof $event.Delete) {
|
|
522
|
+
let len = $string.length(value);
|
|
523
|
+
let $5 = cursor < len;
|
|
524
|
+
if ($5) {
|
|
525
|
+
let before = $string.slice(value, 0, cursor);
|
|
526
|
+
let after = $string.slice(
|
|
527
|
+
value,
|
|
528
|
+
cursor + 1,
|
|
529
|
+
(len - cursor) - 1,
|
|
530
|
+
);
|
|
531
|
+
let v = before + after;
|
|
532
|
+
render_input(
|
|
533
|
+
completed,
|
|
534
|
+
title,
|
|
535
|
+
v,
|
|
536
|
+
cursor,
|
|
537
|
+
validate(v),
|
|
538
|
+
preview(v),
|
|
539
|
+
hint,
|
|
540
|
+
);
|
|
541
|
+
return input_loop(
|
|
542
|
+
completed,
|
|
543
|
+
title,
|
|
544
|
+
v,
|
|
545
|
+
cursor,
|
|
546
|
+
validate,
|
|
547
|
+
preview,
|
|
548
|
+
hint,
|
|
549
|
+
);
|
|
550
|
+
} else {
|
|
551
|
+
return input_loop(
|
|
552
|
+
completed,
|
|
553
|
+
title,
|
|
554
|
+
value,
|
|
555
|
+
cursor,
|
|
556
|
+
validate,
|
|
557
|
+
preview,
|
|
558
|
+
hint,
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
} else if ($4 instanceof $event.Enter) {
|
|
562
|
+
let trimmed = $string.trim(value);
|
|
563
|
+
let $5 = validate(trimmed);
|
|
564
|
+
if ($5 instanceof Some) {
|
|
565
|
+
return input_loop(
|
|
566
|
+
completed,
|
|
567
|
+
title,
|
|
568
|
+
value,
|
|
569
|
+
cursor,
|
|
570
|
+
validate,
|
|
571
|
+
preview,
|
|
572
|
+
hint,
|
|
573
|
+
);
|
|
574
|
+
} else {
|
|
575
|
+
return $promise.resolve(new Ok(trimmed));
|
|
576
|
+
}
|
|
577
|
+
} else if ($4 instanceof $event.Backspace) {
|
|
578
|
+
let $5 = cursor > 0;
|
|
579
|
+
if ($5) {
|
|
580
|
+
let before = $string.slice(value, 0, cursor - 1);
|
|
581
|
+
let after = $string.slice(
|
|
582
|
+
value,
|
|
583
|
+
cursor,
|
|
584
|
+
$string.length(value) - cursor,
|
|
585
|
+
);
|
|
586
|
+
let v = before + after;
|
|
587
|
+
let cur = cursor - 1;
|
|
588
|
+
render_input(
|
|
589
|
+
completed,
|
|
590
|
+
title,
|
|
591
|
+
v,
|
|
592
|
+
cur,
|
|
593
|
+
validate(v),
|
|
594
|
+
preview(v),
|
|
595
|
+
hint,
|
|
596
|
+
);
|
|
597
|
+
return input_loop(
|
|
598
|
+
completed,
|
|
599
|
+
title,
|
|
600
|
+
v,
|
|
601
|
+
cur,
|
|
602
|
+
validate,
|
|
603
|
+
preview,
|
|
604
|
+
hint,
|
|
605
|
+
);
|
|
606
|
+
} else {
|
|
607
|
+
return input_loop(
|
|
608
|
+
completed,
|
|
609
|
+
title,
|
|
610
|
+
value,
|
|
611
|
+
cursor,
|
|
612
|
+
validate,
|
|
613
|
+
preview,
|
|
614
|
+
hint,
|
|
615
|
+
);
|
|
616
|
+
}
|
|
335
617
|
} else if ($4 instanceof $event.Esc) {
|
|
336
618
|
return $promise.resolve(new Error(undefined));
|
|
337
619
|
} else {
|
|
@@ -339,6 +621,7 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
339
621
|
completed,
|
|
340
622
|
title,
|
|
341
623
|
value,
|
|
624
|
+
cursor,
|
|
342
625
|
validate,
|
|
343
626
|
preview,
|
|
344
627
|
hint,
|
|
@@ -349,6 +632,7 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
349
632
|
completed,
|
|
350
633
|
title,
|
|
351
634
|
value,
|
|
635
|
+
cursor,
|
|
352
636
|
validate,
|
|
353
637
|
preview,
|
|
354
638
|
hint,
|
|
@@ -362,11 +646,19 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
362
646
|
let $5 = $1[0].code;
|
|
363
647
|
if ($5 instanceof $event.Char) {
|
|
364
648
|
let c = $5[0];
|
|
365
|
-
let
|
|
649
|
+
let before = $string.slice(value, 0, cursor);
|
|
650
|
+
let after = $string.slice(
|
|
651
|
+
value,
|
|
652
|
+
cursor,
|
|
653
|
+
$string.length(value) - cursor,
|
|
654
|
+
);
|
|
655
|
+
let v = (before + c) + after;
|
|
656
|
+
let cur = cursor + 1;
|
|
366
657
|
render_input(
|
|
367
658
|
completed,
|
|
368
659
|
title,
|
|
369
660
|
v,
|
|
661
|
+
cur,
|
|
370
662
|
validate(v),
|
|
371
663
|
preview(v),
|
|
372
664
|
hint,
|
|
@@ -375,43 +667,213 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
375
667
|
completed,
|
|
376
668
|
title,
|
|
377
669
|
v,
|
|
670
|
+
cur,
|
|
378
671
|
validate,
|
|
379
672
|
preview,
|
|
380
673
|
hint,
|
|
381
674
|
);
|
|
382
|
-
} else if ($5 instanceof $event.
|
|
383
|
-
let
|
|
384
|
-
|
|
385
|
-
|
|
675
|
+
} else if ($5 instanceof $event.LeftArrow) {
|
|
676
|
+
let $6 = cursor > 0;
|
|
677
|
+
if ($6) {
|
|
678
|
+
let cur = cursor - 1;
|
|
679
|
+
render_input(
|
|
680
|
+
completed,
|
|
681
|
+
title,
|
|
682
|
+
value,
|
|
683
|
+
cur,
|
|
684
|
+
validate(value),
|
|
685
|
+
preview(value),
|
|
686
|
+
hint,
|
|
687
|
+
);
|
|
386
688
|
return input_loop(
|
|
387
689
|
completed,
|
|
388
690
|
title,
|
|
389
691
|
value,
|
|
692
|
+
cur,
|
|
390
693
|
validate,
|
|
391
694
|
preview,
|
|
392
695
|
hint,
|
|
393
696
|
);
|
|
394
697
|
} else {
|
|
395
|
-
return
|
|
698
|
+
return input_loop(
|
|
699
|
+
completed,
|
|
700
|
+
title,
|
|
701
|
+
value,
|
|
702
|
+
cursor,
|
|
703
|
+
validate,
|
|
704
|
+
preview,
|
|
705
|
+
hint,
|
|
706
|
+
);
|
|
396
707
|
}
|
|
397
|
-
} else if ($5 instanceof $event.
|
|
398
|
-
let
|
|
708
|
+
} else if ($5 instanceof $event.RightArrow) {
|
|
709
|
+
let len = $string.length(value);
|
|
710
|
+
let $6 = cursor < len;
|
|
711
|
+
if ($6) {
|
|
712
|
+
let cur = cursor + 1;
|
|
713
|
+
render_input(
|
|
714
|
+
completed,
|
|
715
|
+
title,
|
|
716
|
+
value,
|
|
717
|
+
cur,
|
|
718
|
+
validate(value),
|
|
719
|
+
preview(value),
|
|
720
|
+
hint,
|
|
721
|
+
);
|
|
722
|
+
return input_loop(
|
|
723
|
+
completed,
|
|
724
|
+
title,
|
|
725
|
+
value,
|
|
726
|
+
cur,
|
|
727
|
+
validate,
|
|
728
|
+
preview,
|
|
729
|
+
hint,
|
|
730
|
+
);
|
|
731
|
+
} else {
|
|
732
|
+
return input_loop(
|
|
733
|
+
completed,
|
|
734
|
+
title,
|
|
735
|
+
value,
|
|
736
|
+
cursor,
|
|
737
|
+
validate,
|
|
738
|
+
preview,
|
|
739
|
+
hint,
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
} else if ($5 instanceof $event.Home) {
|
|
399
743
|
render_input(
|
|
400
744
|
completed,
|
|
401
745
|
title,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
746
|
+
value,
|
|
747
|
+
0,
|
|
748
|
+
validate(value),
|
|
749
|
+
preview(value),
|
|
405
750
|
hint,
|
|
406
751
|
);
|
|
407
752
|
return input_loop(
|
|
408
753
|
completed,
|
|
409
754
|
title,
|
|
410
|
-
|
|
755
|
+
value,
|
|
756
|
+
0,
|
|
757
|
+
validate,
|
|
758
|
+
preview,
|
|
759
|
+
hint,
|
|
760
|
+
);
|
|
761
|
+
} else if ($5 instanceof $event.End) {
|
|
762
|
+
let len = $string.length(value);
|
|
763
|
+
render_input(
|
|
764
|
+
completed,
|
|
765
|
+
title,
|
|
766
|
+
value,
|
|
767
|
+
len,
|
|
768
|
+
validate(value),
|
|
769
|
+
preview(value),
|
|
770
|
+
hint,
|
|
771
|
+
);
|
|
772
|
+
return input_loop(
|
|
773
|
+
completed,
|
|
774
|
+
title,
|
|
775
|
+
value,
|
|
776
|
+
len,
|
|
411
777
|
validate,
|
|
412
778
|
preview,
|
|
413
779
|
hint,
|
|
414
780
|
);
|
|
781
|
+
} else if ($5 instanceof $event.Delete) {
|
|
782
|
+
let len = $string.length(value);
|
|
783
|
+
let $6 = cursor < len;
|
|
784
|
+
if ($6) {
|
|
785
|
+
let before = $string.slice(value, 0, cursor);
|
|
786
|
+
let after = $string.slice(
|
|
787
|
+
value,
|
|
788
|
+
cursor + 1,
|
|
789
|
+
(len - cursor) - 1,
|
|
790
|
+
);
|
|
791
|
+
let v = before + after;
|
|
792
|
+
render_input(
|
|
793
|
+
completed,
|
|
794
|
+
title,
|
|
795
|
+
v,
|
|
796
|
+
cursor,
|
|
797
|
+
validate(v),
|
|
798
|
+
preview(v),
|
|
799
|
+
hint,
|
|
800
|
+
);
|
|
801
|
+
return input_loop(
|
|
802
|
+
completed,
|
|
803
|
+
title,
|
|
804
|
+
v,
|
|
805
|
+
cursor,
|
|
806
|
+
validate,
|
|
807
|
+
preview,
|
|
808
|
+
hint,
|
|
809
|
+
);
|
|
810
|
+
} else {
|
|
811
|
+
return input_loop(
|
|
812
|
+
completed,
|
|
813
|
+
title,
|
|
814
|
+
value,
|
|
815
|
+
cursor,
|
|
816
|
+
validate,
|
|
817
|
+
preview,
|
|
818
|
+
hint,
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
} else if ($5 instanceof $event.Enter) {
|
|
822
|
+
let trimmed = $string.trim(value);
|
|
823
|
+
let $6 = validate(trimmed);
|
|
824
|
+
if ($6 instanceof Some) {
|
|
825
|
+
return input_loop(
|
|
826
|
+
completed,
|
|
827
|
+
title,
|
|
828
|
+
value,
|
|
829
|
+
cursor,
|
|
830
|
+
validate,
|
|
831
|
+
preview,
|
|
832
|
+
hint,
|
|
833
|
+
);
|
|
834
|
+
} else {
|
|
835
|
+
return $promise.resolve(new Ok(trimmed));
|
|
836
|
+
}
|
|
837
|
+
} else if ($5 instanceof $event.Backspace) {
|
|
838
|
+
let $6 = cursor > 0;
|
|
839
|
+
if ($6) {
|
|
840
|
+
let before = $string.slice(value, 0, cursor - 1);
|
|
841
|
+
let after = $string.slice(
|
|
842
|
+
value,
|
|
843
|
+
cursor,
|
|
844
|
+
$string.length(value) - cursor,
|
|
845
|
+
);
|
|
846
|
+
let v = before + after;
|
|
847
|
+
let cur = cursor - 1;
|
|
848
|
+
render_input(
|
|
849
|
+
completed,
|
|
850
|
+
title,
|
|
851
|
+
v,
|
|
852
|
+
cur,
|
|
853
|
+
validate(v),
|
|
854
|
+
preview(v),
|
|
855
|
+
hint,
|
|
856
|
+
);
|
|
857
|
+
return input_loop(
|
|
858
|
+
completed,
|
|
859
|
+
title,
|
|
860
|
+
v,
|
|
861
|
+
cur,
|
|
862
|
+
validate,
|
|
863
|
+
preview,
|
|
864
|
+
hint,
|
|
865
|
+
);
|
|
866
|
+
} else {
|
|
867
|
+
return input_loop(
|
|
868
|
+
completed,
|
|
869
|
+
title,
|
|
870
|
+
value,
|
|
871
|
+
cursor,
|
|
872
|
+
validate,
|
|
873
|
+
preview,
|
|
874
|
+
hint,
|
|
875
|
+
);
|
|
876
|
+
}
|
|
415
877
|
} else if ($5 instanceof $event.Esc) {
|
|
416
878
|
return $promise.resolve(new Error(undefined));
|
|
417
879
|
} else {
|
|
@@ -419,6 +881,7 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
419
881
|
completed,
|
|
420
882
|
title,
|
|
421
883
|
value,
|
|
884
|
+
cursor,
|
|
422
885
|
validate,
|
|
423
886
|
preview,
|
|
424
887
|
hint,
|
|
@@ -429,6 +892,7 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
429
892
|
completed,
|
|
430
893
|
title,
|
|
431
894
|
value,
|
|
895
|
+
cursor,
|
|
432
896
|
validate,
|
|
433
897
|
preview,
|
|
434
898
|
hint,
|
|
@@ -438,39 +902,208 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
438
902
|
let $4 = $1[0].kind;
|
|
439
903
|
if ($4 instanceof $event.Press) {
|
|
440
904
|
let $5 = $1[0].code;
|
|
441
|
-
if ($5 instanceof $event.
|
|
442
|
-
let
|
|
443
|
-
|
|
444
|
-
|
|
905
|
+
if ($5 instanceof $event.LeftArrow) {
|
|
906
|
+
let $6 = cursor > 0;
|
|
907
|
+
if ($6) {
|
|
908
|
+
let cur = cursor - 1;
|
|
909
|
+
render_input(
|
|
910
|
+
completed,
|
|
911
|
+
title,
|
|
912
|
+
value,
|
|
913
|
+
cur,
|
|
914
|
+
validate(value),
|
|
915
|
+
preview(value),
|
|
916
|
+
hint,
|
|
917
|
+
);
|
|
445
918
|
return input_loop(
|
|
446
919
|
completed,
|
|
447
920
|
title,
|
|
448
921
|
value,
|
|
922
|
+
cur,
|
|
449
923
|
validate,
|
|
450
924
|
preview,
|
|
451
925
|
hint,
|
|
452
926
|
);
|
|
453
927
|
} else {
|
|
454
|
-
return
|
|
928
|
+
return input_loop(
|
|
929
|
+
completed,
|
|
930
|
+
title,
|
|
931
|
+
value,
|
|
932
|
+
cursor,
|
|
933
|
+
validate,
|
|
934
|
+
preview,
|
|
935
|
+
hint,
|
|
936
|
+
);
|
|
455
937
|
}
|
|
456
|
-
} else if ($5 instanceof $event.
|
|
457
|
-
let
|
|
938
|
+
} else if ($5 instanceof $event.RightArrow) {
|
|
939
|
+
let len = $string.length(value);
|
|
940
|
+
let $6 = cursor < len;
|
|
941
|
+
if ($6) {
|
|
942
|
+
let cur = cursor + 1;
|
|
943
|
+
render_input(
|
|
944
|
+
completed,
|
|
945
|
+
title,
|
|
946
|
+
value,
|
|
947
|
+
cur,
|
|
948
|
+
validate(value),
|
|
949
|
+
preview(value),
|
|
950
|
+
hint,
|
|
951
|
+
);
|
|
952
|
+
return input_loop(
|
|
953
|
+
completed,
|
|
954
|
+
title,
|
|
955
|
+
value,
|
|
956
|
+
cur,
|
|
957
|
+
validate,
|
|
958
|
+
preview,
|
|
959
|
+
hint,
|
|
960
|
+
);
|
|
961
|
+
} else {
|
|
962
|
+
return input_loop(
|
|
963
|
+
completed,
|
|
964
|
+
title,
|
|
965
|
+
value,
|
|
966
|
+
cursor,
|
|
967
|
+
validate,
|
|
968
|
+
preview,
|
|
969
|
+
hint,
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
} else if ($5 instanceof $event.Home) {
|
|
458
973
|
render_input(
|
|
459
974
|
completed,
|
|
460
975
|
title,
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
976
|
+
value,
|
|
977
|
+
0,
|
|
978
|
+
validate(value),
|
|
979
|
+
preview(value),
|
|
464
980
|
hint,
|
|
465
981
|
);
|
|
466
982
|
return input_loop(
|
|
467
983
|
completed,
|
|
468
984
|
title,
|
|
469
|
-
|
|
985
|
+
value,
|
|
986
|
+
0,
|
|
987
|
+
validate,
|
|
988
|
+
preview,
|
|
989
|
+
hint,
|
|
990
|
+
);
|
|
991
|
+
} else if ($5 instanceof $event.End) {
|
|
992
|
+
let len = $string.length(value);
|
|
993
|
+
render_input(
|
|
994
|
+
completed,
|
|
995
|
+
title,
|
|
996
|
+
value,
|
|
997
|
+
len,
|
|
998
|
+
validate(value),
|
|
999
|
+
preview(value),
|
|
1000
|
+
hint,
|
|
1001
|
+
);
|
|
1002
|
+
return input_loop(
|
|
1003
|
+
completed,
|
|
1004
|
+
title,
|
|
1005
|
+
value,
|
|
1006
|
+
len,
|
|
470
1007
|
validate,
|
|
471
1008
|
preview,
|
|
472
1009
|
hint,
|
|
473
1010
|
);
|
|
1011
|
+
} else if ($5 instanceof $event.Delete) {
|
|
1012
|
+
let len = $string.length(value);
|
|
1013
|
+
let $6 = cursor < len;
|
|
1014
|
+
if ($6) {
|
|
1015
|
+
let before = $string.slice(value, 0, cursor);
|
|
1016
|
+
let after = $string.slice(
|
|
1017
|
+
value,
|
|
1018
|
+
cursor + 1,
|
|
1019
|
+
(len - cursor) - 1,
|
|
1020
|
+
);
|
|
1021
|
+
let v = before + after;
|
|
1022
|
+
render_input(
|
|
1023
|
+
completed,
|
|
1024
|
+
title,
|
|
1025
|
+
v,
|
|
1026
|
+
cursor,
|
|
1027
|
+
validate(v),
|
|
1028
|
+
preview(v),
|
|
1029
|
+
hint,
|
|
1030
|
+
);
|
|
1031
|
+
return input_loop(
|
|
1032
|
+
completed,
|
|
1033
|
+
title,
|
|
1034
|
+
v,
|
|
1035
|
+
cursor,
|
|
1036
|
+
validate,
|
|
1037
|
+
preview,
|
|
1038
|
+
hint,
|
|
1039
|
+
);
|
|
1040
|
+
} else {
|
|
1041
|
+
return input_loop(
|
|
1042
|
+
completed,
|
|
1043
|
+
title,
|
|
1044
|
+
value,
|
|
1045
|
+
cursor,
|
|
1046
|
+
validate,
|
|
1047
|
+
preview,
|
|
1048
|
+
hint,
|
|
1049
|
+
);
|
|
1050
|
+
}
|
|
1051
|
+
} else if ($5 instanceof $event.Enter) {
|
|
1052
|
+
let trimmed = $string.trim(value);
|
|
1053
|
+
let $6 = validate(trimmed);
|
|
1054
|
+
if ($6 instanceof Some) {
|
|
1055
|
+
return input_loop(
|
|
1056
|
+
completed,
|
|
1057
|
+
title,
|
|
1058
|
+
value,
|
|
1059
|
+
cursor,
|
|
1060
|
+
validate,
|
|
1061
|
+
preview,
|
|
1062
|
+
hint,
|
|
1063
|
+
);
|
|
1064
|
+
} else {
|
|
1065
|
+
return $promise.resolve(new Ok(trimmed));
|
|
1066
|
+
}
|
|
1067
|
+
} else if ($5 instanceof $event.Backspace) {
|
|
1068
|
+
let $6 = cursor > 0;
|
|
1069
|
+
if ($6) {
|
|
1070
|
+
let before = $string.slice(value, 0, cursor - 1);
|
|
1071
|
+
let after = $string.slice(
|
|
1072
|
+
value,
|
|
1073
|
+
cursor,
|
|
1074
|
+
$string.length(value) - cursor,
|
|
1075
|
+
);
|
|
1076
|
+
let v = before + after;
|
|
1077
|
+
let cur = cursor - 1;
|
|
1078
|
+
render_input(
|
|
1079
|
+
completed,
|
|
1080
|
+
title,
|
|
1081
|
+
v,
|
|
1082
|
+
cur,
|
|
1083
|
+
validate(v),
|
|
1084
|
+
preview(v),
|
|
1085
|
+
hint,
|
|
1086
|
+
);
|
|
1087
|
+
return input_loop(
|
|
1088
|
+
completed,
|
|
1089
|
+
title,
|
|
1090
|
+
v,
|
|
1091
|
+
cur,
|
|
1092
|
+
validate,
|
|
1093
|
+
preview,
|
|
1094
|
+
hint,
|
|
1095
|
+
);
|
|
1096
|
+
} else {
|
|
1097
|
+
return input_loop(
|
|
1098
|
+
completed,
|
|
1099
|
+
title,
|
|
1100
|
+
value,
|
|
1101
|
+
cursor,
|
|
1102
|
+
validate,
|
|
1103
|
+
preview,
|
|
1104
|
+
hint,
|
|
1105
|
+
);
|
|
1106
|
+
}
|
|
474
1107
|
} else if ($5 instanceof $event.Esc) {
|
|
475
1108
|
return $promise.resolve(new Error(undefined));
|
|
476
1109
|
} else {
|
|
@@ -478,6 +1111,7 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
478
1111
|
completed,
|
|
479
1112
|
title,
|
|
480
1113
|
value,
|
|
1114
|
+
cursor,
|
|
481
1115
|
validate,
|
|
482
1116
|
preview,
|
|
483
1117
|
hint,
|
|
@@ -488,6 +1122,7 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
488
1122
|
completed,
|
|
489
1123
|
title,
|
|
490
1124
|
value,
|
|
1125
|
+
cursor,
|
|
491
1126
|
validate,
|
|
492
1127
|
preview,
|
|
493
1128
|
hint,
|
|
@@ -496,26 +1131,52 @@ function input_loop(completed, title, value, validate, preview, hint) {
|
|
|
496
1131
|
}
|
|
497
1132
|
}
|
|
498
1133
|
} else {
|
|
499
|
-
return input_loop(
|
|
1134
|
+
return input_loop(
|
|
1135
|
+
completed,
|
|
1136
|
+
title,
|
|
1137
|
+
value,
|
|
1138
|
+
cursor,
|
|
1139
|
+
validate,
|
|
1140
|
+
preview,
|
|
1141
|
+
hint,
|
|
1142
|
+
);
|
|
500
1143
|
}
|
|
501
1144
|
} else {
|
|
502
|
-
return input_loop(
|
|
1145
|
+
return input_loop(
|
|
1146
|
+
completed,
|
|
1147
|
+
title,
|
|
1148
|
+
value,
|
|
1149
|
+
cursor,
|
|
1150
|
+
validate,
|
|
1151
|
+
preview,
|
|
1152
|
+
hint,
|
|
1153
|
+
);
|
|
503
1154
|
}
|
|
504
1155
|
} else {
|
|
505
|
-
return input_loop(
|
|
1156
|
+
return input_loop(
|
|
1157
|
+
completed,
|
|
1158
|
+
title,
|
|
1159
|
+
value,
|
|
1160
|
+
cursor,
|
|
1161
|
+
validate,
|
|
1162
|
+
preview,
|
|
1163
|
+
hint,
|
|
1164
|
+
);
|
|
506
1165
|
}
|
|
507
1166
|
},
|
|
508
1167
|
);
|
|
509
1168
|
}
|
|
510
1169
|
|
|
511
1170
|
export function text_input(completed, title, initial, validate, preview, hint) {
|
|
1171
|
+
let cursor = $string.length(initial);
|
|
512
1172
|
render_input(
|
|
513
1173
|
completed,
|
|
514
1174
|
title,
|
|
515
1175
|
initial,
|
|
1176
|
+
cursor,
|
|
516
1177
|
validate(initial),
|
|
517
1178
|
preview(initial),
|
|
518
1179
|
hint,
|
|
519
1180
|
);
|
|
520
|
-
return input_loop(completed, title, initial, validate, preview, hint);
|
|
1181
|
+
return input_loop(completed, title, initial, cursor, validate, preview, hint);
|
|
521
1182
|
}
|