To make Fenrir easier to approach for new developer, start code migration to be pep8 compliant.

This commit is contained in:
Storm Dragon
2025-07-01 22:23:50 -04:00
parent 4bcf82178e
commit 7408951152
345 changed files with 8688 additions and 3852 deletions

View File

@ -7,20 +7,21 @@
from fenrirscreenreader.core import debug
import string
def getCurrentWord(currX,currY, currText):
lineBreak = False
def getCurrentWord(currX, currY, currText):
lineBreak = False
endOfScreen = False
if currText == '':
return -1, -1, '', endOfScreen, lineBreak
if currText.strip( string.whitespace) == '':
return currX, currY, '', endOfScreen, lineBreak
if currText.strip(string.whitespace) == '':
return currX, currY, '', endOfScreen, lineBreak
x = currX
y = currY
currWord = ''
currWord = ''
wrappedLines = currText.split('\n')
currLine = wrappedLines[y]
Found = False
while(not Found):
while (not Found):
if not currLine[x] in string.whitespace:
if x == 0:
Found = True
@ -36,7 +37,7 @@ def getCurrentWord(currX,currY, currText):
else:
y -= 1
currLine = wrappedLines[y]
x = len( currLine) - 1
x = len(currLine) - 1
lineBreak = True
else:
x -= 1
@ -45,18 +46,20 @@ def getCurrentWord(currX,currY, currText):
for d in string.whitespace:
delimiterPos = currWord.find(d)
if delimiterPos != -1:
currWord = currWord[:delimiterPos]
currWord = currWord[:delimiterPos]
return x, y, currWord, endOfScreen, lineBreak
return currX, currY, '', False, False
def getPrevWord(currX,currY, currText):
lineBreak = 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 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')
@ -69,32 +72,33 @@ def getPrevWord(currX,currY, currText):
else:
y -= 1
currLine = wrappedLines[y]
x = len( currLine) - 1
x = len(currLine) - 1
lineBreak = True
else:
x -= 1
lineBreakCurrWord = lineBreak or lineBreakCurrWord
x, y, currWord, endOfScreen, lineBreak = getCurrentWord(x,y,currText)
x, y, currWord, endOfScreen, lineBreak = getCurrentWord(x, y, currText)
lineBreak = lineBreak or lineBreakCurrWord
return x, y, currWord, endOfScreen, lineBreak
def getNextWord(currX,currY, currText):
lineBreak = False
def getNextWord(currX, currY, currText):
lineBreak = False
endOfScreen = False
if currText == '':
return -1, -1, '', endOfScreen, lineBreak
if currText.strip( string.whitespace) == '':
return currX, currY, '', endOfScreen, lineBreak
if currText.strip(string.whitespace) == '':
return currX, currY, '', endOfScreen, lineBreak
x = currX
y = currY
currWord = ''
currWord = ''
wrappedLines = currText.split('\n')
currLine = wrappedLines[y]
Found = False
while(not Found):
while (not Found):
if not Found:
if x + 1 > len( currLine ) - 1:
if y + 1 > len( wrappedLines ) - 1:
if x + 1 > len(currLine) - 1:
if y + 1 > len(wrappedLines) - 1:
lineBreak = False
endOfScreen = True
return currX, currY, '', endOfScreen, lineBreak
@ -110,7 +114,7 @@ def getNextWord(currX,currY, currText):
Found = True
else:
if currLine[x - 1] in string.whitespace:
Found = True
Found = True
if Found:
currWord = currLine[x:]
for d in string.whitespace:
@ -119,4 +123,3 @@ def getNextWord(currX,currY, currText):
currWord = currWord[:delimiterPos]
return x, y, currWord, endOfScreen, lineBreak
return currX, currY, '', False, False