Skip to content

Commit 19c96b3

Browse files
committed
add :help
1 parent d6f3d82 commit 19c96b3

File tree

5 files changed

+165
-3
lines changed

5 files changed

+165
-3
lines changed

AndroidIDE/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="5" android:versionName="0.1.7" package="dzaima.aplide">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="5" android:versionName="0.1.8" package="dzaima.aplide">
33
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="28"/>
44
<application android:icon="@mipmap/ic_launcher" android:label="">
55
<activity android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">

AndroidIDE/Highlight.pde

+3-1
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,7 @@ static class Theme {
192192

193193
int caret = def;
194194
int[] dfn = {#AA77BB, #EEBB44, #CC7799, #CCDD00, #B63CDA};
195-
195+
}
196+
static class NoErrTheme extends Theme {
197+
{ err = #AA77BB; }
196198
}

AndroidIDE/Tab.pde

+31-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static class REPL extends Tab {
4545
inputs.add(line);
4646
iptr = inputs.size();
4747
textln(" "+line+"\n");
48-
if (line.startsWith(":")) {
48+
if (line.startsWith(":") || line.equals(")help")) {
4949
String cmd = line.substring(1);
5050
int i = cmd.indexOf(" ");
5151
String nm = i==-1? cmd : cmd.substring(0, i);
@@ -102,6 +102,28 @@ static class REPL extends Tab {
102102
if (o instanceof Ddop) {
103103
topbar.toNew(new Ed(nm, ((Ddop) o).code.source()));
104104
}
105+
} else if (nm.equals("h") || nm.equals("help")) {
106+
if (arg.length()==0) {
107+
textln("commands:");
108+
textln(":h/:help view this help page");
109+
textln(":h kb view help for keyboard layout");
110+
textln(":h c view character docs");
111+
textln(":isz sz change input box font size");
112+
textln(":hsz sz change REPL history font size");
113+
textln(":tsz sz change top bar size");
114+
textln(":g expr graph the expression (editable in the window)");
115+
textln(":clear clear REPL history");
116+
textln(":f path edit file at the path");
117+
textln(":fx path edit file at the path, executing on save");
118+
textln(":ex path execute file at the path");
119+
textln(":ed fn edit the function by name in another window (= - save, ⏎ - newline, X - save (!) & close)");
120+
} else {
121+
if (arg.equals("kb")) {
122+
topbar.toNew(new HelpEd(":help kb", join(a.loadStrings("help_kb.txt"), '\n')));
123+
} else if (arg.equals("c")) {
124+
topbar.toNew(new HelpEd(":help c", join(a.loadStrings("help_c.txt"), '\n')));
125+
} else textln("unknown help page \""+arg+"\"");
126+
}
105127
} else textln("Command "+nm+" not found");
106128
//else if (nm.equals(""))
107129
return;
@@ -222,6 +244,14 @@ abstract static class Editor extends Tab {
222244
}
223245
}
224246

247+
static class HelpEd extends Editor {
248+
HelpEd(String name, String val) {
249+
super(name, val);
250+
ta.th = new NoErrTheme();
251+
}
252+
void save(String val) {
253+
}
254+
}
225255

226256
static class Grapher extends Tab {
227257
Graph g;

AndroidIDE/data/help_c.txt

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
fns:
2+
dyadic monadic
3+
+ add; identity (no complex numbers)
4+
- sub; negate / swap case
5+
× mul; sign / case (i.e. ×'Hi ' → 1 ¯1 0) / ×|map
6+
÷ div; 1÷⍵
7+
* pow; e*⍵
8+
⍟ log; e⍟⍵
9+
√ root; 2√⍵
10+
⌈ max; ceil / uppercase
11+
⌊ min; floor / lowercase
12+
| mod; abs / map size
13+
∧ lcm; lcm (aka every; all 1)
14+
∨ gcd; gcd (aka some; contains 1)
15+
⍲ nand; not all / contains 0
16+
⍱ nor; none / all 0
17+
⊥ from; 2⊥⍵; aka decode, pack
18+
⊤ to; 2⊤⍵; aka encode, unpack
19+
○ trig; pi×⍵
20+
! nCk; factorial
21+
22+
monadic dyadic
23+
∊ in; enlist
24+
⍷ NYI; find
25+
⌷ map k&v; select cell
26+
⍳ indexes; where
27+
~ without; negate
28+
⍸ where; NYI; where can contain >1; also ⍸⍣¯1 is useful
29+
⍴ shape; reshape
30+
, ravel; concat
31+
⍮ ,⊂; {⍺⍵}
32+
≢ tally; not equal
33+
≡ depth; equal
34+
⊢ ⍵; ⍵
35+
⊣ ⍵; ⍺
36+
↑ merge; take; merge as in merge dimensions
37+
↓ split; drop; split off last dimension as arrays
38+
? rand; deal
39+
⍪ table; vertical concat
40+
⊖ flip; vertical rotate
41+
⌽ reverse; horizontal rotate
42+
… NYI; range
43+
⍕ format; NYI
44+
⍎ eval; eval arrayified (`-⍎4)
45+
⌿ NYI; replicate
46+
⍀ NYI; expand
47+
∪ unique; union
48+
∩ NYI; intersection
49+
⊂ enclose; split
50+
⊃ first; get single item ('ab'≡1 1⊃2 2⍴⊂'ab')
51+
⊇ NYI; multi-select (subject to ⎕VI)
52+
% NYI; merge - 1 2 2 3%4↑¨⎕a⎕l⎕d → 'Abc3'
53+
⍋ grade up; NYI
54+
⍒ grade down; NYI
55+
⍉ transpose; NYI
56+
⍧ unique mask; count
57+
58+
59+
< lt; sort asc
60+
≤ le; NYI
61+
= eq; NYI
62+
≥ ge; NYI
63+
> gt; sort desc
64+
≠ ne; NYI (⍧ is unique mask)
65+
66+
monadic ops:
67+
68+
/ reduce
69+
\ left scan
70+
¨ for each
71+
⍨ selfie; commute
72+
⌾ table (aka ∘.⍺⍺)
73+
⌸ key; also get/set map keys (e.g. 'x'(map⌸)5; map⌸'x')
74+
ᐵ each-left (A fᐵ B ≡ A f¨ ⊂B)
75+
ᑈ each-right (A fᑈ B ≡ (⊂A) f¨ B)
76+
77+
dyadic ops
78+
79+
∘ compose (←→ {⍶ ⍹ ⍵} or {⍺ ⍶ ⍹ ⍵})
80+
⍛ left-compose (←→ {(⍶ ⍺) ⍹ ⍵})
81+
. NYI (well, ←→ {⍶/ ⍺ ⍹ ⍵})
82+
⍣ repeat
83+
⍡ cumulative repeat
84+
⍥ over (←→ {(⍹⍺) ⍶ ⍹⍵} )
85+
⍤ atop (←→ {⍺⍺ ⍺ ⍵⍵ ⍵} )
86+
⍢ under (←→ {⍺←{⍺⍺⋄⍵}⋄(⍹⍣¯1) (⍹⍺) ⍶ ⍹⍵}; also is structural under; ⍺⍺ can be an array)
87+
⍫ obverse - define inverse: ⍶ - regular function, ⍹ - inverse
88+
@ at; right op = indices or function giving boolean array, left op = replacement array or function
89+
⍁ for each diagonal
90+
91+
nilads:
92+
93+
⍬ 0⍴0
94+
⎕ console (println; exec input line)
95+
⍞ console (print ; input as string)
96+
⍺ left arg
97+
⍵ right arg
98+
⍶ left operand
99+
⍹ right operand
100+
∇ this function
101+
102+
dfns:
103+
{A ⋄ B} → B (also executing A)
104+
{C:A ⋄ B} → B (also executing A if C was true)
105+
{C:←A ⋄ B} → A if C, else B

AndroidIDE/data/help_kb.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
swipe on characters to enter ones around it
2+
M - go to matching bracket
3+
F - switch layout to one with extra functions
4+
N - switch layout to numbers at top-level
5+
A - switch to text layout
6+
# - switch to default layout
7+
⇧ - shift (caps letters, select with «»)
8+
X - close tab (where applicable - grapher & editor)
9+
K - open virtual keyboard
10+
= - evaluate
11+
12+
↶↷ - undo/redo
13+
▲▼ - move trough REPL history
14+
^C/^V - copy/paste
15+
16+
17+
:isz sz change input box font size
18+
:hsz sz change REPL history font size
19+
:tsz sz change top bar size
20+
:g expr graph the expression (editable in the window)
21+
:clear clear REPL history
22+
:f path edit file at the path
23+
:fx path edit file at the path, executing on save
24+
:ex path execute file at the path
25+
:ed fn edit the function by name in another window (= - save, ⏎ - newline, X - save (!) & close)

0 commit comments

Comments
 (0)