-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrint.aplf
51 lines (46 loc) · 2.02 KB
/
Print.aplf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
a Print e;title;nc;content;dr;Scale;t
:If {6::1 ⋄ 0⊣⍵.Type}hr ⍝ if window has been closed
stop ⍝ reset everything
t←{2⊃((1⊃¨⍵)⍳⊂'SessionPrint')⊃⍵}oldEvent ⍝ get the fn that would have been executed in the old state
⍎'a ',t,' e' ⍝ and execute it
→0
:EndIf
#.⎕TRAP←0 'E'('.Err ⎕DMX',⍨⍕⎕THIS)
title←general
t←⎕UCS 9
Scale←{
⍵<1024:''
f←4⌊⌊1024⍟⍵
p←'k' 'M' 'G' 'T'⊃⍨f
1⌽')'t'(',(⍕⌊0.5+⍵÷1024*f),' ',p,'iB'
}
title,←'Size'T(⍕,' bytes',Scale)⎕SIZE'a'
:Select ⊃⎕NC'a'
:CaseList 1 2 ⍝ label/var/⎕OR
:If ⍬≡⍴a
:AndIf 1=≡a ⍝ ⎕OR
(nc content)←a{fo←⍺⍺ ⋄ (⎕NC∘⊂,⊂∘⎕VR)'fo'}0
title,←'Class'T⍕nc
title,←t'(','traditional' 'direct' 'tacit' '' '' 'external'⊃⍨10×1|nc
title,←')',⍨(3.3≠nc)/' ','function' 'operator'⊃⍨1+4=⌊nc
:If 0.3=1|nc ⍝ tacit
content←a dft 0
:EndIf
:Else
title,←'Depth'T(⍕≡a),t'(',')',⍨'ragged' 'simple' 'simple' 'nested'⊃⍨2+¯1⌈2⌊≡a
title,←'Shape'T(⍕⍴a),'⍬'/⍨⍬≡⍴a
title,←1⌽')'t'(','scalar' 'vector' 'matrix'('D array',⍨⍕≢⍴a)⊃⍨4⌊1+≢⍴a
title,←'Type'T⍕dr←⎕DR a
title,←'-bit ',⍨t'(',⍕(⌊dr÷10)×1+(dr=326)∧∨/'64'⍷⊃# ⎕WG'APLVersion'
title,←')',⍨'character' 'Boolean' 'character' 'integer' '' 'float' 'pointer' 'decimal' '' 'complex'⊃⍨1+10|dr
title,←'Def'T{0::⍕⍵ ⋄ ⎕SE.Dyalog.Utils.repObj ⍵}a
content←disp a
:EndIf
:Case 9 ⍝ obj
title,←'Vars'T 1↓∊' ',¨a.⎕NL ¯2
title,←'Fns'T 1↓∊' ',¨a.⎕NL ¯3
title,←'Ops'T 1↓∊' ',¨a.⎕NL ¯4
title,←'Objs'T 1↓∊' ',¨a.⎕NL ¯9
content←⍕a
:EndSelect
'output'Append title content