Changeset 81 in Sophya


Ignore:
Timestamp:
Feb 24, 1998, 7:07:46 PM (28 years ago)
Author:
ansari
Message:

Redirection StdErr Reza 24/02/98

Location:
trunk/SophyaPI/PI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/piapplgen.h

    r78 r81  
    3333        virtual int               PrefYSize() = 0;
    3434
    35         virtual void              RedirectSdtOut(PIConsole* cons) = 0;
     35        virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def)  = 0;
     36        virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital) = 0;
    3637
    3738protected:
  • trunk/SophyaPI/PI/piapplx.cc

    r78 r81  
    159159
    160160/* Call-Back - Fonction privee de ce fichier */
    161 static void redirectstdout_callback(XtPointer, int *, XtInputId*);
    162 
    163 static PIConsole* curconstdout = NULL;
    164 
    165 static void redirectstdout_callback(XtPointer /*cld*/, int * fd, XtInputId* /*iid*/)
     161static void redirectstream_callback(XtPointer, int *, XtInputId*);
     162
     163static PIConsole* consstream[2] = {NULL, NULL};
     164static unsigned char streamva[2] = { PIVA_Def, PIVA_Ital};
     165static int streamno[2] = {0,1};
     166
     167static void redirectstream_callback(XtPointer cld, int * fd, XtInputId* /*iid*/)
    166168{
    167169char buff[128];
    168170int nr;
     171
     172int idx = *((int*)cld);
     173if (idx != 1) idx = 0;
    169174while ( (nr=read(*fd, buff, 127)) > 0 ) {
    170   buff[nr] = '\0'; curconstdout->AddStr(buff, PIVA_Def, false);
    171   }
    172 
    173 curconstdout->Refresh();
    174 }
    175 
    176 
    177 /* --Methode-- */
    178 void PIApplicationX::RedirectSdtOut(PIConsole* cons)
     175  buff[nr] = '\0'; consstream[idx]->AddStr(buff, streamva[idx], false);
     176  }
     177consstream[idx]->Refresh();
     178}
     179
     180/* --Methode-- */
     181void PIApplicationX::RedirectOutStream(PIConsole* cons, unsigned char va)
    179182{
    180183if (!cons) return;
    181 if (curconstdout) { curconstdout = cons; return; }
    182 curconstdout = cons;
     184
     185if (consstream[0]) { consstream[0] = cons; streamva[0] = va; return; }
     186consstream[0] = cons; streamva[0] = va;
    183187
    184188int p[2];
     
    190194fcntl(p[0], F_SETFL, O_NONBLOCK);
    191195
    192 XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstdout_callback, NULL);
    193 }
     196XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) streamno);
     197}
     198
     199/* --Methode-- */
     200void PIApplicationX::RedirectErrStream(PIConsole* cons, unsigned char va)
     201{
     202if (!cons) return;
     203
     204if (consstream[1]) { consstream[1] = cons; streamva[1] = va; return; }
     205consstream[1] = cons; streamva[1] = va;
     206
     207int p[2];
     208pipe(p);
     209// Redirection de stderr :
     210close(2);
     211dup(p[1]);
     212close(p[1]);
     213fcntl(p[0], F_SETFL, O_NONBLOCK);
     214
     215XtAddInput(p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) (streamno+1));
     216}
     217
  • trunk/SophyaPI/PI/piapplx.h

    r78 r81  
    2121  virtual int               PrefXSize();
    2222  virtual int               PrefYSize();
    23   virtual void              RedirectSdtOut(PIConsole* cons);
     23
     24  virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
     25  virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital);
    2426
    2527  PIContainer*              MBCont() { return intcont; }
  • trunk/SophyaPI/PI/picons.cc

    r80 r81  
    700700for(j=0; j<j1; j++) {
    701701  mText[mLPo[mNL-1]+j] = mPrompt[j];
    702   mAtt[mLPo[mNL-1]+j] = PIVA_Ital;
     702  mAtt[mLPo[mNL-1]+j] = PIVA_Def;
    703703//  strg[j] = mPrompt[j];    debug
    704704  } 
     
    784784// printf("**DBG** Save: C= %d %d  L = %d %d \n", mCPbeginC, mCPendC, mCPbeginL, mCPendL);
    785785
    786 if (!ClaimSelection()) {
    787   mCPbeginC = mCPendC = -1;
    788   mCPbeginL = mCPendL = -1;
    789   return;
    790   }
    791 
    792786
    793787// On transforme la position sur la fenetre en position en caracteres ds les buffers
     
    808802
    809803if ( (nc > 0) && (nl > 0) ) {
     804if (!ClaimSelection()) {
     805  mCPbeginC = mCPendC = -1;
     806  mCPbeginL = mCPendL = -1;
     807  if (l2 > -1) DisplayLines(mWGrC, l1, l2); 
     808  return;
     809  }
    810810  l = (mCPendC-mCPbeginC+1) * (mCPendL-mCPbeginL);
    811811  if (l < 0) l = 0;
Note: See TracChangeset for help on using the changeset viewer.