Spawn.vala
[gitlive] / Spawn.vala
index e904817..32c514a 100644 (file)
@@ -1,7 +1,6 @@
 
 
 using GLib;
-using GString;
 // compile valac 
 
 /// # valac  --pkg gio-2.0  --pkg posix Spawn.vala -o /tmp/Spawn
@@ -401,10 +400,12 @@ public class Spawn : Object
         
         //print(JSON.stringify(ch, null,4));
         while (true) {
-            var buffer = new StringBuffer("");
-            
+            string buffer;
+            size_t term_pos;
+            size_t len;
+            IOStatus status;
             try {
-                var status = ch.read_line( buffer,  term_pos );
+                status = ch.read_line( out buffer,  out len,  out term_pos );
             } catch (Error e) {
                 //FIXme
                 break; // ??
@@ -416,17 +417,22 @@ public class Spawn : Object
                 case GLib.IOStatus.NORMAL:
                
                     //write(fn, x.str);
-                    if (this.listeners[prop]) {
-                        this.listeners[prop].call(this, x.str_return);
+                    //if (this.listeners[prop]) {
+                    //    this.listeners[prop].call(this, x.str_return);
+                    //}
+                    if (ch == this.out_ch) {
+                        this.output += buffer;
+                    } else {
+                        this.stderr += buffer;
                     }
-                    _this[prop] += x.str_return;
-                    if (_this.debug) {
-                        print(prop + ':' + x.str_return.replace(/\n/, ''));
+                    //_this[prop] += x.str_return;
+                    if (this.cfg.debug) {
+                        stdout.printf("%s : %s", prop , str_return);
                     }
-                    if (this.async) {
+                    if (this.cfg.async) {
                         try {
-                            if (imports.gi.Gtk.events_pending()) {
-                                imports.gi.Gtk.main_iteration();
+                            if ( Gtk.events_pending()) {
+                                 Gtk.main_iteration();
                             }
                         } catch(Error e) {