From 1391f206586fd455192512d4d6fbd67fe332c5e7 Mon Sep 17 00:00:00 2001 From: Asmageddon Date: Thu, 1 Mar 2012 21:50:08 +0100 Subject: [PATCH] Add option to not store duplicate input in command history for legacy mode. --- deluge/ui/console/modes/alltorrents.py | 5 +++-- deluge/ui/console/modes/legacy.py | 13 +++++++++++-- deluge/ui/console/modes/preference_panes.py | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/deluge/ui/console/modes/alltorrents.py b/deluge/ui/console/modes/alltorrents.py index 7d9ef531c..3dab24076 100644 --- a/deluge/ui/console/modes/alltorrents.py +++ b/deluge/ui/console/modes/alltorrents.py @@ -168,7 +168,8 @@ DEFAULT_PREFS = { "downloaded_width":13, "uploaded_width":13, "owner_width":10, - "disable_three_dots": False + "disable_three_dots": False, + "ignore_duplicate_lines": False } column_pref_names = ["queue","name","size","state", @@ -461,7 +462,7 @@ class AllTorrents(BaseMode, component.Component): if arg and True in arg[0]: self.stdscr.clear() if not self.legacy_mode: - self.legacy_mode = Legacy(self.stdscr,self.encoding) + self.legacy_mode = Legacy(self.stdscr,self.config,self.encoding) component.get("ConsoleUI").set_mode(self.legacy_mode) self.legacy_mode.refresh() curses.curs_set(2) diff --git a/deluge/ui/console/modes/legacy.py b/deluge/ui/console/modes/legacy.py index c59654dda..2151f7888 100644 --- a/deluge/ui/console/modes/legacy.py +++ b/deluge/ui/console/modes/legacy.py @@ -54,7 +54,7 @@ LINES_BUFFER_SIZE = 5000 INPUT_HISTORY_SIZE = 500 class Legacy(BaseMode): - def __init__(self, stdscr, encoding=None): + def __init__(self, stdscr, console_config, encoding=None): self.batch_write = False self.lines = [] @@ -79,6 +79,8 @@ class Legacy(BaseMode): # Get a handle to the main console self.console = component.get("ConsoleUI") + self.console_config = console_config + # show the cursor curses.curs_set(2) @@ -118,7 +120,14 @@ class Legacy(BaseMode): # Remove the oldest input history if the max history size # is reached. del self.input_history[0] - self.input_history.append(self.input) + if self.console_config["ignore_duplicate_lines"]: + if len(self.input_history) > 0: + if self.input_history[-1] != self.input: + self.input_history.append(self.input) + else: + self.input_history.append(self.input) + else: + self.input_history.append(self.input) self.input_history_index = len(self.input_history) self.input = "" self.input_incomplete = "" diff --git a/deluge/ui/console/modes/preference_panes.py b/deluge/ui/console/modes/preference_panes.py index 848ea8bc6..49862d8b4 100644 --- a/deluge/ui/console/modes/preference_panes.py +++ b/deluge/ui/console/modes/preference_panes.py @@ -312,6 +312,7 @@ class InterfacePane(BasePane): BasePane.__init__(self,offset,parent,width) self.add_header("General") self.add_checked_input("disable_three_dots","Do not append three dots symbol when trimming columns",parent.console_config["disable_three_dots"]) + self.add_checked_input("ignore_duplicate_lines","Do not store duplicate input in history",parent.console_config["ignore_duplicate_lines"]) self.add_header("Columns To Display") for cpn in deluge.ui.console.modes.alltorrents.column_pref_names: pn = "show_%s"%cpn