#! /usr/bin/python -i
import sys, time, os, readline
sys.path+=['.']
from oe import *
root = cvar.root
os.chdir('build')

class Caller():
	def __init__(self, fn):
		self.fn = fn
	def __repr__(self):
		self.fn()
		return str(self.fn)

startMain()
while not root.controller:
	time.sleep(0.1)
time.sleep(0.5)

document = root.document
controller = root.controller
if True: # activate controller wrappers
	for fn in dir(controller):
		if not fn.startswith('__') and not fn.startswith('test'):
			globals()[fn] = getattr(controller, fn)
	del undoAction
	undo = Caller(controller.undoAction)
	del redoAction
	redo = Caller(controller.redoAction)
if True: # activate document wrappers
	for fn in dir(document):
		if not fn.startswith('__'):
			globals()[fn] = getattr(document, fn)

def testLogo2():
	def do(cmd):
		[fn(cmd) for fn in (print, eval, readline.add_history)]
	do("newSubCurve(14, 3, 0, True)")
	do("newSubCurve(14, 1, 2, False)")
	do("newBirailStitch(-1, -2, False, True, -0.2, -0.2, 0.5)")

