diff --git a/assets/text/TODO b/assets/text/TODO index 88d7067..07f1dbc 100644 --- a/assets/text/TODO +++ b/assets/text/TODO @@ -22,8 +22,8 @@ High-priority list: 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) text tool: a) honour RTL text flow b) pasting text -4) select-related {re,un}do bugs +3) select-related {re,un}do bugs +4) text tool: pasting text 5) clone selection lag vim:ff=dos tw=0 diff --git a/libtools/ToolText.py b/libtools/ToolText.py index 9beacbf..184f910 100644 --- a/libtools/ToolText.py +++ b/libtools/ToolText.py @@ -5,10 +5,11 @@ # from Tool import Tool -import string, wx +import re, string, wx 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) @@ -32,12 +33,20 @@ class ToolText(Tool): and ((ord(keyChar) >= 32) if ord(keyChar) < 127 else True) \ and (keyModifiers in (wx.MOD_NONE, wx.MOD_SHIFT)): dispatchFn(eventDc, False, [*brushPos, *brushColours, 0, keyChar], viewRect); - if brushPos[0] < (canvas.size[0] - 1): - brushPos[0] += 1 - elif brushPos[1] < (canvas.size[1] - 1): - brushPos[0], brushPos[1] = 0, brushPos[1] + 1 + if not re.match(self.rtlRegEx, keyChar): + if brushPos[0] < (canvas.size[0] - 1): + brushPos[0] += 1 + elif brushPos[1] < (canvas.size[1] - 1): + brushPos[0], brushPos[1] = 0, brushPos[1] + 1 + else: + brushPos[0], brushPos[1] = 0, 0 else: - brushPos[0], brushPos[1] = 0, 0 + 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 dispatchFn(eventDc, True, [*brushPos, *brushColours, 0, "_"], viewRect) rc, dirty = True, True else: