mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 15:26:37 +00:00
Allow pasting text when using text tool.
libtools/ToolText.py:{_processKeyChar,onKeyboardEvent}(): split from onKeyboardEvent(). libtools/ToolText.py:onKeyboardEvent(): obtain & iteratively _processKeyChar() clipboard text on <Control> V. libtools/ToolText.py:onKeyboardEvent(): dispatch cursor patch once after {drawing,pasting}. assets/text/TODO: updated.
This commit is contained in:
parent
e6bdc52af2
commit
2834fe531b
@ -15,15 +15,15 @@ High-priority list:
|
||||
3) cleanup & refactor, switch to GTK
|
||||
4) GUI:
|
||||
a) replace logo w/ canvas panel in About dialogue
|
||||
b) Settings/Settings window (e.g. autosave, hide cursor on leaving window, ...)
|
||||
c) replace resize buttons w/ {-,edit box,+} buttons & lock button re: ratio (ty lol3)
|
||||
d) {copy,cut,delete,insert from,paste}, {edit asset in new canvas,import from {canvas,object}}
|
||||
b) purge MRU list menu item, remove files from MRU list if inaccessible
|
||||
c) Settings/Settings window (e.g. autosave, hide cursor on leaving window, ...)
|
||||
d) replace resize buttons w/ {-,edit box,+} buttons & lock button re: ratio (ty lol3)
|
||||
e) {copy,cut,delete,insert from,paste}, {edit asset in new canvas,import from {canvas,object}}
|
||||
|
||||
Queue:
|
||||
1) scrolling bug: start @ top, down key til cursor below visible canvas, scroll down, cursor gone GRRRR
|
||||
2) scrolling bug: scroll down, apply operator to entire canvas, scroll up
|
||||
3) select-related {re,un}do bugs
|
||||
4) text tool: pasting text
|
||||
5) clone selection lag
|
||||
4) clone selection lag
|
||||
|
||||
vim:ff=dos tw=0
|
||||
|
@ -11,24 +11,9 @@ class ToolText(Tool):
|
||||
name = "Text"
|
||||
rtlRegEx = r'^[\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]+$'
|
||||
|
||||
#
|
||||
# onKeyboardEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyChar, keyCode, keyModifiers, mapPoint, viewRect)
|
||||
def onKeyboardEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyChar, keyCode, keyModifiers, mapPoint, viewRect):
|
||||
if keyCode == wx.WXK_BACK:
|
||||
if brushPos[0] > 0:
|
||||
brushPos[0] -= 1
|
||||
elif brushPos[1] > 0:
|
||||
brushPos[0], brushPos[1] = canvas.size[0] - 1, brushPos[1] - 1
|
||||
else:
|
||||
brushPos[0], brushPos[1] = canvas.size[0] - 1, canvas.size[1] - 1
|
||||
rc, dirty = True, False; dispatchFn(eventDc, True, [*brushPos, *brushColours, 0, "_"], viewRect);
|
||||
elif keyCode == wx.WXK_RETURN:
|
||||
if brushPos[1] < (canvas.size[1] - 1):
|
||||
brushPos[0], brushPos[1] = 0, brushPos[1] + 1
|
||||
else:
|
||||
brushPos[0], brushPos[1] = 0, 0
|
||||
rc, dirty = True, False; dispatchFn(eventDc, True, [*brushPos, *brushColours, 0, "_"], viewRect);
|
||||
elif (ord(keyChar) != wx.WXK_NONE) \
|
||||
# {{{ _processKeyChar(self, brushColours, brushPos, canvas, dispatchFn, eventDc, keyChar, keyModifiers, viewRect)
|
||||
def _processKeyChar(self, brushColours, brushPos, canvas, dispatchFn, eventDc, keyChar, keyModifiers, viewRect):
|
||||
if (ord(keyChar) != wx.WXK_NONE) \
|
||||
and (not keyChar in set("\t\n\v\f\r")) \
|
||||
and ((ord(keyChar) >= 32) if ord(keyChar) < 127 else True) \
|
||||
and (keyModifiers in (wx.MOD_NONE, wx.MOD_SHIFT)):
|
||||
@ -47,11 +32,48 @@ class ToolText(Tool):
|
||||
brushPos[0], brushPos[1] = canvas.size[0] - 1, brushPos[1] - 1
|
||||
else:
|
||||
brushPos[0], brushPos[1] = canvas.size[0] - 1, canvas.size[1] - 1
|
||||
dispatchFn(eventDc, True, [*brushPos, *brushColours, 0, "_"], viewRect)
|
||||
rc, dirty = True, True
|
||||
else:
|
||||
rc, dirty = False, False
|
||||
return rc, dirty
|
||||
# }}}
|
||||
|
||||
#
|
||||
# onKeyboardEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyChar, keyCode, keyModifiers, mapPoint, viewRect)
|
||||
def onKeyboardEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyChar, keyCode, keyModifiers, mapPoint, viewRect):
|
||||
if keyCode == wx.WXK_CONTROL_V:
|
||||
rc, dirty = True, False
|
||||
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)) \
|
||||
and wx.TheClipboard.Open():
|
||||
inBuffer = wx.TextDataObject()
|
||||
if wx.TheClipboard.GetData(inBuffer):
|
||||
for inBufferChar in list(inBuffer.GetText()):
|
||||
rc_, dirty_ = self._processKeyChar(brushColours, brushPos, canvas, dispatchFn, eventDc, inBufferChar, 0, viewRect)
|
||||
rc = True if rc_ else rc; dirty = True if dirty_ else dirty;
|
||||
if rc:
|
||||
dispatchFn(eventDc, True, [*brushPos, *brushColours, 0, "_"], viewRect)
|
||||
wx.TheClipboard.Close()
|
||||
else:
|
||||
rc, error = False, "Clipboard does not contain text data and/or cannot be opened"
|
||||
elif keyCode == wx.WXK_BACK:
|
||||
if brushPos[0] > 0:
|
||||
brushPos[0] -= 1
|
||||
elif brushPos[1] > 0:
|
||||
brushPos[0], brushPos[1] = canvas.size[0] - 1, brushPos[1] - 1
|
||||
else:
|
||||
brushPos[0], brushPos[1] = canvas.size[0] - 1, canvas.size[1] - 1
|
||||
rc, dirty = True, False; dispatchFn(eventDc, True, [*brushPos, *brushColours, 0, "_"], viewRect);
|
||||
elif keyCode == wx.WXK_RETURN:
|
||||
if brushPos[1] < (canvas.size[1] - 1):
|
||||
brushPos[0], brushPos[1] = 0, brushPos[1] + 1
|
||||
else:
|
||||
brushPos[0], brushPos[1] = 0, 0
|
||||
rc, dirty = True, False; dispatchFn(eventDc, True, [*brushPos, *brushColours, 0, "_"], viewRect);
|
||||
else:
|
||||
rc, dirty = self._processKeyChar(brushColours, brushPos, canvas, dispatchFn, eventDc, keyChar, keyModifiers, viewRect)
|
||||
if rc:
|
||||
dispatchFn(eventDc, True, [*brushPos, *brushColours, 0, "_"], viewRect)
|
||||
return rc, dirty
|
||||
|
||||
#
|
||||
# onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
|
||||
|
Loading…
Reference in New Issue
Block a user