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 f2a19e0bf3
commit e6bdc52af2
2 changed files with 17 additions and 8 deletions

View File

@ -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

View File

@ -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 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:
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: