Index: trunk/SophyaPI/PI/piapplgen.h
===================================================================
--- trunk/SophyaPI/PI/piapplgen.h	(revision 80)
+++ trunk/SophyaPI/PI/piapplgen.h	(revision 81)
@@ -33,5 +33,6 @@
         virtual int               PrefYSize() = 0;
 
-        virtual void              RedirectSdtOut(PIConsole* cons) = 0;
+        virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def)  = 0;
+        virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital) = 0;
 
 protected:
Index: trunk/SophyaPI/PI/piapplx.cc
===================================================================
--- trunk/SophyaPI/PI/piapplx.cc	(revision 80)
+++ trunk/SophyaPI/PI/piapplx.cc	(revision 81)
@@ -159,26 +159,30 @@
 
 /* Call-Back - Fonction privee de ce fichier */
-static void redirectstdout_callback(XtPointer, int *, XtInputId*);
-
-static PIConsole* curconstdout = NULL;
-
-static void redirectstdout_callback(XtPointer /*cld*/, int * fd, XtInputId* /*iid*/)
+static void redirectstream_callback(XtPointer, int *, XtInputId*);
+
+static PIConsole* consstream[2] = {NULL, NULL};
+static unsigned char streamva[2] = { PIVA_Def, PIVA_Ital};
+static int streamno[2] = {0,1};
+
+static void redirectstream_callback(XtPointer cld, int * fd, XtInputId* /*iid*/)
 {
 char buff[128];
 int nr;
+
+int idx = *((int*)cld);
+if (idx != 1) idx = 0; 
 while ( (nr=read(*fd, buff, 127)) > 0 ) {
-  buff[nr] = '\0'; curconstdout->AddStr(buff, PIVA_Def, false);
-  }
-
-curconstdout->Refresh();
-}
-
-
-/* --Methode-- */
-void PIApplicationX::RedirectSdtOut(PIConsole* cons)
+  buff[nr] = '\0'; consstream[idx]->AddStr(buff, streamva[idx], false);
+  }
+consstream[idx]->Refresh();
+}
+
+/* --Methode-- */
+void PIApplicationX::RedirectOutStream(PIConsole* cons, unsigned char va)
 {
 if (!cons) return;
-if (curconstdout) { curconstdout = cons; return; }
-curconstdout = cons;
+
+if (consstream[0]) { consstream[0] = cons; streamva[0] = va; return; }
+consstream[0] = cons; streamva[0] = va;
 
 int p[2];
@@ -190,4 +194,24 @@
 fcntl(p[0], F_SETFL, O_NONBLOCK);
 
-XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstdout_callback, NULL);
-}
+XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) streamno);
+}
+
+/* --Methode-- */
+void PIApplicationX::RedirectErrStream(PIConsole* cons, unsigned char va)
+{
+if (!cons) return;
+
+if (consstream[1]) { consstream[1] = cons; streamva[1] = va; return; }
+consstream[1] = cons; streamva[1] = va;
+
+int p[2];
+pipe(p);
+// Redirection de stderr :
+close(2);
+dup(p[1]);
+close(p[1]);
+fcntl(p[0], F_SETFL, O_NONBLOCK);
+
+XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) (streamno+1));
+}
+
Index: trunk/SophyaPI/PI/piapplx.h
===================================================================
--- trunk/SophyaPI/PI/piapplx.h	(revision 80)
+++ trunk/SophyaPI/PI/piapplx.h	(revision 81)
@@ -21,5 +21,7 @@
   virtual int               PrefXSize();
   virtual int               PrefYSize();
-  virtual void              RedirectSdtOut(PIConsole* cons);
+
+  virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
+  virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital);
 
   PIContainer*              MBCont() { return intcont; }
Index: trunk/SophyaPI/PI/picons.cc
===================================================================
--- trunk/SophyaPI/PI/picons.cc	(revision 80)
+++ trunk/SophyaPI/PI/picons.cc	(revision 81)
@@ -700,5 +700,5 @@
 for(j=0; j<j1; j++) {
   mText[mLPo[mNL-1]+j] = mPrompt[j];
-  mAtt[mLPo[mNL-1]+j] = PIVA_Ital;
+  mAtt[mLPo[mNL-1]+j] = PIVA_Def;
 //  strg[j] = mPrompt[j];    debug
   }  
@@ -784,10 +784,4 @@
 // printf("**DBG** Save: C= %d %d  L = %d %d \n", mCPbeginC, mCPendC, mCPbeginL, mCPendL);
 
-if (!ClaimSelection()) { 
-  mCPbeginC = mCPendC = -1;
-  mCPbeginL = mCPendL = -1;
-  return;
-  }
-
 
 // On transforme la position sur la fenetre en position en caracteres ds les buffers
@@ -808,4 +802,10 @@
 
 if ( (nc > 0) && (nl > 0) ) {
+if (!ClaimSelection()) { 
+  mCPbeginC = mCPendC = -1;
+  mCPbeginL = mCPendL = -1;
+  if (l2 > -1) DisplayLines(mWGrC, l1, l2);  
+  return;
+  }
   l = (mCPendC-mCPbeginC+1) * (mCPendL-mCPbeginL);
   if (l < 0) l = 0;
