diff options
author | glenda <glenda@cirno> | 2022-09-10 16:25:05 +0000 |
---|---|---|
committer | glenda <glenda@cirno> | 2022-09-10 16:25:05 +0000 |
commit | e2ebfbb7d19ff3b990eb51dc9843200053cbbf98 (patch) | |
tree | 986b0353a1179f803872b1578ebfe0acd83050bd /runtime/start.apl | |
parent | d07d4afcb8acff3757394f2f9822d014f31fecf0 (diff) |
Improve the session a lot
Diffstat (limited to 'runtime/start.apl')
-rw-r--r-- | runtime/start.apl | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/runtime/start.apl b/runtime/start.apl index 46a0703..c98462e 100644 --- a/runtime/start.apl +++ b/runtime/start.apl @@ -1,15 +1,41 @@ -send←⍈ ⍝ I can't type those easily so give them names -recv←⍇ -prompt←6⍴' ' -session←{ - (task data)←{1 ⍵} recv ⍬ - ⎕rawio←{¯1≡⍵:'???:' ⋄ ⍵,':'} task ⎕tasks 1 - ⎕rawio←data - ⍞rawio←prompt - ∇⍵ -} - +⎕session←{ + (indented main prompt)←⍵ + unindent←{ + ⎕rawio←⎕ucs ⍺⍴8 + } + handleError←{ + 0::⍺ + (task (error msg taskname))←⍵ + ⎕rawio←error,' in [',(⍕task),':',taskname,']' + _←{⎕rawio←': ', msg} IF msg≢'' + ⎕rawio←⎕ucs 10 + ⎕rawio←prompt + ≢prompt + } + handleQuad←{ + 0::⍺ + data←⍵ + ⎕rawio←data + ⎕rawio←⎕ucs 10 + ⎕rawio←prompt + ≢prompt + } + handleQuoteQuad←{ + 0::⍺ + data←⍵ + ⎕rawio←data + ⍺ + } + handle←{ + 0::⍺ + (task (type data))←⍵ + indented←⍺ + _←indented∘unindent IF (indented>0)∧task≢main + type≡'!': 0 handleError task data + type≡'⎕': 0 handleQuad data + type≡'⍞': 0 handleQuoteQuad data + ⍵ + } + {∇ ⍵ handle {1 ⍵}⍇⍬} indented +}&'session'⊢0 ⎕self (6⍴' ') ⎕←'Welcome to APL9' -⍞rawio←prompt - -⎕session←session&'session'⊢⍬
\ No newline at end of file |