Author: andar

Revision: 5901

Log:
        Improve 'info' command draw speed

Diff:
Modified: branches/1.2_RC/ChangeLog
===================================================================
--- branches/1.2_RC/ChangeLog   2009-10-31 18:44:27 UTC (rev 5900)
+++ branches/1.2_RC/ChangeLog   2009-10-31 18:52:52 UTC (rev 5901)
@@ -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 ====

Modified: branches/1.2_RC/deluge/ui/console/commands/info.py
===================================================================
--- branches/1.2_RC/deluge/ui/console/commands/info.py  2009-10-31 18:44:27 UTC 
(rev 5900)
+++ branches/1.2_RC/deluge/ui/console/commands/info.py  2009-10-31 18:52:52 UTC 
(rev 5901)
@@ -136,6 +136,8 @@
         :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 @@
 
                 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)

Modified: branches/1.2_RC/deluge/ui/console/main.py
===================================================================
--- branches/1.2_RC/deluge/ui/console/main.py   2009-10-31 18:44:27 UTC (rev 
5900)
+++ branches/1.2_RC/deluge/ui/console/main.py   2009-10-31 18:52:52 UTC (rev 
5901)
@@ -237,6 +237,19 @@
     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 @@
 
         """
         if self.interactive:
-            self.screen.add_line(line)
+            self.screen.add_line(line, not self.batch_write)
         else:
             print(colors.strip_colors(line))
 

Modified: branches/1.2_RC/deluge/ui/console/screen.py
===================================================================
--- branches/1.2_RC/deluge/ui/console/screen.py 2009-10-31 18:44:27 UTC (rev 
5900)
+++ branches/1.2_RC/deluge/ui/console/screen.py 2009-10-31 18:52:52 UTC (rev 
5901)
@@ -129,7 +129,7 @@
     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 @@
         "{!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 @@
             # 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):
         """

Modified: trunk/deluge/ui/console/commands/info.py
===================================================================
--- trunk/deluge/ui/console/commands/info.py    2009-10-31 18:44:27 UTC (rev 
5900)
+++ trunk/deluge/ui/console/commands/info.py    2009-10-31 18:52:52 UTC (rev 
5901)
@@ -136,6 +136,8 @@
         :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 @@
 
                 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)

Modified: trunk/deluge/ui/console/main.py
===================================================================
--- trunk/deluge/ui/console/main.py     2009-10-31 18:44:27 UTC (rev 5900)
+++ trunk/deluge/ui/console/main.py     2009-10-31 18:52:52 UTC (rev 5901)
@@ -237,6 +237,19 @@
     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 @@
 
         """
         if self.interactive:
-            self.screen.add_line(line)
+            self.screen.add_line(line, not self.batch_write)
         else:
             print(colors.strip_colors(line))
 

Modified: trunk/deluge/ui/console/screen.py
===================================================================
--- trunk/deluge/ui/console/screen.py   2009-10-31 18:44:27 UTC (rev 5900)
+++ trunk/deluge/ui/console/screen.py   2009-10-31 18:52:52 UTC (rev 5901)
@@ -129,7 +129,7 @@
     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 @@
         "{!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 @@
             # 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):
         """



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to