Update word_utils.py
This commit is contained in:
parent
032c7d5452
commit
d5f70ecba1
@ -7,35 +7,6 @@
|
|||||||
from core import debug
|
from core import debug
|
||||||
import string
|
import string
|
||||||
|
|
||||||
def getPrevWord(currX,currY, currText):
|
|
||||||
lineBreak = False
|
|
||||||
endOfScreen = False
|
|
||||||
if currText == '':
|
|
||||||
return -1, -1, '', endOfScreen, lineBreak
|
|
||||||
if currText.strip( string.whitespace) == '':
|
|
||||||
return currX, currY, '', endOfScreen, lineBreak
|
|
||||||
x, y, currWord, endOfScreen, lineBreakCurrWord = getCurrentWord(currX,currY,currText)
|
|
||||||
if endOfScreen:
|
|
||||||
return x, y, currWord, endOfScreen, lineBreak
|
|
||||||
wrappedLines = currText.split('\n')
|
|
||||||
currLine = wrappedLines[y]
|
|
||||||
if x - 1 < 0:
|
|
||||||
if y - 1 < 0:
|
|
||||||
lineBreak = False
|
|
||||||
endOfScreen = True
|
|
||||||
return currX, currY, '', endOfScreen, lineBreak
|
|
||||||
else:
|
|
||||||
y -= 1
|
|
||||||
currLine = wrappedLines[y]
|
|
||||||
x = len( wrappedLines[y]) - 1
|
|
||||||
lineBreak = True
|
|
||||||
else:
|
|
||||||
x -= 1
|
|
||||||
lineBreakCurrWord = lineBreak or lineBreakCurrWord
|
|
||||||
x, y, currWord, endOfScreen, lineBreak = getCurrentWord(x,y,currText)
|
|
||||||
lineBreak = lineBreak or lineBreakCurrWord
|
|
||||||
return x, y, currWord, endOfScreen, lineBreak
|
|
||||||
|
|
||||||
def getCurrentWord(currX,currY, currText):
|
def getCurrentWord(currX,currY, currText):
|
||||||
lineBreak = False
|
lineBreak = False
|
||||||
endOfScreen = False
|
endOfScreen = False
|
||||||
@ -75,10 +46,38 @@ def getCurrentWord(currX,currY, currText):
|
|||||||
delimiterPos = currWord.find(d)
|
delimiterPos = currWord.find(d)
|
||||||
if delimiterPos != -1:
|
if delimiterPos != -1:
|
||||||
currWord = currWord[:delimiterPos]
|
currWord = currWord[:delimiterPos]
|
||||||
|
|
||||||
return x, y, currWord, endOfScreen, lineBreak
|
return x, y, currWord, endOfScreen, lineBreak
|
||||||
return currX, currY, '', False, False
|
return currX, currY, '', False, False
|
||||||
|
|
||||||
|
def getPrevWord(currX,currY, currText):
|
||||||
|
lineBreak = False
|
||||||
|
endOfScreen = False
|
||||||
|
if currText == '':
|
||||||
|
return -1, -1, '', endOfScreen, lineBreak
|
||||||
|
if currText.strip( string.whitespace) == '':
|
||||||
|
return currX, currY, '', endOfScreen, lineBreak
|
||||||
|
x, y, currWord, endOfScreen, lineBreakCurrWord = getCurrentWord(currX,currY,currText)
|
||||||
|
if endOfScreen:
|
||||||
|
return x, y, currWord, endOfScreen, lineBreak
|
||||||
|
wrappedLines = currText.split('\n')
|
||||||
|
currLine = wrappedLines[y]
|
||||||
|
if x - 1 < 0:
|
||||||
|
if y - 1 < 0:
|
||||||
|
lineBreak = False
|
||||||
|
endOfScreen = True
|
||||||
|
return currX, currY, '', endOfScreen, lineBreak
|
||||||
|
else:
|
||||||
|
y -= 1
|
||||||
|
currLine = wrappedLines[y]
|
||||||
|
x = len( wrappedLines[y]) - 1
|
||||||
|
lineBreak = True
|
||||||
|
else:
|
||||||
|
x -= 1
|
||||||
|
lineBreakCurrWord = lineBreak or lineBreakCurrWord
|
||||||
|
x, y, currWord, endOfScreen, lineBreak = getCurrentWord(x,y,currText)
|
||||||
|
lineBreak = lineBreak or lineBreakCurrWord
|
||||||
|
return x, y, currWord, endOfScreen, lineBreak
|
||||||
|
|
||||||
def getNextWord(currX,currY, currText):
|
def getNextWord(currX,currY, currText):
|
||||||
lineBreak = False
|
lineBreak = False
|
||||||
endOfScreen = False
|
endOfScreen = False
|
||||||
|
Loading…
Reference in New Issue
Block a user