diff --git a/deluge/ui/console/commands/info.py b/deluge/ui/console/commands/info.py index 57bd4e38d..8a478a87d 100644 --- a/deluge/ui/console/commands/info.py +++ b/deluge/ui/console/commands/info.py @@ -136,6 +136,8 @@ class Command(BaseCommand): :param verbose: bool, if true, we print out more information about the the torrent """ + self.console.set_batch_write(True) + self.console.write(" ") self.console.write("{!info!}Name: {!input!}%s" % (status["name"])) self.console.write("{!info!}ID: {!input!}%s" % (torrent_id)) @@ -223,6 +225,8 @@ class Command(BaseCommand): self.console.write(s[:-1]) + self.console.set_batch_write(False) + def complete(self, line): # We use the ConsoleUI torrent tab complete method return component.get("ConsoleUI").tab_complete_torrent(line) diff --git a/deluge/ui/console/main.py b/deluge/ui/console/main.py index 91b29c463..e4b72f243 100644 --- a/deluge/ui/console/main.py +++ b/deluge/ui/console/main.py @@ -237,6 +237,19 @@ class ConsoleUI(component.Component): def update(self): pass + def set_batch_write(self, batch): + """ + When this is set the screen is not refreshed after a `:meth:write` until + this is set to False. + + :param batch: set True to prevent screen refreshes after a `:meth:write` + :type batch: bool + + """ + self.batch_write = batch + if not batch: + self.screen.refresh() + def write(self, line): """ Writes a line out depending on if we're in interactive mode or not. @@ -245,7 +258,7 @@ class ConsoleUI(component.Component): """ if self.interactive: - self.screen.add_line(line) + self.screen.add_line(line, not self.batch_write) else: print(colors.strip_colors(line)) diff --git a/deluge/ui/console/screen.py b/deluge/ui/console/screen.py index 2cee70bbf..2c74045a5 100644 --- a/deluge/ui/console/screen.py +++ b/deluge/ui/console/screen.py @@ -129,7 +129,7 @@ class Screen(CursesStdIO): def connectionLost(self, reason): self.close() - def add_line(self, text): + def add_line(self, text, refresh=True): """ Add a line to the screen. This will be showed between the two bars. The text can be formatted with color using the following format: @@ -149,7 +149,11 @@ class Screen(CursesStdIO): "{!info!}I am some info text!" "{!error!}Uh oh!" - :param text: str, the text to show + :param text: the text to show + :type text: string + :param refresh: if True, the screen will refresh after the line is added + :type refresh: bool + """ def get_line_chunks(line): @@ -219,7 +223,8 @@ class Screen(CursesStdIO): # Remove the oldest line if the max buffer size has been reached del self.lines[0] - self.refresh() + if refresh: + self.refresh() def add_string(self, row, string): """