-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.rb
More file actions
103 lines (89 loc) · 1.89 KB
/
Copy pathsample.rb
File metadata and controls
103 lines (89 loc) · 1.89 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
module EventEditorMeta
def thing
#place meta.c here
end
end
class EventDisplay
include EventEditorMeta
def parse(eventlist)
@str = ""
eventlist.each{|x|
@enable = {}
@case = {}
@event = x
@posstack = []
@pos = -1
@kstr = ""
thing
}
msgbox_p self
@str
end
def cmd(name, id)
if @pos == -1 && @event.code == id
@kstr = name + ":\n"
@enable[@pos] = true
else
@enable[@pos] = false
end
end
def start()
(@start ||= 0)
@start += 1
@enable[@pos + 1] = @enable[@pos]
@posstack.push @pos
@pos += 1
end
def stop
(@stop ||= 0)
@stop += 1
if @pos == @event.parameters.size && @enable[@pos]
@str << ">" * (4*@event.indent) << @kstr << "\n"
@enable[@pos] = false
end
@pos -= 1 if @pos == @event.parameters.size
@enable[@pos] = false
@case[@pos] = false
@pos = @posstack.pop
end
def moveon
@enable[@pos + 1] = true
@pos += 1
end
def entity(a, b)
return unless @enable[@pos]
@kstr << "#{a} #{b}(#{@event.parameters[@pos]})\n"
moveon
end
def end_item
nil
end
def selectcase(*names, enditem)
return unless @enable[@pos]
@kstr << names[@event.parameters[@pos]] << "\n"
@case[@pos] = true
end
def enumcase(caption, *names, enditem)
return unless @enable[@pos]
case @event.parameters[@pos]
when false then r = 0
when true then r = 1
else r = @event.parameters[@pos]
end
@kstr << "#{caption} #{names[r]}\n"
moveon
end
def casewhen(id)
return unless @case[@pos]
if @event.parameters[@pos] == id
@enable[@pos] = true
else
@enable[@pos] = false
end
end
def data(types = "string")
return unless @enable[@pos]
@kstr << @event.parameters.join("\n")
@event.parameters.size.times{moveon}
end
end