latest release.

This commit is contained in:
Storm Dragon 2025-04-17 00:36:26 -04:00
commit 7a12992b88
5 changed files with 13 additions and 33 deletions

View File

@ -5,4 +5,4 @@ pyudev>=0.21.0
pexpect pexpect
pyperclip pyperclip
pyte>=0.7.0 pyte>=0.7.0
rapidfuzz>=2.0.0 setproctitle

View File

@ -101,8 +101,8 @@ setup(
"dbus-python>=1.2.8", "dbus-python>=1.2.8",
"pyperclip", "pyperclip",
"pyudev>=0.21.0", "pyudev>=0.21.0",
"rapidfuzz>=2.0.0",
"setuptools", "setuptools",
"setproctitle",
"pexpect", "pexpect",
"pyte>=0.7.0", "pyte>=0.7.0",
], ],
@ -113,10 +113,10 @@ if not forceSettingsFlag:
# create settings file from example if not exist # create settings file from example if not exist
if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'): if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'):
try: try:
copyfile('/etc/fenrirscreenreader/settings/settings.conf.example', '/etc/fenrirscreenreader/settings/settings.conf') copyfile('config/fenrirscreenreader/settings/settings.conf', '/etc/fenrirscreenreader/settings/settings.conf')
print('create settings file in /etc/fenrirscreenreader/settings/settings.conf') print('create settings file in /etc/fenrirscreenreader/settings/settings.conf')
except: except OSError as e:
pass print(f"Could not copy settings file to destination: {e}")
else: else:
print('settings.conf file found. It is not overwritten automatical') print('settings.conf file found. It is not overwritten automatical')

View File

@ -6,6 +6,7 @@
from fenrirscreenreader.core import debug from fenrirscreenreader.core import debug
import os import os
import importlib
import _thread import _thread
import pyperclip import pyperclip
@ -42,6 +43,7 @@ class command():
# Set display environment variable # Set display environment variable
os.environ['DISPLAY'] = display os.environ['DISPLAY'] = display
# Attempt to set clipboard content # Attempt to set clipboard content
importlib.reload(pyperclip) # Weird workaround for some distros
pyperclip.copy(clipboard) pyperclip.copy(clipboard)
# If we get here without exception, we found a working display # If we get here without exception, we found a working display
success = True success = True

View File

@ -5,6 +5,7 @@
# By Chrys, Storm Dragon, and contributers. # By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug from fenrirscreenreader.core import debug
import importlib
import _thread import _thread
import pyperclip import pyperclip
import os import os
@ -34,6 +35,7 @@ class command():
# Set display environment variable # Set display environment variable
os.environ['DISPLAY'] = display os.environ['DISPLAY'] = display
# Attempt to get clipboard content # Attempt to get clipboard content
importlib.reload(pyperclip) # Weird workaround for some distros
clipboardContent = pyperclip.paste() clipboardContent = pyperclip.paste()
# If we get here without exception, we found a working display # If we get here without exception, we found a working display
if clipboardContent: if clipboardContent:

View File

@ -7,7 +7,6 @@
from fenrirscreenreader.core import debug from fenrirscreenreader.core import debug
from fenrirscreenreader.utils import screen_utils from fenrirscreenreader.utils import screen_utils
import time, os, re, difflib import time, os, re, difflib
from rapidfuzz.distance import Levenshtein
class screenManager(): class screenManager():
def __init__(self): def __init__(self):
@ -83,7 +82,6 @@ class screenManager():
def updateScreenIgnored(self): def updateScreenIgnored(self):
self.prevScreenIgnored = self.currScreenIgnored self.prevScreenIgnored = self.currScreenIgnored
self.currScreenIgnored = self.isSuspendingScreen(self.env['screen']['newTTY']) self.currScreenIgnored = self.isSuspendingScreen(self.env['screen']['newTTY'])
def update(self, eventData, trigger='onUpdate'): def update(self, eventData, trigger='onUpdate'):
# set new "old" values # set new "old" values
self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes'] self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes']
@ -146,11 +144,8 @@ class screenManager():
cursorLineEndOffset = cursorLineStart + self.env['screen']['newCursor']['x'] + 3 cursorLineEndOffset = cursorLineStart + self.env['screen']['newCursor']['x'] + 3
oldScreenText = self.env['screen']['oldContentText'][cursorLineStartOffset:cursorLineEndOffset] oldScreenText = self.env['screen']['oldContentText'][cursorLineStartOffset:cursorLineEndOffset]
newScreenText = self.env['screen']['newContentText'][cursorLineStartOffset:cursorLineEndOffset] newScreenText = self.env['screen']['newContentText'][cursorLineStartOffset:cursorLineEndOffset]
# Use the original differ for typing mode to preserve behavior
diff = self.differ.compare(oldScreenText, newScreenText) diff = self.differ.compare(oldScreenText, newScreenText)
diffList = list(diff) diffList = list(diff)
typing = True typing = True
tempNewDelta = ''.join(x[2:] for x in diffList if x[0] == '+') tempNewDelta = ''.join(x[2:] for x in diffList if x[0] == '+')
if tempNewDelta.strip() != '': if tempNewDelta.strip() != '':
@ -158,28 +153,9 @@ class screenManager():
diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +'\n'] diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +'\n']
typing = False typing = False
else: else:
# For screen changes, use the original differ diff = self.differ.compare(oldScreenText.split('\n'),\
if self.isScreenChange() or trigger == 'onScreenChange': newScreenText.split('\n'))
diff = self.differ.compare(oldScreenText.split('\n'), diffList = list(diff)
newScreenText.split('\n'))
diffList = list(diff)
else:
# Use rapidfuzz for normal updates - not for screen changes
try:
# Process line by line using rapidfuzz
old_lines = oldScreenText.split('\n')
new_lines = newScreenText.split('\n')
# Use standard differ for better word grouping
diff = self.differ.compare(old_lines, new_lines)
diffList = list(diff)
except Exception as e:
# Fall back to standard differ if there's any issue
self.env['runtime']['debug'].writeDebugOut('screenManager:update:rapidfuzz: ' + str(e), debug.debugLevel.ERROR)
diff = self.differ.compare(oldScreenText.split('\n'),
newScreenText.split('\n'))
diffList = list(diff)
if not typing: if not typing:
self.env['screen']['newDelta'] = '\n'.join(x[2:] for x in diffList if x[0] == '+') self.env['screen']['newDelta'] = '\n'.join(x[2:] for x in diffList if x[0] == '+')