continue word wrapping prototype
This commit is contained in:
parent
38b8cd7979
commit
90d18609ba
@ -4,7 +4,8 @@
|
|||||||
# Fenrir TTY screen reader
|
# Fenrir TTY screen reader
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
|
|
||||||
from core import debug
|
#from core import debug
|
||||||
|
import string
|
||||||
# X Y Word END BREAK
|
# X Y Word END BREAK
|
||||||
# -1, -1, '', True False
|
# -1, -1, '', True False
|
||||||
def getPrevWord(currX,currY, currText):
|
def getPrevWord(currX,currY, currText):
|
||||||
@ -12,45 +13,70 @@ def getPrevWord(currX,currY, currText):
|
|||||||
endOfScreen = False
|
endOfScreen = False
|
||||||
if currText == '':
|
if currText == '':
|
||||||
return -1, -1, '', endOfScreen, lineBreak
|
return -1, -1, '', endOfScreen, lineBreak
|
||||||
|
if currText.strip(string.punctuation +"§ " + string.whitespace) == '':
|
||||||
|
return currX, currY, '', endOfScreen, lineBreak
|
||||||
x, y, currWord, endOfScreen, lineBreak = getCurrentWord(currX,currY,currText)
|
x, y, currWord, endOfScreen, lineBreak = getCurrentWord(currX,currY,currText)
|
||||||
if endOfScreen:
|
if endOfScreen:
|
||||||
return x, y, currWord, endOfScreen, lineBreak
|
return x, y, currWord, endOfScreen, lineBreak
|
||||||
wrappedLines = currText.split('\n')
|
wrappedLines = currText.split('\n')
|
||||||
currLine = wrappedLines[y].replace("\t"," ")
|
currLine = wrappedLines[y]
|
||||||
|
Found = False
|
||||||
|
while(not Found):
|
||||||
|
currWord = 'prev'
|
||||||
return x, y, currWord, endOfScreen, lineBreak
|
return x, y, currWord, endOfScreen, lineBreak
|
||||||
|
return currX, currY, '', False, False
|
||||||
|
|
||||||
def getCurrentWord(currX,currY, currText):
|
def getCurrentWord(currX,currY, currText):
|
||||||
lineBreak = False
|
lineBreak = False
|
||||||
endOfScreen = False
|
endOfScreen = False
|
||||||
if currText == '':
|
if currText == '':
|
||||||
return -1, -1, '', endOfScreen, lineBreak
|
return -1, -1, '', endOfScreen, lineBreak
|
||||||
|
if currText.strip(string.punctuation +"§ " + string.whitespace) == '':
|
||||||
|
return currX, currY, '', endOfScreen, lineBreak
|
||||||
x = currX
|
x = currX
|
||||||
y = currY
|
y = currY
|
||||||
currWord = ''
|
currWord = ''
|
||||||
wrappedLines = currText.split('\n')
|
wrappedLines = currText.split('\n')
|
||||||
currLine = wrappedLines[y].replace("\t"," ")
|
currLine = wrappedLines[y]
|
||||||
|
Found = False
|
||||||
|
while(not Found):
|
||||||
|
currWord = 'curr'
|
||||||
return x, y, currWord, endOfScreen, lineBreak
|
return x, y, currWord, endOfScreen, lineBreak
|
||||||
|
return currX, currY, '', False, False
|
||||||
|
|
||||||
def getNextWord(currX,currY, currText):
|
def getNextWord(currX,currY, currText):
|
||||||
lineBreak = False
|
lineBreak = False
|
||||||
endOfScreen = False
|
endOfScreen = False
|
||||||
if currText == '':
|
if currText == '':
|
||||||
return -1, -1, '', endOfScreen, lineBreak
|
return -1, -1, '', endOfScreen, lineBreak
|
||||||
|
if currText.strip(string.punctuation +"§ " + string.whitespace) == '':
|
||||||
|
return currX, currY, '', endOfScreen, lineBreak
|
||||||
x, y, currWord, endOfScreen, lineBreak = getCurrentWord(currX,currY,currText)
|
x, y, currWord, endOfScreen, lineBreak = getCurrentWord(currX,currY,currText)
|
||||||
if endOfScreen:
|
if endOfScreen:
|
||||||
return x, y, currWord, endOfScreen, lineBreak
|
return x, y, currWord, endOfScreen, lineBreak
|
||||||
wrappedLines = currText.split('\n')
|
wrappedLines = currText.split('\n')
|
||||||
currLine = wrappedLines[y].replace("\t"," ")
|
currLine = wrappedLines[y]
|
||||||
|
Found = False
|
||||||
|
while(not Found):
|
||||||
|
currWord = 'next'
|
||||||
return x, y, currWord, endOfScreen, lineBreak
|
return x, y, currWord, endOfScreen, lineBreak
|
||||||
|
return currX, currY, '', False, False
|
||||||
|
|
||||||
|
|
||||||
data = [
|
|
||||||
'das ist ein test lol\n',
|
data = """das ist ein test lol
|
||||||
' das ist ein test l \n',
|
das ist ein test l
|
||||||
' das ist ein test\n',
|
das ist ein test
|
||||||
' \n',
|
|
||||||
' asdf asdf a\n',
|
asdf asdf a
|
||||||
'test test\n',
|
test test
|
||||||
' te test\n'
|
te test"""
|
||||||
]
|
print('__DATA START__')
|
||||||
|
print(data)
|
||||||
|
print('__DATA END__\n\n')
|
||||||
|
|
||||||
|
x = 0
|
||||||
|
y = 0
|
||||||
|
x, y, currWord, endOfScreen, lineBreak = getCurrentWord(x,y,data)
|
||||||
|
print(x,y,currWord)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user