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

@ -6,11 +6,14 @@
from fenrirscreenreader.core import debug
class cursorManager():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shouldProcessNumpadCommands(self):
"""
Check if numpad commands should be processed based on numlock state
@ -19,19 +22,25 @@ class cursorManager():
"""
# Return False if numlock is ON
return not self.env['input']['newNumLock']
def shutdown(self):
pass
def clearMarks(self):
self.env['commandBuffer']['Marks']['1'] = None
self.env['commandBuffer']['Marks']['2'] = None
def isMarkSet(self):
return self.env['commandBuffer']['Marks']['1'] != None
return self.env['commandBuffer']['Marks']['1'] is not None
def isSingleMark(self):
return self.env['commandBuffer']['Marks']['1'] != None and \
self.env['commandBuffer']['Marks']['2'] == None
return self.env['commandBuffer']['Marks']['1'] is not None and \
self.env['commandBuffer']['Marks']['2'] is None
def isMultibleMark(self):
return self.env['commandBuffer']['Marks']['1'] != None and \
self.env['commandBuffer']['Marks']['2'] != None
return self.env['commandBuffer']['Marks']['1'] is not None and \
self.env['commandBuffer']['Marks']['2'] is not None
def setMark(self):
currCursor = None
if self.env['screen']['newCursorReview']:
@ -45,11 +54,13 @@ class cursorManager():
self.env['commandBuffer']['Marks']['2'] = currCursor.copy()
return 2
return 0
def getReviewOrTextCursor(self):
if self.env['screen']['newCursorReview']:
return self.env['screen']['newCursorReview'].copy()
else:
return self.env['screen']['newCursor'].copy()
def clearReviewCursor(self):
if not self.isReviewMode():
return
@ -63,7 +74,7 @@ class cursorManager():
return self.env['screen']['newCursor']['y'] != self.env['screen']['oldCursor']['y']
def isReviewMode(self):
return self.env['screen']['newCursorReview'] != None
return self.env['screen']['newCursorReview'] is not None
def enterReviewModeCurrTextCursor(self, overwrite=False):
if self.isReviewMode() and not overwrite:
@ -71,9 +82,11 @@ class cursorManager():
self.env['screen']['oldCursorReview'] = self.env['screen']['newCursorReview']
if not self.env['screen']['newCursorReview']:
self.env['screen']['newCursorReview'] = self.env['screen']['newCursor'].copy()
if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight') and \
self.env['runtime']['attributeManager'].isAttributeCursorActive():
self.env['screen']['newCursorReview'] = self.env['runtime']['attributeManager'].getCurrAttributeCursor().copy()
if self.env['runtime']['settingsManager'].getSettingAsBool(
'focus',
'highlight') and self.env['runtime']['attributeManager'].isAttributeCursorActive():
self.env['screen']['newCursorReview'] = self.env['runtime']['attributeManager'].getCurrAttributeCursor(
).copy()
def setReviewCursorPosition(self, x, y):
if not self.isReviewMode():
@ -84,18 +97,22 @@ class cursorManager():
def isApplicationWindowSet(self):
try:
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
if self.env['commandBuffer']['windowArea'][currApp]['1'] != None:
currApp = self.env['runtime']['applicationManager'].getCurrentApplication(
)
if self.env['commandBuffer']['windowArea'][currApp]['1'] is not None:
return True
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('cursorManager isApplicationWindowSet: Error checking window area: ' + str(e), debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(
'cursorManager isApplicationWindowSet: Error checking window area: ' + str(e),
debug.debugLevel.ERROR)
return False
def setWindowForApplication(self, start = None, end = None):
def setWindowForApplication(self, start=None, end=None):
x1 = 0
x2 = 0
y1 = 0
y2 = 0
if start == None:
if start is None:
if not self.env['commandBuffer']['Marks']['1']:
return False
else:
@ -104,32 +121,40 @@ class cursorManager():
else:
x1 = start['x']
y1 = start['y']
if end == None:
if end is None:
if not self.env['commandBuffer']['Marks']['2']:
return False
else:
x1 = self.env['commandBuffer']['Marks']['2']['x']
y1 = self.env['commandBuffer']['Marks']['2']['y']
y1 = self.env['commandBuffer']['Marks']['2']['y']
else:
x1 = start['x']
y1 = start['y']
y1 = start['y']
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
self.env['commandBuffer']['windowArea'][currApp] = {}
if x1 * y1 <= \
x2 * y2:
self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x1, 'y':y1}
self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x2, 'y':y2}
x2 * y2:
self.env['commandBuffer']['windowArea'][currApp]['1'] = {
'x': x1, 'y': y1}
self.env['commandBuffer']['windowArea'][currApp]['2'] = {
'x': x2, 'y': y2}
else:
self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x2, 'y':y2}
self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x1, 'y':y1}
return True
self.env['commandBuffer']['windowArea'][currApp]['1'] = {
'x': x2, 'y': y2}
self.env['commandBuffer']['windowArea'][currApp]['2'] = {
'x': x1, 'y': y1}
return True
def clearWindowForApplication(self):
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
try:
del self.env['commandBuffer']['windowArea'][currApp]
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('cursorManager clearWindowForApplication: Error clearing window area: ' + str(e), debug.debugLevel.ERROR)
self.env['runtime']['debug'].writeDebugOut(
'cursorManager clearWindowForApplication: Error clearing window area: ' +
str(e),
debug.debugLevel.ERROR)
return False
return True
return True