Module: deluge
Branch: master
Commit: 81a837faedf7dfddccb5ac3f2837e62e1758fdf2

Author: John Garland <[email protected]>
Date:   Mon Jun  7 19:49:09 2010 +1000

Fix unicode support in console ui (#1307)

---

 deluge/ui/console/screen.py |   20 ++++++--------------
 1 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/deluge/ui/console/screen.py b/deluge/ui/console/screen.py
index a8f7f9a..ad0da73 100644
--- a/deluge/ui/console/screen.py
+++ b/deluge/ui/console/screen.py
@@ -308,7 +308,7 @@ class Screen(CursesStdIO):
         if c == curses.KEY_ENTER or c == 10:
             if self.input:
                 self.add_line(">>> " + self.input)
-                self.command_parser(self.input)
+                self.command_parser(self.input.encode(self.encoding))
                 if len(self.input_history) == INPUT_HISTORY_SIZE:
                     # Remove the oldest input history if the max history size
                     # is reached.
@@ -404,21 +404,13 @@ class Screen(CursesStdIO):
             if c > 31 and c < 256:
                 # Emulate getwch
                 stroke = chr(c)
-
-                uchar = None
-
-                while 1:
+                uchar = ""
+                while not uchar:
                     try:
                         uchar = stroke.decode(self.encoding)
                     except UnicodeDecodeError:
-                        pass
-                    
-                    c = self.stdscr.getch()
-
-                    if c == -1:
-                        break
-
-                    stroke += chr(c) 
+                        c = self.stdscr.getch()
+                        stroke += chr(c)
 
                 if uchar:
                     if self.input_cursor == len(self.input):
@@ -426,7 +418,7 @@ class Screen(CursesStdIO):
                     else:
                         # Insert into string
                         self.input = self.input[:self.input_cursor] + uchar + 
self.input[self.input_cursor:]
-                        
+
                     # Move the cursor forward
                     self.input_cursor += 1
 

-- 
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