Compare commits
No commits in common. "7a12992b882515b21ca8524c33f82073728b5e3f" and "7a87fb51bb201681aae7e4e83bb557c1c28af85e" have entirely different histories.
7a12992b88
...
7a87fb51bb
@ -5,4 +5,4 @@ pyudev>=0.21.0
|
|||||||
pexpect
|
pexpect
|
||||||
pyperclip
|
pyperclip
|
||||||
pyte>=0.7.0
|
pyte>=0.7.0
|
||||||
setproctitle
|
rapidfuzz>=2.0.0
|
||||||
|
8
setup.py
8
setup.py
@ -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('config/fenrirscreenreader/settings/settings.conf', '/etc/fenrirscreenreader/settings/settings.conf')
|
copyfile('/etc/fenrirscreenreader/settings/settings.conf.example', '/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 OSError as e:
|
except:
|
||||||
print(f"Could not copy settings file to destination: {e}")
|
pass
|
||||||
else:
|
else:
|
||||||
print('settings.conf file found. It is not overwritten automatical')
|
print('settings.conf file found. It is not overwritten automatical')
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
from fenrirscreenreader.core import debug
|
from fenrirscreenreader.core import debug
|
||||||
import os
|
import os
|
||||||
import importlib
|
|
||||||
import _thread
|
import _thread
|
||||||
import pyperclip
|
import pyperclip
|
||||||
|
|
||||||
@ -43,7 +42,6 @@ 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
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
# 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
|
||||||
@ -35,7 +34,6 @@ 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:
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
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):
|
||||||
@ -82,6 +83,7 @@ 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']
|
||||||
@ -144,8 +146,11 @@ 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() != '':
|
||||||
@ -153,9 +158,28 @@ 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:
|
||||||
diff = self.differ.compare(oldScreenText.split('\n'),\
|
# For screen changes, use the original differ
|
||||||
newScreenText.split('\n'))
|
if self.isScreenChange() or trigger == 'onScreenChange':
|
||||||
diffList = list(diff)
|
diff = self.differ.compare(oldScreenText.split('\n'),
|
||||||
|
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] == '+')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user