git @ Cat's Eye Technologies Jolverine / 82d0db9
Superficially Skulptify, but would prolly be nicer to reimpl in JS. catseye 11 years ago
1 changed file(s) with 20 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
66 import sys
77
88
9 # check if running under Skulpt, and if so, apply appropriate modifications
10 if getattr(sys, 'resetTimeout', None) is not None:
11 __name__ = '__skulpt__'
12
13
914 class Program(object):
10 def __init__(self, program, debug=False, super_wimp_mode=False):
15 def __init__(self, debug=False, super_wimp_mode=False):
1116 self.wheel = [
1217 'left',
1318 'right',
2429 self.insertpos = 'bottom'
2530 self._debug = debug
2631 self._super_wimp_mode = super_wimp_mode
32 self.maxx = 0
33 self.maxy = 0
34 self.x = 0
35 self.y = 0
36 self.dx = 1
37 self.dy = 0
38
39 def load_string(self, text):
2740 y = 0
28 self.maxx = 0
29 for line in file:
41 for line in text.split('\n'):
3042 line = line.rstrip('\r\n')
3143 x = 0
3244 while x < len(line):
3648 self.maxx = x
3749 y += 1
3850 self.maxy = y
39 self.x = 0
40 self.y = 0
41 self.dx = 1
42 self.dy = 0
51
52 def load_file(self, filename):
53 self.load_string(open(filename, 'r').read())
4354
4455 ### helpers ###
4556
188199 if sys.argv[1] == '--super-wimp-mode':
189200 super_wimp_mode = True
190201 sys.argv.pop(1)
191 with open(sys.argv[1]) as file:
192 p = Program(file, debug=debug, super_wimp_mode=super_wimp_mode)
202 p = Program(debug=debug, super_wimp_mode=super_wimp_mode)
203 p.load_file(sys.argv[1])
193204 p.dump()
194205 p.run()