summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Resch <andrewresch@gmail.com>2009-10-31 18:52:52 +0000
committerAndrew Resch <andrewresch@gmail.com>2009-10-31 18:52:52 +0000
commit09ae4fbb72353e40af4beeaa7610dbdcf0b5179b (patch)
tree6e313943274b0c1272ec34cf56792f945b691193
parent6e063e7c8540ff18392ca60dfcf83fc39ab5a362 (diff)
downloaddeluge-09ae4fbb72353e40af4beeaa7610dbdcf0b5179b.tar.gz
deluge-09ae4fbb72353e40af4beeaa7610dbdcf0b5179b.tar.bz2
deluge-09ae4fbb72353e40af4beeaa7610dbdcf0b5179b.zip
Improve 'info' command draw speed
-rw-r--r--ChangeLog1
-rw-r--r--deluge/ui/console/commands/info.py4
-rw-r--r--deluge/ui/console/main.py15
-rw-r--r--deluge/ui/console/screen.py11
4 files changed, 27 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ae6023851..a939ceb53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,7 @@
* Fix displaying non-ascii strings
* Fix #1052 crash when issuing commands while not connected to a daemon
* Fix crash when string length makes line longer than terminal width
+ * Improve 'info' command draw speed
=== Deluge 1.2.0_rc2 (25 October 2009) ===
==== GtkUI ====
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):
"""