WIP move clipboards to memoryManager

This commit is contained in:
Chrys 2017-10-30 20:59:56 +01:00
parent dec4974fb0
commit 5059013009
13 changed files with 8 additions and 4 deletions

View File

@ -11,14 +11,14 @@ class command():
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment
self.env['runtime']['memoryManager'].addIndexList('clipboardHistory', self.env['runtime']['settingsManager'].getSettingAsInt('general', 'numberOfClipboards'))
def shutdown(self): def shutdown(self):
pass pass
def getDescription(self): def getDescription(self):
return _('clears the currently selected clipboard') return _('clears the currently selected clipboard')
def run(self): def run(self):
self.env['commandBuffer']['currClipboard'] = -1 self.env['runtime']['memoryManager'].clearCurrentIndexList('clipboardHistory')
del self.env['commandBuffer']['clipboard'][:]
self.env['runtime']['outputManager'].presentText(_('clipboard cleared'), interrupt=True) self.env['runtime']['outputManager'].presentText(_('clipboard cleared'), interrupt=True)
return return
def setCallback(self, callback): def setCallback(self, callback):

View File

@ -14,8 +14,12 @@ class memoryManager():
self.env = environment self.env = environment
def shutdown(self): def shutdown(self):
pass pass
def addValueToFirstIndex(self, name, value): def addValueToFirstIndex(self, name, value, index = 0):
pass if self.listStorage[name]['maxLength'] != None:
self.listStorage[name]['list'] = [value] + self.listStorage[name]['list']
else:
self.listStorage[name]['list'] = [value] + self.listStorage[name]['list'][:self.listStorage[name]['maxLength'] -1]
self.listStorage[name]['index'] = index
def addIndexList(self, name, maxLength = None, currList = [], currIndex = 0): def addIndexList(self, name, maxLength = None, currList = [], 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):