Browse Source

FIX, TextEdit doubleclick selection on multiline wrap with tabs in between

pull/34/head
Eugenio Parodi 4 years ago
parent
commit
9724ab3a8d
  1. 6
      TermTk/TTkWidgets/texedit.py
  2. 2
      demo/showcase/textedit.py

6
TermTk/TTkWidgets/texedit.py

@ -241,7 +241,7 @@ class _TTkTextEditView(TTkAbstractScrollView):
I assume the x,y position already normalized using the _cursorAlign function
'''
dt, (fr, to) = self._lines[y]
return self._dataLines[dt], self._dataLines[dt].tabCharPos(x+fr,self._tabSpaces)
return self._dataLines[dt], fr+self._dataLines[dt].substring(fr,to).tabCharPos(x,self._tabSpaces)
def _cursorFromLinePos(self,liney,p):
'''
@ -258,8 +258,8 @@ class _TTkTextEditView(TTkAbstractScrollView):
if dt1 != dt:
break
if fr<=p<to:
s = self._dataLines[dt].substring(0,p).tab2spaces(self._tabSpaces)
return len(s)-fr, liney
s = self._dataLines[dt].substring(fr,p).tab2spaces(self._tabSpaces)
return len(s), liney
liney += 1
liney-=1
dt, (fr, to) = self._lines[liney]

2
demo/showcase/textedit.py

@ -57,7 +57,7 @@ def demoTextEdit(root=None):
# Test Tabs
te.append(ttk.TTkString("Tabs Test\n",ttk.TTkColor.UNDERLINE+ttk.TTkColor.BOLD))
te.append("Word\tAnother Word\tYet more words")
te.append("What a wonderful word\tOut of this word\tBattle of the words\n")
te.append("What a wonderful word\tOut of this word\tBattle of the words\tThe city of thousand words\tThe word is not enough\tJurassic word\n")
te.append("tab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab")
te.append("-tab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab")
te.append("--tab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab\ttab")

Loading…
Cancel
Save