2016-07-20 08:53:00 -04:00
|
|
|
#!/bin/python
|
|
|
|
|
|
|
|
def getCurrentWord(x,y, currText):
|
2016-07-20 09:25:28 -04:00
|
|
|
if currText == '':
|
|
|
|
return -1, -1, ''
|
2016-07-20 08:53:00 -04:00
|
|
|
wordFound = False
|
|
|
|
currWord = ''
|
|
|
|
currLine = wrappedLines[y].replace("\t"," ")
|
|
|
|
while not wordFound:
|
|
|
|
x = currLine[:x].rfind(" ")
|
|
|
|
if x == -1:
|
|
|
|
x = 0
|
|
|
|
else:
|
|
|
|
x += 1
|
|
|
|
wordEnd = currLine[x + 1:].find(" ")
|
|
|
|
if wordEnd == -1:
|
|
|
|
wordEnd = len(currLine)
|
|
|
|
else:
|
|
|
|
wordEnd += x + 1
|
|
|
|
currWord = currLine[x:wordEnd]
|
|
|
|
wordFound = currWord.strip(" \t\n") != ''
|
|
|
|
if wordFound:
|
|
|
|
break
|
|
|
|
if x == 0:
|
|
|
|
if y != 0:
|
|
|
|
y -= 1
|
|
|
|
currLine = wrappedLines[y].replace("\t"," ")
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
x = len(wrappedLines[y]) - 1
|
|
|
|
else:
|
|
|
|
x -= 1
|
|
|
|
return x, y, currWord
|