Merge branch 'master' into storm
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.utils import line_utils
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return _('read line to cursor pos, use review cursor if you are in review mode, otherwhise use text cursor')
|
||||
|
||||
def run(self):
|
||||
cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor()
|
||||
|
||||
x, y, currLine = \
|
||||
line_utils.getCurrentLine(cursorPos['x'], cursorPos['y'], self.env['screen']['newContentText'])
|
||||
|
||||
if currLine.isspace():
|
||||
self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText(currLine[:cursorPos['x']], interrupt=True)
|
||||
self.env['runtime']['outputManager'].announceActiveCursor()
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -26,8 +26,8 @@ class command():
|
||||
if currLine.isspace():
|
||||
self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText(currLine[cursorPos['x']], interrupt=True)
|
||||
self.env['runtime']['outputManager'].announceActiveCursor()
|
||||
self.env['runtime']['outputManager'].presentText(currLine[cursorPos['x']:], interrupt=True)
|
||||
self.env['runtime']['outputManager'].announceActiveCursor()
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -20,30 +20,37 @@ class command():
|
||||
return _('Export current fenrir clipboard to X or GUI clipboard')
|
||||
def run(self):
|
||||
_thread.start_new_thread(self._threadRun , ())
|
||||
|
||||
def _threadRun(self):
|
||||
try:
|
||||
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
|
||||
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
|
||||
return
|
||||
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
|
||||
return
|
||||
|
||||
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
|
||||
user = self.env['general']['currUser']
|
||||
|
||||
for display in range(10):
|
||||
p = Popen('su ' + self.env['general']['currUser'] + ' -c "cat << \\\"EOF\\\" | xclip -d :' + str(display) + ' -selection clipboard\n' + clipboard + '\nEOF\n"', stdout=PIPE, stderr=PIPE, shell=True)
|
||||
stdout, stderr = p.communicate()
|
||||
p = Popen(
|
||||
['su', user, '-c', f"xclip -d :{display} -selection clipboard"],
|
||||
stdin=PIPE, stdout=PIPE, stderr=PIPE, preexec_fn=os.setpgrp
|
||||
)
|
||||
stdout, stderr = p.communicate(input=clipboard.encode('utf-8'))
|
||||
|
||||
self.env['runtime']['outputManager'].interruptOutput()
|
||||
#screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding')
|
||||
|
||||
stderr = stderr.decode('utf-8')
|
||||
stdout = stdout.decode('utf-8')
|
||||
if (stderr == ''):
|
||||
break
|
||||
#stderr = stderr.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
|
||||
#stdout = stdout.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
|
||||
|
||||
if stderr == '':
|
||||
break
|
||||
|
||||
if stderr != '':
|
||||
self.env['runtime']['outputManager'].presentText(stderr , soundIcon='', interrupt=False)
|
||||
self.env['runtime']['outputManager'].presentText(stderr, soundIcon='', interrupt=False)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText('exported to the X session.', interrupt=True)
|
||||
self.env['runtime']['outputManager'].presentText('exported to the X session.', interrupt=True)
|
||||
|
||||
except Exception as e:
|
||||
self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False)
|
||||
|
||||
self.env['runtime']['outputManager'].presentText(str(e), soundIcon='', interrupt=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -14,11 +14,11 @@ class command():
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return _('Move review to the bottom of the screen')
|
||||
return _('Move review to the bottom of the screen')
|
||||
|
||||
def run(self):
|
||||
self.env['screen']['newCursorReview'] = { 'x': 0, 'y':self.env['screen']['lines'] -1}
|
||||
self.env['runtime']['outputManager'].presentText(_("Bottom"), interrupt=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(_("Bottom"), interrupt=True, flush=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -15,7 +15,7 @@ class command():
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return _('set review cursor to begin of current line and display the content')
|
||||
return _('set review cursor to begin of current line and display the content')
|
||||
|
||||
def run(self):
|
||||
cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor()
|
||||
|
@ -0,0 +1,30 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.utils import char_utils
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return _('Move Review to the first character on the screen (left top)')
|
||||
|
||||
def run(self):
|
||||
cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor()
|
||||
self.env['runtime']['cursorManager'].setReviewCursorPosition(0 ,0)
|
||||
self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], lastChar = \
|
||||
char_utils.getLastCharInLine(self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText'])
|
||||
|
||||
self.env['runtime']['outputManager'].presentText(lastChar ,interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(_("first character in screen"), interrupt=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
@ -0,0 +1,30 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.utils import char_utils
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return _('Move Review to the last character on the screen (right bottom)')
|
||||
|
||||
def run(self):
|
||||
cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor()
|
||||
self.env['runtime']['cursorManager'].setReviewCursorPosition(self.env['screen']['columns']-1 ,self.env['screen']['lines']-1)
|
||||
self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], lastChar = \
|
||||
char_utils.getLastCharInLine(self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText'])
|
||||
|
||||
self.env['runtime']['outputManager'].presentText(lastChar ,interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(_("last character in screen"), interrupt=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
@ -17,9 +17,15 @@ class command():
|
||||
return 'No Description found'
|
||||
|
||||
def run(self):
|
||||
# enabled?
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'):
|
||||
# enabled?
|
||||
active = self.env['runtime']['settingsManager'].getSettingAsInt('keyboard', 'charEchoMode')
|
||||
# 0 = off
|
||||
if active == 0:
|
||||
return
|
||||
# 2 = caps only
|
||||
if active == 2:
|
||||
if not self.env['input']['newCapsLock']:
|
||||
return
|
||||
# big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now)
|
||||
xMove = abs(self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x'])
|
||||
if xMove > 3:
|
||||
@ -42,6 +48,7 @@ class command():
|
||||
currDelta.strip() != '':
|
||||
currDelta = currDelta.strip()
|
||||
self.env['runtime']['outputManager'].presentText(currDelta, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False)
|
||||
print(currDelta)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/bin/python
|
||||
import time
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
@ -12,63 +11,75 @@ import datetime
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.lastTime = datetime.datetime.now()
|
||||
self.lastDateString = ''
|
||||
self.lastTimeString = ''
|
||||
self.lastTimeString = ''
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def getDescription(self):
|
||||
return 'No Description found'
|
||||
return 'No Description found'
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('time', 'enabled'):
|
||||
return
|
||||
onMinutes = self.env['runtime']['settingsManager'].getSetting('time', 'onMinutes')
|
||||
|
||||
onMinutes = self.env['runtime']['settingsManager'].getSetting('time', 'onMinutes')
|
||||
delaySec = self.env['runtime']['settingsManager'].getSettingAsInt('time', 'delaySec')
|
||||
|
||||
# no need
|
||||
if onMinutes == '' and delaySec <= 0:
|
||||
return
|
||||
|
||||
onMinutes = onMinutes.split(',')
|
||||
now = datetime.datetime.now()
|
||||
|
||||
# ignore onMinutes if there is a delaySec
|
||||
if delaySec > 0:
|
||||
if int((now-self.lastTime).total_seconds()) < delaySec:
|
||||
return
|
||||
if int((now - self.lastTime).total_seconds()) < delaySec:
|
||||
return
|
||||
else:
|
||||
# shoul announce?
|
||||
# should announce?
|
||||
if not str(now.minute).zfill(2) in onMinutes:
|
||||
return
|
||||
# already announced?
|
||||
if now.hour == self.lastTime.hour:
|
||||
if now.minute == self.lastTime.minute:
|
||||
return
|
||||
|
||||
dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat')
|
||||
dateString = datetime.datetime.strftime(now, dateFormat)
|
||||
|
||||
|
||||
presentDate = self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentDate') and \
|
||||
self.lastDateString != dateString
|
||||
presentTime = self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentTime')
|
||||
self.lastDateString != dateString
|
||||
presentTime = self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentTime')
|
||||
|
||||
# no changed value to announce
|
||||
if not (presentDate or presentTime):
|
||||
return
|
||||
return
|
||||
|
||||
timeFormat = self.env['runtime']['settingsManager'].getSetting('general', 'timeFormat')
|
||||
timeString = datetime.datetime.strftime(now, timeFormat)
|
||||
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'interrupt'):
|
||||
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'interrupt'):
|
||||
self.env['runtime']['outputManager'].interruptOutput()
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'announce'):
|
||||
self.env['runtime']['outputManager'].playSoundIcon('announce')
|
||||
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'announce'):
|
||||
self.env['runtime']['outputManager'].playSoundIcon('announce')
|
||||
|
||||
if presentTime:
|
||||
# present the time
|
||||
self.env['runtime']['outputManager'].presentText(_("It's {0}").format(timeString.replace(':00', " O'clock ").lstrip('0')), soundIcon='', interrupt=False)
|
||||
# and date if changes
|
||||
if presentDate:
|
||||
self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=False)
|
||||
self.lastDateString = dateString
|
||||
# Check if it's 12:00 AM
|
||||
if now.hour == 0 and now.minute == 0:
|
||||
# present the date
|
||||
self.env['runtime']['outputManager'].presentText(dateString, soundIcon='', interrupt=False)
|
||||
|
||||
self.lastTime = datetime.datetime.now()
|
||||
self.lastTimeString = timeString
|
||||
self.lastTimeString = timeString
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -84,8 +84,10 @@ class fenrirManager():
|
||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||
self.modifierInput = False
|
||||
self.singleKeyCommand = False
|
||||
self.singleKeyCommand = False
|
||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||
self.environment['runtime']['inputManager'].handleDeviceGrab()
|
||||
|
||||
if self.environment['input']['keyForeward'] > 0:
|
||||
self.environment['input']['keyForeward'] -=1
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onKeyInput')
|
||||
|
@ -139,6 +139,8 @@ class inputManager():
|
||||
self.env['input']['prevInput'] = []
|
||||
|
||||
def handleLedStates(self, mEvent):
|
||||
if self.currKeyIsModifier():
|
||||
return
|
||||
try:
|
||||
if mEvent['EventName'] == 'KEY_NUMLOCK':
|
||||
self.env['runtime']['inputDriver'].toggleLedState()
|
||||
|
@ -124,7 +124,7 @@ settingsData = {
|
||||
'grabDevices': True,
|
||||
'ignoreShortcuts': False,
|
||||
'keyboardLayout': "desktop",
|
||||
'charEcho': False,
|
||||
'charEchoMode': 2, # while capslock
|
||||
'charDeleteEcho': True,
|
||||
'wordEcho': True,
|
||||
'interruptOnKeyPress': True,
|
||||
|
@ -34,6 +34,11 @@ class driver(screenDriver):
|
||||
self.bgColorValues = {0: 'black', 1: 'blue', 2: 'green', 3: 'cyan', 4: 'red', 5: 'magenta', 6: 'brown/yellow', 7: 'white'}
|
||||
self.fgColorValues = {0: 'black', 1: 'blue', 2: 'green', 3: 'cyan', 4: 'red', 5: 'magenta', 6: 'brown/yellow', 7: 'light gray', 8: 'dark gray', 9: 'light blue', 10: 'light green', 11: 'light cyan', 12: 'light red', 13: 'light magenta', 14: 'light yellow', 15: 'white'}
|
||||
self.hichar = None
|
||||
try:
|
||||
# set workaround for paste clipboard -> injectTextToScreen
|
||||
os.system('sysctl dev.tty.legacy_tiocsti=1')
|
||||
except:
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.env['runtime']['attributeManager'].appendDefaultAttributes([
|
||||
@ -95,8 +100,23 @@ class driver(screenDriver):
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('getSessionInformation: Maybe no LoginD:' + str(e),debug.debugLevel.ERROR)
|
||||
#self.env['runtime']['debug'].writeDebugOut('getSessionInformation:' + str(self.env['screen']['autoIgnoreScreens']) + ' ' + str(self.env['general']) ,debug.debugLevel.INFO)
|
||||
|
||||
def updateWatchdog(self,active , eventQueue):
|
||||
def readFile(self, file):
|
||||
d = b''
|
||||
file.seek(0)
|
||||
try:
|
||||
d = file.read()
|
||||
except:
|
||||
file.seek(0)
|
||||
while True:
|
||||
# Read from file
|
||||
try:
|
||||
d += file.readline(1)
|
||||
if not d:
|
||||
break
|
||||
except Exception as e:
|
||||
break
|
||||
return d
|
||||
def updateWatchdog(self, active , eventQueue):
|
||||
try:
|
||||
useVCSU = os.access('/dev/vcsu', os.R_OK)
|
||||
vcsa = {}
|
||||
@ -111,7 +131,7 @@ class driver(screenDriver):
|
||||
index = str(vcsaDev[9:])
|
||||
vcsa[index] = open(vcsaDev,'rb')
|
||||
if index == currScreen:
|
||||
lastScreenContent = vcsa[index].read()
|
||||
lastScreenContent = self.readFile(vcsa[index])
|
||||
if useVCSU:
|
||||
vcsuDevices = glob.glob('/dev/vcsu*')
|
||||
for vcsuDev in vcsuDevices:
|
||||
@ -143,13 +163,13 @@ class driver(screenDriver):
|
||||
oldScreen = currScreen
|
||||
try:
|
||||
vcsa[currScreen].seek(0)
|
||||
lastScreenContent = vcsa[currScreen].read()
|
||||
lastScreenContent = self.readFile(vcsa[currScreen])
|
||||
except:
|
||||
pass
|
||||
vcsuContent = None
|
||||
if useVCSU:
|
||||
vcsu[currScreen].seek(0)
|
||||
vcsuContent = vcsu[currScreen].read()
|
||||
vcsuContent = self.readFile(vcsu[currScreen])
|
||||
eventQueue.put({"Type":fenrirEventType.ScreenChanged,
|
||||
"Data":self.createScreenEventData(currScreen, lastScreenContent, vcsuContent)
|
||||
})
|
||||
@ -157,7 +177,7 @@ class driver(screenDriver):
|
||||
self.env['runtime']['debug'].writeDebugOut('ScreenUpdate',debug.debugLevel.INFO)
|
||||
vcsa[currScreen].seek(0)
|
||||
time.sleep(0.01)
|
||||
dirtyContent = vcsa[currScreen].read()
|
||||
dirtyContent = self.readFile(vcsa[currScreen])
|
||||
screenContent = dirtyContent
|
||||
vcsuContent = None
|
||||
timeout = time.time()
|
||||
@ -183,7 +203,7 @@ class driver(screenDriver):
|
||||
#if not vcsa[currScreen] in r:
|
||||
# break
|
||||
vcsa[currScreen].seek(0)
|
||||
dirtyContent = vcsa[currScreen].read()
|
||||
dirtyContent = self.readFile(vcsa[currScreen])
|
||||
if screenContent == dirtyContent:
|
||||
break
|
||||
if time.time() - timeout >= 0.1:
|
||||
@ -191,7 +211,7 @@ class driver(screenDriver):
|
||||
break
|
||||
if useVCSU:
|
||||
vcsu[currScreen].seek(0)
|
||||
vcsuContent = vcsu[currScreen].read()
|
||||
vcsuContent = self.readFile(vcsu[currScreen])
|
||||
lastScreenContent = screenContent
|
||||
eventQueue.put({"Type":fenrirEventType.ScreenUpdate,
|
||||
"Data":self.createScreenEventData(currScreen, screenContent, vcsuContent)
|
||||
|
Reference in New Issue
Block a user