Most of the pep8 changes finished. Be careful, things may be horribly broken.

This commit is contained in:
Storm Dragon
2025-07-03 13:22:00 -04:00
parent 7408951152
commit 21bb9c6083
344 changed files with 6374 additions and 6083 deletions

View File

@ -8,118 +8,118 @@ from fenrirscreenreader.core import debug
import string
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
x = currX
y = currY
currWord = ''
wrappedLines = currText.split('\n')
currLine = wrappedLines[y]
Found = False
while (not Found):
if not currLine[x] in string.whitespace:
def get_current_word(curr_x, curr_y, curr_text):
line_break = False
end_of_screen = False
if curr_text == '':
return -1, -1, '', end_of_screen, line_break
if curr_text.strip(string.whitespace) == '':
return curr_x, curr_y, '', end_of_screen, line_break
x = curr_x
y = curr_y
curr_word = ''
wrapped_lines = curr_text.split('\n')
curr_line = wrapped_lines[y]
found = False
while (not found):
if not curr_line[x] in string.whitespace:
if x == 0:
Found = True
found = True
else:
if currLine[x - 1] in string.whitespace:
Found = True
if not Found:
if curr_line[x - 1] in string.whitespace:
found = True
if not found:
if x - 1 < 0:
if y - 1 < 0:
lineBreak = False
endOfScreen = True
return currX, currY, '', endOfScreen, lineBreak
line_break = False
end_of_screen = True
return curr_x, curr_y, '', end_of_screen, line_break
else:
y -= 1
currLine = wrappedLines[y]
x = len(currLine) - 1
lineBreak = True
curr_line = wrapped_lines[y]
x = len(curr_line) - 1
line_break = True
else:
x -= 1
if Found:
currWord = currLine[x:]
if found:
curr_word = curr_line[x:]
for d in string.whitespace:
delimiterPos = currWord.find(d)
if delimiterPos != -1:
currWord = currWord[:delimiterPos]
return x, y, currWord, endOfScreen, lineBreak
return currX, currY, '', False, False
delimiter_pos = curr_word.find(d)
if delimiter_pos != -1:
curr_word = curr_word[:delimiter_pos]
return x, y, curr_word, end_of_screen, line_break
return curr_x, curr_y, '', 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]
def get_prev_word(curr_x, curr_y, curr_text):
line_break = False
end_of_screen = False
if curr_text == '':
return -1, -1, '', end_of_screen, line_break
if curr_text.strip(string.whitespace) == '':
return curr_x, curr_y, '', end_of_screen, line_break
x, y, curr_word, end_of_screen, line_break_curr_word = get_current_word(
curr_x, curr_y, curr_text)
if end_of_screen:
return x, y, curr_word, end_of_screen, line_break
wrapped_lines = curr_text.split('\n')
curr_line = wrapped_lines[y]
if x - 1 < 0:
if y - 1 < 0:
lineBreak = False
endOfScreen = True
return currX, currY, '', endOfScreen, lineBreak
line_break = False
end_of_screen = True
return curr_x, curr_y, '', end_of_screen, line_break
else:
y -= 1
currLine = wrappedLines[y]
x = len(currLine) - 1
lineBreak = True
curr_line = wrapped_lines[y]
x = len(curr_line) - 1
line_break = 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
line_break_curr_word = line_break or line_break_curr_word
x, y, curr_word, end_of_screen, line_break = get_current_word(x, y, curr_text)
line_break = line_break or line_break_curr_word
return x, y, curr_word, end_of_screen, line_break
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
x = currX
y = currY
currWord = ''
wrappedLines = currText.split('\n')
currLine = wrappedLines[y]
Found = False
while (not Found):
if not Found:
if x + 1 > len(currLine) - 1:
if y + 1 > len(wrappedLines) - 1:
lineBreak = False
endOfScreen = True
return currX, currY, '', endOfScreen, lineBreak
def get_next_word(curr_x, curr_y, curr_text):
line_break = False
end_of_screen = False
if curr_text == '':
return -1, -1, '', end_of_screen, line_break
if curr_text.strip(string.whitespace) == '':
return curr_x, curr_y, '', end_of_screen, line_break
x = curr_x
y = curr_y
curr_word = ''
wrapped_lines = curr_text.split('\n')
curr_line = wrapped_lines[y]
found = False
while (not found):
if not found:
if x + 1 > len(curr_line) - 1:
if y + 1 > len(wrapped_lines) - 1:
line_break = False
end_of_screen = True
return curr_x, curr_y, '', end_of_screen, line_break
else:
y += 1
currLine = wrappedLines[y]
curr_line = wrapped_lines[y]
x = 0
lineBreak = True
line_break = True
else:
x += 1
if not currLine[x] in string.whitespace:
if not curr_line[x] in string.whitespace:
if x == 0:
Found = True
found = True
else:
if currLine[x - 1] in string.whitespace:
Found = True
if Found:
currWord = currLine[x:]
if curr_line[x - 1] in string.whitespace:
found = True
if found:
curr_word = curr_line[x:]
for d in string.whitespace:
delimiterPos = currWord.find(d)
if delimiterPos != -1:
currWord = currWord[:delimiterPos]
return x, y, currWord, endOfScreen, lineBreak
return currX, currY, '', False, False
delimiter_pos = curr_word.find(d)
if delimiter_pos != -1:
curr_word = curr_word[:delimiter_pos]
return x, y, curr_word, end_of_screen, line_break
return curr_x, curr_y, '', False, False