/[xmltv_parser]/trunk/xmltv_parser/main.cs
ViewVC logotype

Diff of /trunk/xmltv_parser/main.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/xmltv_parser/main.cs	2013/03/08 02:44:25	41
+++ trunk/xmltv_parser/main.cs	2013/03/08 03:01:48	42
@@ -17,6 +17,11 @@
 {
     public partial class main : Form
     {
+        private bool IsUnix
+        {
+            get { return System.Environment.OSVersion.Platform == PlatformID.Unix; }
+        }
+
         public main()
         {
             InitializeComponent();
@@ -26,20 +31,39 @@
         }
 
         StringBuilder log_flusher = new StringBuilder();
+        bool HAVE_CR = false;
         void Log_OnFlush(object sender, LoggerOnFlushEventArgs e)
         {
-            //Console.Write(e.Buffer);         
+            
             log_flusher.Append(e.Buffer);
-            if(e.Buffer == System.Environment.NewLine[0])
+            if (IsUnix)
             {
-                OnLogFlush(log_flusher.ToString().TrimEnd(new char[] { System.Environment.NewLine[0] }).TrimStart(new char[]{'\n'}));
-                log_flusher = new StringBuilder();
+                if (e.Buffer == System.Environment.NewLine[0])
+                {
+                    OnLogFlush(log_flusher.ToString());
+                    log_flusher = new StringBuilder();
+                }
+            }
+            else
+            {                
+                if (e.Buffer == System.Environment.NewLine[0])
+                {
+                    HAVE_CR = true;
+                }
+                if (e.Buffer == System.Environment.NewLine[1] && HAVE_CR)
+                {
+                    OnLogFlush(log_flusher.ToString().TrimStart(new char[] { System.Environment.NewLine[1] }));
+                    log_flusher = new StringBuilder();
+                    HAVE_CR = false;
+                }
             }
+            
         }
 
         void OnLogFlush(string logmessage)
         {
-            txtStatus.Text = logmessage;
+            Console.Write(logmessage);        
+            txtStatus.Text = logmessage.Replace(System.Environment.NewLine, "");
             Thread.Sleep(100);
         }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22