latest release.
This commit is contained in:
		| @@ -6,6 +6,7 @@ | ||||
|  | ||||
| from fenrirscreenreader.core import debug | ||||
| import os | ||||
| import importlib | ||||
| import _thread | ||||
| import pyperclip | ||||
|  | ||||
| @@ -42,6 +43,7 @@ class command(): | ||||
|                     # Set display environment variable | ||||
|                     os.environ['DISPLAY'] = display | ||||
|                     # Attempt to set clipboard content | ||||
|                     importlib.reload(pyperclip) # Weird workaround for some distros | ||||
|                     pyperclip.copy(clipboard) | ||||
|                     # If we get here without exception, we found a working display | ||||
|                     success = True | ||||
|   | ||||
| @@ -5,6 +5,7 @@ | ||||
| # By Chrys, Storm Dragon, and contributers. | ||||
|  | ||||
| from fenrirscreenreader.core import debug | ||||
| import importlib | ||||
| import _thread | ||||
| import pyperclip | ||||
| import os | ||||
| @@ -34,6 +35,7 @@ class command(): | ||||
|                     # Set display environment variable | ||||
|                     os.environ['DISPLAY'] = display | ||||
|                     # Attempt to get clipboard content | ||||
|                     importlib.reload(pyperclip) # Weird workaround for some distros | ||||
|                     clipboardContent = pyperclip.paste() | ||||
|                     # If we get here without exception, we found a working display | ||||
|                     if clipboardContent: | ||||
|   | ||||
| @@ -7,7 +7,6 @@ | ||||
| from fenrirscreenreader.core import debug | ||||
| from fenrirscreenreader.utils import screen_utils | ||||
| import time, os, re, difflib | ||||
| from rapidfuzz.distance import Levenshtein | ||||
|  | ||||
| class screenManager(): | ||||
|     def __init__(self): | ||||
| @@ -83,7 +82,6 @@ class screenManager(): | ||||
|     def updateScreenIgnored(self): | ||||
|         self.prevScreenIgnored = self.currScreenIgnored | ||||
|         self.currScreenIgnored = self.isSuspendingScreen(self.env['screen']['newTTY']) | ||||
|  | ||||
|     def update(self, eventData, trigger='onUpdate'): | ||||
|         # set new "old" values | ||||
|         self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes'] | ||||
| @@ -146,11 +144,8 @@ class screenManager(): | ||||
|                         cursorLineEndOffset = cursorLineStart + self.env['screen']['newCursor']['x'] + 3 | ||||
|                     oldScreenText = self.env['screen']['oldContentText'][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)  | ||||
|                     diffList = list(diff) | ||||
|  | ||||
|                     typing = True | ||||
|                     tempNewDelta = ''.join(x[2:] for x in diffList if x[0] == '+') | ||||
|                     if tempNewDelta.strip() != '': | ||||
| @@ -158,28 +153,9 @@ class screenManager(): | ||||
|                             diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +'\n'] | ||||
|                             typing = False | ||||
|                 else: | ||||
|                     # For screen changes, use the original differ | ||||
|                     if self.isScreenChange() or trigger == 'onScreenChange': | ||||
|                         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) | ||||
|                     diff = self.differ.compare(oldScreenText.split('\n'),\ | ||||
|                       newScreenText.split('\n')) | ||||
|                     diffList = list(diff) | ||||
|  | ||||
|                 if not typing: | ||||
|                     self.env['screen']['newDelta'] = '\n'.join(x[2:] for x in diffList if x[0] == '+') | ||||
| @@ -209,7 +185,7 @@ class screenManager(): | ||||
|             ignoreScreens.extend(self.env['screen']['autoIgnoreScreens']) | ||||
|         self.env['runtime']['debug'].writeDebugOut('screenManager:isSuspendingScreen ignore:' + str(ignoreScreens) + ' current:'+ str(screen ), debug.debugLevel.INFO) | ||||
|         return (screen in ignoreScreens) | ||||
|  | ||||
|   | ||||
|     def isScreenChange(self): | ||||
|         if not self.env['screen']['oldTTY']: | ||||
|             return False | ||||
|   | ||||
		Reference in New Issue
	
	Block a user