Uses 911K of libraries. Click here for Pure Java version (8338L/44K).
1 | !7 |
2 | |
3 | !include once #1020738 // Loadable Utils |
4 | |
5 | srecord Definition(S word, S definition) {} |
6 | |
7 | module DefinitionsByVoice > DynObjectTable<Definition> { |
8 | bool voiceMode; |
9 | |
10 | visualize { |
11 | ret withRightAlignedButtons(super.visualize(), |
12 | dm_fieldCheckBox('voiceMode)); |
13 | } |
14 | |
15 | start { |
16 | dm_useLocalMechListCopies(); |
17 | dontPersist(); |
18 | fieldsInOrder = true; |
19 | dm_onTopInput(voidfunc(fS s) { reactTo(s) }); |
20 | reactTo(dm_getTopInput()); |
21 | } |
22 | |
23 | void _search(fS s) { |
24 | bool wasEmpty = count() == 0; |
25 | L<Definition> l = map(func(S def) -> Definition { Definition(s, def) }, dm_getDefinitions(s)); |
26 | if (empty(l)) ret; |
27 | addAll(l); |
28 | vmBus_send(wasEmpty ? 'firstResults : 'moreResults, this); |
29 | if (voiceMode && wasEmpty) |
30 | dm_say(first(l).definition); |
31 | } |
32 | |
33 | // API |
34 | |
35 | void reactTo(fS s) enter { |
36 | switch to q(); |
37 | clear(); |
38 | _search(s); |
39 | new Matches m; |
40 | for (S x : matchX_any_allRests(mL("Query Definition Patterns"), s)) |
41 | _search(x); |
42 | if (nempty(data)) dm_showModule_noFocus(); |
43 | } |
44 | } |
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020313 |
Snippet name: | Show Definitions By Voice |
Eternal ID of this version: | #1020313/17 |
Text MD5: | 133c697da923f3fcb41ec9cbcd65a4a9 |
Transpilation MD5: | 71fb3f1aad88bf89b847a5d879148166 |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-01-01 18:56:07 |
Source code size: | 1075 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 344 / 2597 |
Version history: | 16 change(s) |
Referenced in: | [show references] |