11 |
from org.fenfire.vocab import * |
from org.fenfire.vocab import * |
12 |
from org.fenfire.vocab.lava import * |
from org.fenfire.vocab.lava import * |
13 |
from org.fenfire.swamp import Nodes |
from org.fenfire.swamp import Nodes |
14 |
|
from org.fenfire.util import PUIClipboard |
15 |
import org.nongnu.alph as alph |
import org.nongnu.alph as alph |
16 |
import org.nongnu.storm as storm |
import org.nongnu.storm as storm |
17 |
|
|
72 |
nodeview.setHasNoContext() |
nodeview.setHasNoContext() |
73 |
mindView = ff.view.lava.mindMapView2D.MindMapView2D(fen, nodeview) |
mindView = ff.view.lava.mindMapView2D.MindMapView2D(fen, nodeview) |
74 |
|
|
|
|
|
75 |
class Context(ff.view.buoy.AbstractMainNode2D.Context): |
class Context(ff.view.buoy.AbstractMainNode2D.Context): |
76 |
def __init__(self): |
def __init__(self): |
77 |
self.rmb_switch = [ 'go', 'link', 'unlink' ] |
self.rmb_switch = [ 'go', 'link', 'unlink' ] |
282 |
vob.AbstractUpdateManager.chg() |
vob.AbstractUpdateManager.chg() |
283 |
|
|
284 |
def key(self, key): |
def key(self, key): |
285 |
if (dbg): p("key: ", key) |
p("key: ", key) |
286 |
if key == 'Escape' or key == 'Tab': |
if key == 'Escape' or key == 'Tab': |
287 |
|
"""Removes the focus from the current accursed node and sets no new accursed node.""" |
288 |
context.setAccursed(None) |
context.setAccursed(None) |
289 |
elif key == 'Backspace': |
elif key == 'Backspace': |
290 |
|
"""Removes a character before the cursor.""" |
291 |
if context.getAccursed() != None \ |
if context.getAccursed() != None \ |
292 |
and context.offset > 0: |
and context.offset > 0: |
293 |
context.deleteText() |
context.deleteText() |
294 |
elif key == 'Delete': |
elif key == 'Delete': |
295 |
|
"""Removes a character next to the cursor.""" |
296 |
if context.getAccursed() != None: |
if context.getAccursed() != None: |
297 |
text = alphContent.getText(fen.graph, context.getAccursed()) |
text = alphContent.getText(fen.graph, context.getAccursed()) |
298 |
if context.offset < len(text): |
if context.offset < len(text): |
299 |
context.offset += 1 |
context.offset += 1 |
300 |
context.deleteText() |
context.deleteText() |
301 |
elif key == "Ctrl-S": |
elif key == "Ctrl-S": |
302 |
|
"""Save the structure.""" |
303 |
p("going to save"); |
p("going to save"); |
304 |
m = ff.swamp.Graphs.toModel(fen.graph); |
m = ff.swamp.Graphs.toModel(fen.graph); |
305 |
m.write(java.io.FileWriter(FILE)); |
m.write(java.io.FileWriter(FILE)); |
306 |
elif key == "Ctrl-Q": |
elif key == "Ctrl-Q": |
307 |
|
"""Save the structure and quit.""" |
308 |
p("going to save"); |
p("going to save"); |
309 |
m = ff.swamp.Graphs.toModel(fen.graph); |
m = ff.swamp.Graphs.toModel(fen.graph); |
310 |
m.write(java.io.FileWriter(FILE)); |
m.write(java.io.FileWriter(FILE)); |
311 |
java.lang.System.exit(43) |
java.lang.System.exit(43) |
312 |
elif key == "Ctrl-R": |
elif key == "Ctrl-R": |
313 |
|
"""Reload scene.""" |
314 |
vob.putil.demo.loadScenes() |
vob.putil.demo.loadScenes() |
315 |
elif key == "Return": |
elif key == "Return": |
316 |
|
"""Add a linebreak.""" |
317 |
context.insertText("\n") |
context.insertText("\n") |
318 |
text = alphContent.getText(fen.graph, context.getAccursed()) |
text = alphContent.getText(fen.graph, context.getAccursed()) |
319 |
# small hack to show the new line on NodeView, without content it would be shrank |
# small hack to show the new line on NodeView, without content it would be shrank |
321 |
context.insertText(" ") |
context.insertText(" ") |
322 |
context.offset -= 1 |
context.offset -= 1 |
323 |
elif key == 'Up': |
elif key == 'Up': |
324 |
|
"""Move the cursor to the previous line.""" |
325 |
xy = jarray.zeros(2, 'f') |
xy = jarray.zeros(2, 'f') |
326 |
nodeview.getXY(fen.graph, context.getAccursed(), |
nodeview.getXY(fen.graph, context.getAccursed(), |
327 |
context.offset, xy) |
context.offset, xy) |
328 |
xy[1] -= textstyle.getHeight(1) |
xy[1] -= textstyle.getHeight(1) |
329 |
context.offset = nodeview.getPos(fen.graph, context.getAccursed(), xy[0], xy[1]) |
context.offset = nodeview.getPos(fen.graph, context.getAccursed(), xy[0], xy[1]) |
330 |
elif key == 'Down': |
elif key == 'Down': |
331 |
|
"""Move the cursor to the next line.""" |
332 |
xy = jarray.zeros(2, 'f') |
xy = jarray.zeros(2, 'f') |
333 |
nodeview.getXY(fen.graph, context.getAccursed(), |
nodeview.getXY(fen.graph, context.getAccursed(), |
334 |
context.offset, xy) |
context.offset, xy) |
335 |
xy[1] += textstyle.getHeight(1) |
xy[1] += textstyle.getHeight(1) |
336 |
context.offset = nodeview.getPos(fen.graph, context.getAccursed(), xy[0], xy[1]) |
context.offset = nodeview.getPos(fen.graph, context.getAccursed(), xy[0], xy[1]) |
337 |
elif key == 'Left': |
elif key == 'Left': |
338 |
|
"""Move the cursor a character to the left.""" |
339 |
if context.offset > 0: context.offset -= 1 |
if context.offset > 0: context.offset -= 1 |
340 |
elif key == 'Right': |
elif key == 'Right': |
341 |
|
"""Move the cursor a character to the right.""" |
342 |
text = alphContent.getText(fen.graph, context.getAccursed()) |
text = alphContent.getText(fen.graph, context.getAccursed()) |
343 |
if context.offset < len(text): |
if context.offset < len(text): |
344 |
context.offset += 1 |
context.offset += 1 |
345 |
if key == "Ctrl-HomE": |
if key == "Ctrl-HomE": |
346 |
|
"""Move the cursor into the beginning of the text.""" |
347 |
context.offset = 0 |
context.offset = 0 |
348 |
if key == "Ctrl-EnD": |
if key == "Ctrl-EnD": |
349 |
|
"""Move the cursor to the end of the text.""" |
350 |
text = alphContent.getText(fen.graph, context.getAccursed()) |
text = alphContent.getText(fen.graph, context.getAccursed()) |
351 |
context.offset = len(text) |
context.offset = len(text) |
352 |
|
if key == "Ctrl-C": |
353 |
|
"""Copy the content of the node into the clipboard.""" |
354 |
|
text = alphContent.getText(fen.graph, context.getAccursed()) |
355 |
|
PUIClipboard.puiCopy(text) |
356 |
|
if key == "Ctrl-V" or key=="Ctrl-Y": |
357 |
|
"""Paste the content the clipboard just after the cursor.""" |
358 |
|
context.insertText(PUIClipboard.getText()) |
359 |
|
print 'PUI', PUIClipboard.getText() |
360 |
if key == "Home" or key == "Ctrl-A": |
if key == "Home" or key == "Ctrl-A": |
361 |
|
"""Move the cursor into the beginning of the line.""" |
362 |
xy = jarray.zeros(2, 'f') |
xy = jarray.zeros(2, 'f') |
363 |
nodeview.getXY(fen.graph, context.getAccursed(), |
nodeview.getXY(fen.graph, context.getAccursed(), |
364 |
context.offset, xy) |
context.offset, xy) |
365 |
xy[0] = 0 |
xy[0] = 0 |
366 |
context.offset = nodeview.getPos(fen.graph, context.getAccursed(), xy[0], xy[1]) |
context.offset = nodeview.getPos(fen.graph, context.getAccursed(), xy[0], xy[1]) |
367 |
if key == "End" or key == "Ctrl-E": |
if key == "End" or key == "Ctrl-E": |
368 |
|
"""Move the cursor to the end of the line.""" |
369 |
# the end of line is reached by going to home of the line below |
# the end of line is reached by going to home of the line below |
370 |
# and returning a single character back if not the end of text was reached |
# and returning a single character back if not the end of text was reached |
371 |
xy = jarray.zeros(2, 'f') |
xy = jarray.zeros(2, 'f') |
377 |
text = alphContent.getText(fen.graph, context.getAccursed()) |
text = alphContent.getText(fen.graph, context.getAccursed()) |
378 |
if context.offset < len(text): context.offset -= 1 |
if context.offset < len(text): context.offset -= 1 |
379 |
elif len(key) == 1: |
elif len(key) == 1: |
380 |
|
"""Enter a character into the cursor position.""" |
381 |
context.insertText(key) |
context.insertText(key) |
382 |
|
|
383 |
if dbg: |
if dbg: |