Index: /trunk/SophyaPI/PI/piapplgen.h
===================================================================
--- /trunk/SophyaPI/PI/piapplgen.h	(revision 77)
+++ /trunk/SophyaPI/PI/piapplgen.h	(revision 78)
@@ -6,4 +6,6 @@
 #include PICONT_H
 #include PIMENUBAR_H
+
+#include "picons.h"
 
 class PIApplicationGen : public PIMsgHandler {
@@ -31,4 +33,6 @@
         virtual int               PrefYSize() = 0;
 
+        virtual void              RedirectSdtOut(PIConsole* cons) = 0;
+
 protected:
     PIContainer               *topcont;
Index: /trunk/SophyaPI/PI/piapplx.cc
===================================================================
--- /trunk/SophyaPI/PI/piapplx.cc	(revision 77)
+++ /trunk/SophyaPI/PI/piapplx.cc	(revision 78)
@@ -5,5 +5,10 @@
 
 
-#define DEBUG_APPLX
+// Pour rediriger stdout 
+#include <unistd.h>
+#include <fcntl.h>
+
+
+// #define DEBUG_APPLX
 
 static Cursor a_curs[3];
@@ -153,2 +158,36 @@
 
 
+/* 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*/)
+{
+char buff[128];
+int nr;
+while ( (nr=read(*fd, buff, 127)) > 0 ) {
+  buff[nr] = '\0'; curconstdout->AddStr(buff, PIVA_Def, false);
+  }
+
+curconstdout->Refresh();
+}
+
+
+/* --Methode-- */
+void PIApplicationX::RedirectSdtOut(PIConsole* cons)
+{
+if (!cons) return;
+if (curconstdout) { curconstdout = cons; return; }
+curconstdout = cons;
+
+int p[2];
+pipe(p);
+// Redirection de stdout :
+close(1);
+dup(p[1]);
+close(p[1]);
+fcntl(p[0], F_SETFL, O_NONBLOCK);
+
+XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstdout_callback, NULL);
+}
Index: /trunk/SophyaPI/PI/piapplx.h
===================================================================
--- /trunk/SophyaPI/PI/piapplx.h	(revision 77)
+++ /trunk/SophyaPI/PI/piapplx.h	(revision 78)
@@ -8,19 +8,20 @@
 class PIApplicationX : public PIApplicationGen {
 public:
-		  PIApplicationX(int sx=200, int sy=30, int narg=0, char *arg[]=NULL);
+  		            PIApplicationX(int sx=200, int sy=30, int narg=0, char *arg[]=NULL);
 
-  virtual	  ~PIApplicationX();
+  virtual	            ~PIApplicationX();
 	
-  virtual void    Run();
-  virtual void    Stop() { mStop = false; }
+  virtual void              Run();
+  virtual void              Stop() { mStop = false; }
 
-  virtual void    SetReady();
-  virtual void    SetBusy(); 
-  virtual void    SetBlocked();
+  virtual void              SetReady();
+  virtual void              SetBusy(); 
+  virtual void              SetBlocked();
 
-  virtual int     PrefXSize();
-  virtual int     PrefYSize();
+  virtual int               PrefXSize();
+  virtual int               PrefYSize();
+  virtual void              RedirectSdtOut(PIConsole* cons);
 
-  PIContainer*    MBCont() { return intcont; }
+  PIContainer*              MBCont() { return intcont; }
 protected:
   PIWdg * topwdg;
Index: /trunk/SophyaPI/PI/picons.cc
===================================================================
--- /trunk/SophyaPI/PI/picons.cc	(revision 77)
+++ /trunk/SophyaPI/PI/picons.cc	(revision 78)
@@ -8,5 +8,5 @@
 
 
-#define DEBUG_PICONS 1
+// #define DEBUG_PICONS 1
 
 //  Le menu qui va servir a changer de fontes, couleurs, ...
@@ -65,5 +65,5 @@
 
 ActivateKeyboard();
-ActivateButton(1); // Pour permettre la selection 
+// ActivateButton(1);   Pour permettre la selection 
 ActivateButton(3); // Pour afficher le menu des options (Fontes/couleur)
 Manage();
@@ -151,4 +151,5 @@
 mOffL = 0;
 if (mScb) {
+  mScb->SetMinMax(0, NbLines()-1);
   mScb->SetSize(WindNbLines());
   mScb->SetValue(NbLines()-WindNbLines()-1);
@@ -225,5 +226,4 @@
   }
 mOffL = 0;
-if (mScb)  mScb->SetValue(NbLines()-WindNbLines()-1);
 }
 
@@ -240,9 +240,7 @@
 void PIConsole::Keyboard(int key, PIKeyModifier kmod)
 {
-char c = ' ' ;
-if (isprint(key))  c = key;
-
-//printf("PIConsole::Keyboard: Key= %d (%c) Mod= %d  NCmdL=%d (%d,%d)\n", 
-//       key, c, (int)kmod, mNCmdL, mCCP, mCLC);
+
+
+#ifdef DEBUG_PICONS
 if ( (kmod == PIKM_Alt) ) {
   char buff[128];
@@ -300,4 +298,5 @@
   }
 }
+#endif
 
 if (mNCmdL < 1)  return;
@@ -305,10 +304,32 @@
 int k;
 bool fgfk = false;
-if (kmod == PIKM_Blank) {
+
+if (kmod == PIKM_Cntl) {
+  switch (key) {
+    case 'A' :
+    case 'a' :
+      mCCP = 0;
+      break;
+    case 'E' :
+    case 'e' :
+      mCCP = mCLC;
+      break;
+    case 'K' :
+    case 'k' :
+      mCLC = mCCP;
+      break;
+    }
+  }
+
+else if (kmod == PIKM_Alt) {
+  if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller)
+  }
+
+else if (kmod == PIKM_Blank) {
   switch (key) {
     case PIK_Return :    
     case PIK_Enter :
       mCmdStr[mCLC] = '\0';
-      printf("Process()-Debug- <CR/Enter> CmdStr= %s (L=%d)\n", mCmdStr, strlen(mCmdStr) );
+//      printf("Process()-Debug- <CR/Enter> CmdStr= %s (L=%d)\n", mCmdStr, strlen(mCmdStr) );
       Send( Msg(), PIMsg_OK, mCmdStr);
       ClrCmd();
@@ -345,9 +366,9 @@
 
 
-/* --Methode-- */
+/* --Methode-- 
 void PIConsole::But1Press(int x, int y)
 {
-printf("PIConsole::But3Press(%d %d ) \n", x, y);
-}
+printf("PIConsole::But1Press(%d %d ) \n", x, y);
+} */
 
 /* --Methode-- */
@@ -356,4 +377,14 @@
 opmc->SetMsgParent((PIMsgHandler*)this);
 opmc->Show(this, x, y);
+}
+
+/* --Methode-- */
+void PIConsole::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
+{
+if (typ != PICP_string) return;
+int i;
+char *pc = (char *)pdata;
+for(i=0; i<l; i++) CmdAddChar(pc[i]);
+UpdCmdLine();
 }
 
Index: /trunk/SophyaPI/PI/picons.h
===================================================================
--- /trunk/SophyaPI/PI/picons.h	(revision 77)
+++ /trunk/SophyaPI/PI/picons.h	(revision 78)
@@ -39,6 +39,7 @@
   virtual void       Resize();
   virtual void       Keyboard(int key, PIKeyModifier kmod);
-  virtual void       But1Press(int x, int y);
+//  virtual void       But1Press(int x, int y);
   virtual void       But3Press(int x, int y);
+  virtual void       PasteSelection(unsigned int typ, void *pdata, unsigned int l);
 
           void       DebugPrint(int cont=0);
Index: /trunk/SophyaPI/PI/pistdwdgx.cc
===================================================================
--- /trunk/SophyaPI/PI/pistdwdgx.cc	(revision 77)
+++ /trunk/SophyaPI/PI/pistdwdgx.cc	(revision 78)
@@ -468,5 +468,5 @@
 if (min >= max)  max = min+100;
 if (mVal < min)  mVal = min;
-if (mVal > max)  mVal = max;
+if (mVal > max-mSz)  mVal = max-mSz;
 int n=0;
 Arg warg[3];
