fix some bad stuff
This commit is contained in:
@ -1,24 +0,0 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return _('interrupts the current presentation')
|
||||
def run(self):
|
||||
if len(self.env['input']['prevDeepestInput']) > len(self.env['input']['currInput']):
|
||||
return
|
||||
self.env['runtime']['outputManager'].interruptOutput()
|
||||
self.env['runtime']['screenManager'].injectTextToScreen(b'\x1b')
|
||||
def setCallback(self, callback):
|
||||
pass
|
@ -1,58 +0,0 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
import string
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return 'No Description found'
|
||||
|
||||
def run(self):
|
||||
# is it enabled?
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'):
|
||||
return
|
||||
# is naviation?
|
||||
if self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x'] != 1:
|
||||
return
|
||||
# just when cursor move worddetection is needed
|
||||
if not self.env['runtime']['cursorManager'].isCursorHorizontalMove():
|
||||
return
|
||||
# for now no new line
|
||||
if self.env['runtime']['cursorManager'].isCursorVerticalMove():
|
||||
return
|
||||
# currently writing
|
||||
if self.env['runtime']['screenManager'].isDelta():
|
||||
return
|
||||
|
||||
# get the word
|
||||
newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]
|
||||
x, y, currWord, endOfScreen, lineBreak = \
|
||||
word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent)
|
||||
|
||||
# is there a word?
|
||||
if currWord == '':
|
||||
return
|
||||
# at the end of a word
|
||||
if not newContent[self.env['screen']['newCursor']['x']].isspace():
|
||||
return
|
||||
# at the end of a word
|
||||
if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \
|
||||
(x + len(currWord) != self.env['screen']['newCursor']['x']-1):
|
||||
return
|
||||
|
||||
self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -57,10 +57,7 @@ class command():
|
||||
return
|
||||
# deletion
|
||||
if self.env['runtime']['screenManager'].isNegativeDelta():
|
||||
# quirk for pseudo windows like finch (uses _ insteed of space in input box)
|
||||
if self.env['screen']['newNegativeDelta'] != '_':
|
||||
return
|
||||
|
||||
return
|
||||
# first place could not be the end of a word
|
||||
if self.env['screen']['newCursor']['x'] == 0:
|
||||
return
|
||||
|
@ -25,9 +25,7 @@ class command():
|
||||
|
||||
# More than just a deletion happend
|
||||
if self.env['runtime']['screenManager'].isDelta(ignoreSpace=True):
|
||||
# hack for finch and other pseudo window apps that use _ for input boxes
|
||||
if not self.env['screen']['newDelta'] == '_':
|
||||
return
|
||||
return
|
||||
|
||||
# no deletion
|
||||
if not self.env['runtime']['screenManager'].isNegativeDelta():
|
||||
|
@ -19,7 +19,6 @@ class command():
|
||||
def run(self):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'autoReadIncoming'):
|
||||
return
|
||||
|
||||
# is there something to read?
|
||||
if not self.env['runtime']['screenManager'].isDelta(ignoreSpace=True):
|
||||
return
|
||||
@ -28,11 +27,11 @@ class command():
|
||||
#if len(self.env['screen']['newDelta'].strip(' \n\t')) <= 1:
|
||||
xMove = abs(self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x'])
|
||||
yMove = abs(self.env['screen']['newCursor']['y'] - self.env['screen']['oldCursor']['y'])
|
||||
if (xMove >= 1):# and xMove == len(self.env['screen']['newDelta']):
|
||||
|
||||
if (xMove >= 1) and xMove == len(self.env['screen']['newDelta']):
|
||||
# if len(self.env['screen']['newDelta'].strip(' \n\t0123456789')) <= 2:
|
||||
if not '\n' in self.env['screen']['newDelta']:
|
||||
return
|
||||
|
||||
#print(xMove, yMove, len(self.env['screen']['newDelta']), len(self.env['screen']['newNegativeDelta']))
|
||||
self.env['runtime']['outputManager'].presentText(self.env['screen']['newDelta'], interrupt=False, flush=False)
|
||||
|
||||
|
@ -159,19 +159,13 @@ class screenManager():
|
||||
#newScreenText = re.sub(' +',' ',newScreenText)
|
||||
diff = self.differ.compare(oldScreenText, newScreenText)
|
||||
diffList = list(diff)
|
||||
typing = True
|
||||
typing = True
|
||||
tempNewDelta = ''.join(x[2:] for x in diffList if x[0] == '+')
|
||||
if tempNewDelta.strip() != '':
|
||||
if not '│' not in tempNewDelta:
|
||||
if tempNewDelta != ''.join(newScreenText[self.env['screen']['oldCursor']['x']:self.env['screen']['newCursor']['x']].rstrip()):
|
||||
diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +'\n']
|
||||
typing = False
|
||||
if tempNewDelta != ''.join(newScreenText[self.env['screen']['oldCursor']['x']:self.env['screen']['newCursor']['x']].rstrip()):
|
||||
diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +'\n']
|
||||
typing = False
|
||||
else:
|
||||
# cleanup scrollbars in windows to not produce wrong output
|
||||
if ('│' in newScreenText) and ('│' in oldScreenText):
|
||||
for c in ['▒','↑','↓']:
|
||||
newScreenText = newScreenText.replace(c,'')
|
||||
oldScreenText = oldScreenText.replace(c,'')
|
||||
diff = self.differ.compare(oldScreenText.split('\n'),\
|
||||
newScreenText.split('\n'))
|
||||
diffList = list(diff)
|
||||
|
@ -4,7 +4,7 @@
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
import os, struct, sys, pty, tty, termios, shlex, signal, select, pyte, time, fcntl ,getpass,traceback
|
||||
import os, struct, sys, pty, tty, termios, shlex, signal, select, pyte, time, fcntl ,getpass
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.core.eventData import fenrirEventType
|
||||
from fenrirscreenreader.core.screenDriver import screenDriver
|
||||
@ -143,14 +143,12 @@ class driver(screenDriver):
|
||||
def handleSigwinch(self, *args):
|
||||
os.write(self.signalPipe[1], b'w')
|
||||
def terminalEmulation(self,active , eventQueue):
|
||||
|
||||
try:
|
||||
old_attr = termios.tcgetattr(sys.stdin)
|
||||
tty.setraw(0)
|
||||
lines, columns = self.getTerminalSize(0)
|
||||
if self.command == '':
|
||||
self.command = screen_utils.getShell()
|
||||
self.env['runtime']['debug'].writeDebugOut('Process starting.. ' + self.command,debug.debugLevel.INFO)
|
||||
terminal, p_pid, self.p_out = self.openTerminal(columns, lines, self.command)
|
||||
lines, columns = self.resizeTerminal(self.p_out)
|
||||
terminal.resize(lines, columns)
|
||||
@ -194,8 +192,7 @@ class driver(screenDriver):
|
||||
"Data":screen_utils.createScreenEventData(terminal.GetScreenContent())
|
||||
})
|
||||
except Exception as e: # Process died?
|
||||
self.env['runtime']['debug'].writeDebugOut('Process died' + str(e),debug.debugLevel.ERROR)
|
||||
self.env['runtime']['debug'].writeDebugOut(str(traceback.format_exc()),debug.debugLevel.ERROR)
|
||||
print(e)
|
||||
active.value = False
|
||||
finally:
|
||||
os.kill(p_pid, signal.SIGTERM)
|
||||
|
Reference in New Issue
Block a user