Diff of /plugins/logger.py [17c6bf] .. [82ddff] Maximize Restore

  Switch to side-by-side view

--- a/plugins/logger.py
+++ b/plugins/logger.py
@@ -1,9 +1,16 @@
 
 import time
 import sys
+import os
+import re
 import wx
 import cStringIO
 import Queue
+
+
+lerexp = re.compile('(\r\n)|(\r)|(\n)')
+def fixle(st):
+    return lerexp.sub(os.linesep, st)
 
 class pseudo_logger:
     def __init__(self):
@@ -11,8 +18,7 @@
         self.softspace = 0
         self.lg = 1
         self.lt = None
-        sys.stdout = self
-        sys.stderr = self
+        sys.stdout = sys.stderr = self
 
     def write(self, data):
         ## print >>sys.__stdout__, repr(data), self.softspace
@@ -23,7 +29,7 @@
             sys.__stdout__.write(x)
         
         self.lg = data[-1:] == '\n'
-        x = data.replace('\r', '').replace('\n', '\r\n')
+        x = fixle(data)
         self.buffer.write(x)
         sys.__stdout__.write(x.encode('utf8'))
     
@@ -34,16 +40,16 @@
 
 class logger(wx.TextCtrl):
     def __init__(self, parent):
+        global l
         wx.TextCtrl.__init__(self, parent, -1, style=wx.TE_READONLY|wx.TE_MULTILINE|wx.TE_RICH)
         self.softspace = 0
         self.lg = 1
         self.lt = None
-        sys.stdout = self
-        sys.stderr = self
+        sys.stdout = sys.stderr = self
         l.buffer.seek(0)
-        self.AppendText(l.buffer.read())
-        del globals()['l']
+        wx.TextCtrl.AppendText(self, l.buffer.read())
         self.data = Queue.Queue()
+        l = self
     
     def write(self, data):
         ## print >>sys.__stdout__, repr(data), self.softspace
@@ -57,7 +63,7 @@
                 pass
             
         self.lg = data[-1:] == '\n'
-        x = data.replace('\r', '').replace('\n', '\r\n')
+        x = fixle(data)
         self.data.put(x)
         try:
             sys.__stdout__.write(data.encode('utf8'))
@@ -73,4 +79,7 @@
     
     def handle_writes(self):
         while self.data.qsize():
-            self.AppendText(self.data.get())
+            wx.TextCtrl.AppendText(self, self.data.get())
+    
+    def AppendText(self, txt):
+        self.write(txt)