Honour RTL flow in text tool.

libtools/ToolText.py:rtlRegEx: added.
libtools/ToolText.py:onKeyboardEvent(): move backwards given RTL keyChar.
assets/text/TODO: updated.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-16 10:09:25 +02:00
parent 99369626c4
commit 9752a8e6ce
2 changed files with 17 additions and 8 deletions

View File

@ -22,8 +22,8 @@ High-priority list:
Queue: Queue:
1) scrolling bug: start @ top, down key til cursor below visible canvas, scroll down, cursor gone GRRRR 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 2) scrolling bug: scroll down, apply operator to entire canvas, scroll up
3) text tool: a) honour RTL text flow b) pasting text 3) select-related {re,un}do bugs
4) select-related {re,un}do bugs 4) text tool: pasting text
5) clone selection lag 5) clone selection lag
vim:ff=dos tw=0 vim:ff=dos tw=0

View File

@ -5,10 +5,11 @@
# #
from Tool import Tool from Tool import Tool
import string, wx import re, string, wx
class ToolText(Tool): class ToolText(Tool):
name = "Text" name = "Text"
rtlRegEx = r'^[\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]+$'
# #
# onKeyboardEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, dispatchFn, eventDc, keyChar, keyCode, keyModifiers, mapPoint, viewRect) # 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 ((ord(keyChar) >= 32) if ord(keyChar) < 127 else True) \
and (keyModifiers in (wx.MOD_NONE, wx.MOD_SHIFT)): and (keyModifiers in (wx.MOD_NONE, wx.MOD_SHIFT)):
dispatchFn(eventDc, False, [*brushPos, *brushColours, 0, keyChar], viewRect); dispatchFn(eventDc, False, [*brushPos, *brushColours, 0, keyChar], viewRect);
if brushPos[0] < (canvas.size[0] - 1): if not re.match(self.rtlRegEx, keyChar):
brushPos[0] += 1 if brushPos[0] < (canvas.size[0] - 1):
elif brushPos[1] < (canvas.size[1] - 1): brushPos[0] += 1
brushPos[0], brushPos[1] = 0, brushPos[1] + 1 elif brushPos[1] < (canvas.size[1] - 1):
brushPos[0], brushPos[1] = 0, brushPos[1] + 1
else:
brushPos[0], brushPos[1] = 0, 0
else: 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) dispatchFn(eventDc, True, [*brushPos, *brushColours, 0, "_"], viewRect)
rc, dirty = True, True rc, dirty = True, True
else: else: