119 |
if text != None: |
if text != None: |
120 |
self.alphContent.insertText(node, 0, text, 1) |
self.alphContent.insertText(node, 0, text, 1) |
121 |
self.components.append(node) |
self.components.append(node) |
122 |
|
return node |
123 |
|
|
124 |
|
def addNode(self, text): |
125 |
|
node = self.newNode(text) |
126 |
|
self.link(node) |
127 |
|
|
128 |
def editText(self, text): |
def editText(self, text): |
129 |
if text == None: text = '' |
if text == None: text = '' # XXX can alph remove text? |
130 |
self.alphContent.setText(self.focused, text, 1) |
self.alphContent.setText(self.focused, text, 1) |
131 |
|
|
132 |
def neighbours(self, node): |
def neighbours(self, node): |
147 |
if node in self.components: |
if node in self.components: |
148 |
self.components.remove(node) |
self.components.remove(node) |
149 |
self.fen.graph.add(self.focused, STRUCTLINK.linkedTo, node) |
self.fen.graph.add(self.focused, STRUCTLINK.linkedTo, node) |
150 |
|
|
151 |
|
def unlink(self, node): |
152 |
|
self.fen.graph.rm_111(self.focused, STRUCTLINK.linkedTo, node) |
153 |
|
self.fen.graph.rm_111(node, STRUCTLINK.linkedTo, self.focused) |
154 |
|
if not Traversals.isConnected(self.focused, STRUCTLINK.linkedTo, node, self.fen.constgraph): |
155 |
|
self.components.append(node) |
156 |
|
|
157 |
scene = MMScene() |
scene = MMScene() |
158 |
|
|
159 |
|
|
160 |
cmds = {'quit': lambda x:quit(), |
cmds = {'quit': lambda x:quit(), |
161 |
'save': lambda x:save(), |
'save': lambda x:save(), |
162 |
'new': scene.newNode, |
'new': scene.newNode, |
163 |
|
'add': scene.addNode, |
164 |
'write': scene.editText, |
'write': scene.editText, |
165 |
'moveto': lambda str:scene.focus(scene.neighbours(scene.focused)[int(str)-1]), |
'moveto': lambda str:scene.focus(scene.neighbours(scene.focused)[int(str)-1]), |
166 |
'changeto': lambda str:scene.focus(scene.components[-int(str)-1]), |
'changeto': lambda str:scene.focus(scene.components[-int(str)-1]), |
167 |
'linkto': lambda str:scene.link(scene.components[-int(str)-1]), |
'link': lambda str:scene.link(scene.components[-int(str)-1]), |
168 |
|
'unlink': lambda str:scene.unlink(scene.neighbours(scene.focused)[int(str)-1]), |
169 |
} |
} |
170 |
|
|
171 |
while 1: |
while 1: |