WIP memoryManager

This commit is contained in:
chrys 2017-11-03 13:33:06 +01:00
parent 46d01103c4
commit 93f4c92a10
27 changed files with 529 additions and 82 deletions

View File

@ -0,0 +1,26 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
# this command is just to initialize stuff.
# like init index lists in memoryManager
# it is not useful to execute it
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
# clipboard
self.env['runtime']['memoryManager'].addIndexList(self, 'clipboardHistory', self.env['runtime']['settingsManager'].getSettingAsInt('general', 'numberOfClipboards'))
def shutdown(self):
pass
def getDescription(self):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,26 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
# this command is just to initialize stuff.
# like init index lists in memoryManager
# it is not useful to execute it
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
# clipboard
self.env['runtime']['memoryManager'].addIndexList(self, 'clipboardHistory', self.env['runtime']['settingsManager'].getSettingAsInt('general', 'numberOfClipboards'))
def shutdown(self):
pass
def getDescription(self):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -24,20 +24,11 @@ class command():
clipboardFilePath = clipboardFilePath.replace('$User',self.env['general']['currUser']) clipboardFilePath = clipboardFilePath.replace('$User',self.env['general']['currUser'])
clipboardFile = open(clipboardFilePath,'w') clipboardFile = open(clipboardFilePath,'w')
try: try:
currClipboard = self.env['commandBuffer']['currClipboard'] if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
if currClipboard < 0:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return return
if not self.env['commandBuffer']['clipboard']: clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) clipboardFile.write(clipboard)
return
if not self.env['commandBuffer']['clipboard'][currClipboard]:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if self.env['commandBuffer']['clipboard'][currClipboard] == '':
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
clipboardFile.write(self.env['commandBuffer']['clipboard'][currClipboard])
clipboardFile.close() clipboardFile.close()
os.chmod(clipboardFilePath, 0o666) os.chmod(clipboardFilePath, 0o666)
self.env['runtime']['outputManager'].presentText(_('clipboard exported to file'), interrupt=True) self.env['runtime']['outputManager'].presentText(_('clipboard exported to file'), interrupt=True)

View File

@ -24,22 +24,12 @@ class command():
def _threadRun(self): def _threadRun(self):
try: try:
currClipboard = self.env['commandBuffer']['currClipboard'] if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
if currClipboard < 0:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if not self.env['commandBuffer']['clipboard']:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if not self.env['commandBuffer']['clipboard'][currClipboard]:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if self.env['commandBuffer']['clipboard'][currClipboard] == '':
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return return
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
for display in range(10): for display in range(10):
p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \\\"' + self.env['commandBuffer']['clipboard'][currClipboard].replace('"','\\\\\\"') +'\\\" | xclip -d :' + str(display) + ' -selection c"' , stdout=PIPE, stderr=PIPE, shell=True) p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \\\"' + clipboard.replace('"','\\\\\\"') +'\\\" | xclip -d :' + str(display) + ' -selection c"' , stdout=PIPE, stderr=PIPE, shell=True)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
self.env['runtime']['outputManager'].interruptOutput() self.env['runtime']['outputManager'].interruptOutput()
#screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding') #screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding')

View File

@ -17,11 +17,12 @@ class command():
return _('selects the first clipboard') return _('selects the first clipboard')
def run(self): def run(self):
if len(self.env['commandBuffer']['clipboard']) == 0: if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return return
self.env['commandBuffer']['currClipboard'] = 0 self.env['runtime']['memoryManager'].setFirstIndex('clipboardHistory')
self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=True) clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
self.env['runtime']['outputManager'].presentText(clipboard, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -29,8 +29,7 @@ class command():
clipboardFile = open(clipboardFilePath,'r') clipboardFile = open(clipboardFilePath,'r')
imported = clipboardFile.read() imported = clipboardFile.read()
clipboardFile.close() clipboardFile.close()
self.env['commandBuffer']['clipboard'] = [imported] + self.env['commandBuffer']['clipboard'][:self.env['runtime']['settingsManager'].getSettingAsInt('general', 'numberOfClipboards') -1] self.env['runtime']['memoryManager'].addValueToFirstIndex('clipboardHistory', imported)
self.env['commandBuffer']['currClipboard'] = 0
self.env['runtime']['outputManager'].presentText('Import to Clipboard', soundIcon='CopyToClipboard', interrupt=True) self.env['runtime']['outputManager'].presentText('Import to Clipboard', soundIcon='CopyToClipboard', interrupt=True)
self.env['runtime']['outputManager'].presentText(imported, soundIcon='', interrupt=False) self.env['runtime']['outputManager'].presentText(imported, soundIcon='', interrupt=False)

View File

@ -17,11 +17,12 @@ class command():
return _('selects the last clipboard') return _('selects the last clipboard')
def run(self): def run(self):
if len(self.env['commandBuffer']['clipboard']) == 0: if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return return
self.env['commandBuffer']['currClipboard'] = len(self.env['commandBuffer']['clipboard']) -1 self.env['runtime']['memoryManager'].setLastIndex('clipboardHistory')
self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=True) clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
self.env['runtime']['outputManager'].presentText(clipboard, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -17,16 +17,20 @@ class command():
return _('selects the next clipboard') return _('selects the next clipboard')
def run(self): def run(self):
if len(self.env['commandBuffer']['clipboard']) == 0: if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return return
self.env['commandBuffer']['currClipboard'] += 1 self.env['runtime']['memoryManager'].getNextIndex('clipboardHistory')
if self.env['commandBuffer']['currClipboard'] > len(self.env['commandBuffer']['clipboard']) -1: isFirst = self.env['runtime']['memoryManager'].isFirstIndex('clipboardHistory')
self.env['commandBuffer']['currClipboard'] = 0 isLast = self.env['runtime']['memoryManager'].isLastIndex('clipboardHistory')
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
if isFirst:
self.env['runtime']['outputManager'].presentText(_('First clipboard '), interrupt=True) self.env['runtime']['outputManager'].presentText(_('First clipboard '), interrupt=True)
self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=False) if isLast:
else: self.env['runtime']['outputManager'].presentText(_('Last clipboard '), interrupt=True)
self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=True)
speechInterrupt = not(isLast or isFirst)
self.env['runtime']['outputManager'].presentText(clipboard, interrupt = speechInterrupt)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -19,22 +19,12 @@ class command():
return _('pastes the text from the currently selected clipboard') return _('pastes the text from the currently selected clipboard')
def run(self): def run(self):
currClipboard = self.env['commandBuffer']['currClipboard'] if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
if currClipboard < 0:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if not self.env['commandBuffer']['clipboard']:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if not self.env['commandBuffer']['clipboard'][currClipboard]:
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
if self.env['commandBuffer']['clipboard'][currClipboard] == '':
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return return
self.env['runtime']['outputManager'].presentText('paste clipboard', soundIcon='PasteClipboardOnScreen', interrupt=True) self.env['runtime']['outputManager'].presentText('paste clipboard', soundIcon='PasteClipboardOnScreen', interrupt=True)
time.sleep(0.01) clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
self.env['runtime']['screenManager'].injectTextToScreen(self.env['commandBuffer']['clipboard'][currClipboard]) self.env['runtime']['screenManager'].injectTextToScreen(clipboard)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -17,16 +17,20 @@ class command():
return _('selects the previous clipboard') return _('selects the previous clipboard')
def run(self): def run(self):
if len(self.env['commandBuffer']['clipboard']) == 0: if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return return
self.env['commandBuffer']['currClipboard'] -= 1 self.env['runtime']['memoryManager'].setPrefIndex('clipboardHistory')
if self.env['commandBuffer']['currClipboard'] < 0: isFirst = self.env['runtime']['memoryManager'].isFirstIndex('clipboardHistory')
self.env['commandBuffer']['currClipboard'] = len(self.env['commandBuffer']['clipboard']) -1 isLast = self.env['runtime']['memoryManager'].isLastIndex('clipboardHistory')
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
if isFirst:
self.env['runtime']['outputManager'].presentText(_('First clipboard '), interrupt=True)
if isLast:
self.env['runtime']['outputManager'].presentText(_('Last clipboard '), interrupt=True) self.env['runtime']['outputManager'].presentText(_('Last clipboard '), interrupt=True)
self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=False)
else: speechInterrupt = not(isLast or isFirst)
self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=True) self.env['runtime']['outputManager'].presentText(clipboard, interrupt = speechInterrupt)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -0,0 +1,24 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('clears the currently selected clipboard')
def run(self):
self.env['runtime']['memoryManager'].clearCurrentIndexList('clipboardHistory')
self.env['runtime']['outputManager'].presentText(_('clipboard cleared'), interrupt=True)
return
def setCallback(self, callback):
pass

View File

@ -0,0 +1,26 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
from utils import mark_utils
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('copies last presented text to the currently selected clipboard')
def run(self):
lastEcho = self.env['runtime']['outputManager'].getLastEcho()
self.env['runtime']['memoryManager'].addValueToFirstIndex('clipboardHistory', lastEcho)
self.env['runtime']['outputManager'].presentText(lastEcho, soundIcon='CopyToClipboard', interrupt=True)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,39 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
from utils import mark_utils
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('copies marked text to the currently selected clipboard')
def run(self):
if not self.env['commandBuffer']['Marks']['1']:
self.env['runtime']['outputManager'].presentText(_("one or two marks needed"), interrupt=True)
return
if not self.env['commandBuffer']['Marks']['2']:
self.env['runtime']['cursorManager'].setMark()
# use the last first and the last setted mark as range
startMark = self.env['commandBuffer']['Marks']['1'].copy()
endMark = self.env['commandBuffer']['Marks']['2'].copy()
marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText'])
self.env['runtime']['memoryManager'].addValueToFirstIndex('clipboardHistory', marked)
# reset marks
self.env['runtime']['cursorManager'].clearMarks()
self.env['runtime']['outputManager'].presentText(marked, soundIcon='CopyToClipboard', interrupt=True)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,27 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('speaks the contents of the currently selected clipboard')
def run(self):
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
self.env['runtime']['outputManager'].presentText(clipboard , interrupt=True)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,39 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
import os
class command():
def __init__(self):
pass
def initialize(self, environment, scriptPath=''):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('export the current fenrir clipboard to a file')
def run(self):
clipboardFilePath = self.env['runtime']['settingsManager'].getSetting('general', 'clipboardExportPath')
clipboardFilePath = clipboardFilePath.replace('$user',self.env['general']['currUser'])
clipboardFilePath = clipboardFilePath.replace('$USER',self.env['general']['currUser'])
clipboardFilePath = clipboardFilePath.replace('$User',self.env['general']['currUser'])
clipboardFile = open(clipboardFilePath,'w')
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')
clipboardFile.write(clipboard)
clipboardFile.close()
os.chmod(clipboardFilePath, 0o666)
self.env['runtime']['outputManager'].presentText(_('clipboard exported to file'), interrupt=True)
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('export_clipboard_to_file:run: Filepath:'+ clipboardFile +' trace:' + str(e),debug.debugLevel.ERROR)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,50 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
import subprocess, os
from subprocess import Popen, PIPE
import _thread
class command():
def __init__(self):
pass
def initialize(self, environment, scriptPath=''):
self.env = environment
self.scriptPath = scriptPath
def shutdown(self):
pass
def getDescription(self):
return _('export the current fenrir clipboard to X 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')
for display in range(10):
p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \\\"' + clipboard.replace('"','\\\\\\"') +'\\\" | xclip -d :' + str(display) + ' -selection c"' , stdout=PIPE, stderr=PIPE, shell=True)
stdout, stderr = p.communicate()
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 != '':
self.env['runtime']['outputManager'].presentText(stderr , soundIcon='', interrupt=False)
else:
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)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,28 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('selects the first clipboard')
def run(self):
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
self.env['runtime']['memoryManager'].setFirstIndex('clipboardHistory')
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
self.env['runtime']['outputManager'].presentText(clipboard, interrupt=True)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,44 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
from utils import mark_utils
import os
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
self.env['runtime']['memoryManager'].isFirstIndex('clipboardHistory')
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
self.env['runtime']['outputManager'].presentText(clipboard, interrupt=True)
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('imports text from clipboard file to the clipboard')
def run(self):
clipboardFilePath = self.env['runtime']['settingsManager'].getSetting('general', 'clipboardExportPath')
clipboardFilePath = clipboardFilePath.replace('$user',self.env['general']['currUser'])
clipboardFilePath = clipboardFilePath.replace('$USER',self.env['general']['currUser'])
clipboardFilePath = clipboardFilePath.replace('$User',self.env['general']['currUser'])
if not os.path.exists(clipboardFilePath):
self.env['runtime']['outputManager'].presentText(_('File does not exist'), soundIcon='', interrupt=True)
return
clipboardFile = open(clipboardFilePath,'r')
imported = clipboardFile.read()
clipboardFile.close()
self.env['runtime']['memoryManager'].addValueToFirstIndex('clipboardHistory', imported)
self.env['runtime']['outputManager'].presentText('Import to Clipboard', soundIcon='CopyToClipboard', interrupt=True)
self.env['runtime']['outputManager'].presentText(imported, soundIcon='', interrupt=False)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,28 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('selects the last clipboard')
def run(self):
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
self.env['runtime']['memoryManager'].setLastIndex('clipboardHistory')
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
self.env['runtime']['outputManager'].presentText(clipboard, interrupt=True)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,36 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('selects the next clipboard')
def run(self):
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
self.env['runtime']['memoryManager'].getNextIndex('clipboardHistory')
isFirst = self.env['runtime']['memoryManager'].isFirstIndex('clipboardHistory')
isLast = self.env['runtime']['memoryManager'].isLastIndex('clipboardHistory')
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
if isFirst:
self.env['runtime']['outputManager'].presentText(_('First clipboard '), interrupt=True)
if isLast:
self.env['runtime']['outputManager'].presentText(_('Last clipboard '), interrupt=True)
speechInterrupt = not(isLast or isFirst)
self.env['runtime']['outputManager'].presentText(clipboard, interrupt = speechInterrupt)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,30 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
import time
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
self.env['runtime']['memoryManager'].addIndexList('clipboardHistory', self.env['runtime']['settingsManager'].getSettingAsInt('general', 'numberOfClipboards'))
def shutdown(self):
pass
def getDescription(self):
return _('pastes the text from the currently selected clipboard')
def run(self):
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
self.env['runtime']['outputManager'].presentText('paste clipboard', soundIcon='PasteClipboardOnScreen', interrupt=True)
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
self.env['runtime']['screenManager'].injectTextToScreen(clipboard)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,36 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('selects the previous clipboard')
def run(self):
if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'):
self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True)
return
self.env['runtime']['memoryManager'].setPrefIndex('clipboardHistory')
isFirst = self.env['runtime']['memoryManager'].isFirstIndex('clipboardHistory')
isLast = self.env['runtime']['memoryManager'].isLastIndex('clipboardHistory')
clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory')
if isFirst:
self.env['runtime']['outputManager'].presentText(_('First clipboard '), interrupt=True)
if isLast:
self.env['runtime']['outputManager'].presentText(_('Last clipboard '), interrupt=True)
speechInterrupt = not(isLast or isFirst)
self.env['runtime']['outputManager'].presentText(clipboard, interrupt = speechInterrupt)
def setCallback(self, callback):
pass

View File

@ -11,11 +11,6 @@ import time
# use this in your own commands # use this in your own commands
commandBuffer = { commandBuffer = {
'enableSpeechOnKeypress': False, 'enableSpeechOnKeypress': False,
'genericList':[],
'genericListSource':'',
'genericListSelection': 0,
'clipboard':[],
'currClipboard': 0,
'Marks':{'1':None, '2':None}, 'Marks':{'1':None, '2':None},
'bookMarks':{}, 'bookMarks':{},
'windowArea':{}, 'windowArea':{},

View File

@ -15,22 +15,27 @@ class memoryManager():
def shutdown(self): def shutdown(self):
pass pass
def listStorageValid(self,name, index = None): def listStorageValid(self,name, index = None):
print(index,self.listStorage[name]['list'])
try: try:
if index == None: if index == None:
index = self.listStorage[name]['index'] index = self.listStorage[name]['index']
if index == -1:
return self.listStorage[name]['list'] == []
return self.listStorage[name]['list'][index] != None return self.listStorage[name]['list'][index] != None
except e as Exception: except Exception as e:
self.env['runtime']['debug'].writeDebugOut("listStorageValid " + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("listStorageValid " + str(e),debug.debugLevel.ERROR)
return False return False
def addValueToFirstIndex(self, name, value, index = 0): def addValueToFirstIndex(self, name, value):
if not self.listStorageValid(name, index): if not self.listStorageValid(name):
return return
if self.listStorage[name]['maxLength'] != None: if self.listStorage[name]['maxLength'] != None:
self.listStorage[name]['list'] = [value] + self.listStorage[name]['list'] self.listStorage[name]['list'] = [value] + self.listStorage[name]['list']
else: else:
self.listStorage[name]['list'] = [value] + self.listStorage[name]['list'][:self.listStorage[name]['maxLength'] -1] self.listStorage[name]['list'] = [value] + self.listStorage[name]['list'][:self.listStorage[name]['maxLength'] -1]
self.listStorage[name]['index'] = index self.listStorage[name]['index'] = index
def addIndexList(self, name, maxLength = None, currList = [], currIndex = 0): def addIndexList(self, name, maxLength = None, currList = [], currIndex = -1):
if len(currList) != 0 and (currIndex == -1):
currIndex = 0
self.listStorage[name] = {'list': currList, 'index': currIndex, 'maxLength': maxLength} self.listStorage[name] = {'list': currList, 'index': currIndex, 'maxLength': maxLength}
def isLastIndex(self, name): def isLastIndex(self, name):
if not self.listStorageValid(name): if not self.listStorageValid(name):
@ -68,6 +73,13 @@ class memoryManager():
return False return False
self.listStorage[name]['index'] = 0 self.listStorage[name]['index'] = 0
return True return True
def getIndexListLen(self, name):
if not self.listStorageValid(name):
return 0
if self.isIndexListEmpty(name):
self.listStorage[name]['index'] = -1
return 0
return len(self.listStorage[name]['index'])
def setLastIndex(self, name): def setLastIndex(self, name):
if not self.listStorageValid(name): if not self.listStorageValid(name):
return False return False
@ -103,6 +115,7 @@ class memoryManager():
if currIndex == -1: if currIndex == -1:
return None return None
try: try:
print(self.listStorage[name]['list'])
return self.listStorage[name]['list'][currIndex] return self.listStorage[name]['list'][currIndex]
except: except:
return None return None