From 5059013009a2b0784cc2f42fdb06c5d0822ff1e0 Mon Sep 17 00:00:00 2001 From: Chrys Date: Mon, 30 Oct 2017 20:59:56 +0100 Subject: [PATCH] WIP move clipboards to memoryManager --- src/fenrir/commands/commands/{ => WIP}/clear_clipboard.py | 4 ++-- .../commands/{ => WIP}/copy_last_echo_to_clipboard.py | 0 .../commands/{ => WIP}/copy_marked_to_clipboard.py | 0 src/fenrir/commands/commands/{ => WIP}/curr_clipboard.py | 0 .../commands/{ => WIP}/export_clipboard_to_file.py | 0 .../commands/commands/{ => WIP}/export_clipboard_to_x.py | 0 src/fenrir/commands/commands/{ => WIP}/first_clipboard.py | 0 .../commands/{ => WIP}/import_clipboard_from_file.py | 0 src/fenrir/commands/commands/{ => WIP}/last_clipboard.py | 0 src/fenrir/commands/commands/{ => WIP}/next_clipboard.py | 0 src/fenrir/commands/commands/{ => WIP}/paste_clipboard.py | 0 src/fenrir/commands/commands/{ => WIP}/prev_clipboard.py | 0 src/fenrir/core/memoryManager.py | 8 ++++++-- 13 files changed, 8 insertions(+), 4 deletions(-) rename src/fenrir/commands/commands/{ => WIP}/clear_clipboard.py (67%) rename src/fenrir/commands/commands/{ => WIP}/copy_last_echo_to_clipboard.py (100%) rename src/fenrir/commands/commands/{ => WIP}/copy_marked_to_clipboard.py (100%) rename src/fenrir/commands/commands/{ => WIP}/curr_clipboard.py (100%) rename src/fenrir/commands/commands/{ => WIP}/export_clipboard_to_file.py (100%) rename src/fenrir/commands/commands/{ => WIP}/export_clipboard_to_x.py (100%) rename src/fenrir/commands/commands/{ => WIP}/first_clipboard.py (100%) rename src/fenrir/commands/commands/{ => WIP}/import_clipboard_from_file.py (100%) rename src/fenrir/commands/commands/{ => WIP}/last_clipboard.py (100%) rename src/fenrir/commands/commands/{ => WIP}/next_clipboard.py (100%) rename src/fenrir/commands/commands/{ => WIP}/paste_clipboard.py (100%) rename src/fenrir/commands/commands/{ => WIP}/prev_clipboard.py (100%) diff --git a/src/fenrir/commands/commands/clear_clipboard.py b/src/fenrir/commands/commands/WIP/clear_clipboard.py similarity index 67% rename from src/fenrir/commands/commands/clear_clipboard.py rename to src/fenrir/commands/commands/WIP/clear_clipboard.py index 3abe1257..2d9f2564 100644 --- a/src/fenrir/commands/commands/clear_clipboard.py +++ b/src/fenrir/commands/commands/WIP/clear_clipboard.py @@ -11,14 +11,14 @@ class command(): 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 _('clears the currently selected clipboard') def run(self): - self.env['commandBuffer']['currClipboard'] = -1 - del self.env['commandBuffer']['clipboard'][:] + self.env['runtime']['memoryManager'].clearCurrentIndexList('clipboardHistory') self.env['runtime']['outputManager'].presentText(_('clipboard cleared'), interrupt=True) return def setCallback(self, callback): diff --git a/src/fenrir/commands/commands/copy_last_echo_to_clipboard.py b/src/fenrir/commands/commands/WIP/copy_last_echo_to_clipboard.py similarity index 100% rename from src/fenrir/commands/commands/copy_last_echo_to_clipboard.py rename to src/fenrir/commands/commands/WIP/copy_last_echo_to_clipboard.py diff --git a/src/fenrir/commands/commands/copy_marked_to_clipboard.py b/src/fenrir/commands/commands/WIP/copy_marked_to_clipboard.py similarity index 100% rename from src/fenrir/commands/commands/copy_marked_to_clipboard.py rename to src/fenrir/commands/commands/WIP/copy_marked_to_clipboard.py diff --git a/src/fenrir/commands/commands/curr_clipboard.py b/src/fenrir/commands/commands/WIP/curr_clipboard.py similarity index 100% rename from src/fenrir/commands/commands/curr_clipboard.py rename to src/fenrir/commands/commands/WIP/curr_clipboard.py diff --git a/src/fenrir/commands/commands/export_clipboard_to_file.py b/src/fenrir/commands/commands/WIP/export_clipboard_to_file.py similarity index 100% rename from src/fenrir/commands/commands/export_clipboard_to_file.py rename to src/fenrir/commands/commands/WIP/export_clipboard_to_file.py diff --git a/src/fenrir/commands/commands/export_clipboard_to_x.py b/src/fenrir/commands/commands/WIP/export_clipboard_to_x.py similarity index 100% rename from src/fenrir/commands/commands/export_clipboard_to_x.py rename to src/fenrir/commands/commands/WIP/export_clipboard_to_x.py diff --git a/src/fenrir/commands/commands/first_clipboard.py b/src/fenrir/commands/commands/WIP/first_clipboard.py similarity index 100% rename from src/fenrir/commands/commands/first_clipboard.py rename to src/fenrir/commands/commands/WIP/first_clipboard.py diff --git a/src/fenrir/commands/commands/import_clipboard_from_file.py b/src/fenrir/commands/commands/WIP/import_clipboard_from_file.py similarity index 100% rename from src/fenrir/commands/commands/import_clipboard_from_file.py rename to src/fenrir/commands/commands/WIP/import_clipboard_from_file.py diff --git a/src/fenrir/commands/commands/last_clipboard.py b/src/fenrir/commands/commands/WIP/last_clipboard.py similarity index 100% rename from src/fenrir/commands/commands/last_clipboard.py rename to src/fenrir/commands/commands/WIP/last_clipboard.py diff --git a/src/fenrir/commands/commands/next_clipboard.py b/src/fenrir/commands/commands/WIP/next_clipboard.py similarity index 100% rename from src/fenrir/commands/commands/next_clipboard.py rename to src/fenrir/commands/commands/WIP/next_clipboard.py diff --git a/src/fenrir/commands/commands/paste_clipboard.py b/src/fenrir/commands/commands/WIP/paste_clipboard.py similarity index 100% rename from src/fenrir/commands/commands/paste_clipboard.py rename to src/fenrir/commands/commands/WIP/paste_clipboard.py diff --git a/src/fenrir/commands/commands/prev_clipboard.py b/src/fenrir/commands/commands/WIP/prev_clipboard.py similarity index 100% rename from src/fenrir/commands/commands/prev_clipboard.py rename to src/fenrir/commands/commands/WIP/prev_clipboard.py diff --git a/src/fenrir/core/memoryManager.py b/src/fenrir/core/memoryManager.py index 5fc6a0e2..b56235a6 100644 --- a/src/fenrir/core/memoryManager.py +++ b/src/fenrir/core/memoryManager.py @@ -14,8 +14,12 @@ class memoryManager(): self.env = environment def shutdown(self): pass - def addValueToFirstIndex(self, name, value): - pass + def addValueToFirstIndex(self, name, value, index = 0): + 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): self.listStorage[name] = {'list': currList, 'index': currIndex, 'maxLength': maxLength} def isLastIndex(self, name):