2222
2323__all__ = ['TTkTextCursor' ]
2424
25+ from enum import IntEnum
26+
27+ from typing import List
28+
2529try :
2630 from typing import Self
2731except :
2832 class Self (): pass
2933
3034from TermTk .TTkCore .log import TTkLog
3135from TermTk .TTkCore .color import TTkColor
32- from TermTk .TTkCore .string import TTkString
36+ from TermTk .TTkCore .string import TTkString , TTkStringType
3337from TermTk .TTkGui .textwrap1 import TTkTextWrap
3438from TermTk .TTkGui .textdocument import TTkTextDocument
3539
@@ -79,15 +83,15 @@ def hasSelection(self) -> bool:
7983 return not (self .position .line == self .anchor .line and self .position .pos == self .anchor .pos )
8084
8185class TTkTextCursor ():
82- class MoveMode ():
86+ class MoveMode (IntEnum ):
8387 MoveAnchor = 0x00
8488 '''Moves the anchor to the same position as the cursor itself.'''
8589 KeepAnchor = 0x01
8690 '''Keeps the anchor where it is.'''
8791 MoveAnchor = MoveMode .MoveAnchor
8892 KeepAnchor = MoveMode .KeepAnchor
8993
90- class SelectionType ():
94+ class SelectionType (IntEnum ):
9195 Document = 0x03
9296 '''Selects the entire document.'''
9397 BlockUnderCursor = 0x02
@@ -101,7 +105,7 @@ class SelectionType():
101105 LineUnderCursor = SelectionType .LineUnderCursor
102106 WordUnderCursor = SelectionType .WordUnderCursor
103107
104- class MoveOperation ():
108+ class MoveOperation (IntEnum ):
105109 NoMove = 0
106110 '''Keep the cursor where it is'''
107111 Start = 1
@@ -267,7 +271,7 @@ def setPosition(self, line:int, pos:int, moveMode:MoveMode=MoveMode.MoveAnchor,
267271 self ._properties [cID ].anchor .set (line ,pos )
268272 self ._document .cursorPositionChanged .emit (self )
269273
270- def getLinesUnderCursor (self ) -> TTkString :
274+ def getLinesUnderCursor (self ) -> List [ TTkString ] :
271275 return [ self ._document ._dataLines [p .position .line ] for p in self ._properties ]
272276
273277 def _checkCursors (self , notify :bool = False ) -> None :
@@ -348,7 +352,7 @@ def moveEnd(cID,p,_):
348352 def document (self ) -> TTkTextDocument :
349353 return self ._document
350354
351- def replaceText (self , text :TTkString , moveCursor :bool = False ) -> None :
355+ def replaceText (self , text :TTkStringType , moveCursor :bool = False ) -> None :
352356 # if there is no selection, just select the next n chars till the end of the line
353357 # the newline is not replaced
354358 self ._document ._acquire ()
@@ -365,7 +369,7 @@ def replaceText(self, text:TTkString, moveCursor:bool=False) -> None:
365369 self ._document ._release ()
366370 return self .insertText (text , moveCursor )
367371
368- def insertText (self , text :TTkString , moveCursor :bool = False ) -> None :
372+ def insertText (self , text :TTkStringType , moveCursor :bool = False ) -> None :
369373 self ._document ._acquire ()
370374 _lineFirst = - 1
371375 if self .hasSelection ():
0 commit comments