-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile-explorer.grph
More file actions
75 lines (68 loc) · 1.95 KB
/
file-explorer.grph
File metadata and controls
75 lines (68 loc) · 1.95 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#requires GRPH 1.9
#import stdio
#import reflect>requiresPermission
requiresPermission: "file-list"
{file} history = file {''}
integer historyIndex = 0
integer historyLast = 0
Polygon parent = Polygon("Parent Directory" color[128 128 128] 8,0 16,4 10,4 10,16 6,16 6,4 0,4)
Polygon previous = cloneShape[parent] as Polygon
translate previous: 20,0
setRotationCenter previous: 28,8
rotate previous: 270°
setName previous: "Previous"
Polygon next = cloneShape[parent] as Polygon
translate next: 40,0
setRotationCenter next: 48,8
rotate next: 90°
setName next: "Next"
Text at = Text(toString[history{historyIndex}] 60,20 font[20] BLACK)
validateAll:
{shape} groups = shape {}
#while true
boolean changed = getArrayLength[groups] == 0
#if getSelectedShape[] == parent
file? new = getParentFile[history{historyIndex}]
#if new != null
historyIndex += 1
history{historyIndex+} = new
historyLast = historyIndex
changed = true
#elseif getSelectedShape[] == previous
#if historyIndex > 0
historyIndex -= 1
changed = true
#else
resetSelectedShape:
#elseif getSelectedShape[] == next
#if historyIndex < historyLast
historyIndex += 1
changed = true
#else
resetSelectedShape:
#elseif getSelectedShape[] is Text && getSelectedShape[] != at
file f = concat[history{historyIndex} "/" getName[getSelectedShape[]]] as file
#if isDirectory[f]
historyIndex += 1
history{historyIndex+} = getAbsoluteFile[f]
historyLast = historyIndex
changed = true
#if changed
setName at: toString[history{historyIndex}]
resetSelectedShape:
#while getArrayLength[groups] > 0
unvalidate: groups{0}
groups{0-} =
integer y = 50
#foreach f : listFiles[history{historyIndex}]
Text group = Text(getFileName[f] createPos[10 y] font[15] BLACK)
groups{+} = group
validate: group
y += 20
#else
Text group = Text("Empty directory" createPos[50 y] font[20] BLACK)
setHCentered: group
groups{+} = group
validate: group
wait: 100
//