Changeset 135 in Sophya for trunk/SophyaPI
- Timestamp:
- Aug 14, 1998, 7:17:15 PM (27 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/piapplgen.cc
r110 r135 116 116 // void RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def) 117 117 // Redirige le flot de sortie ("stdout" sous Unix) vers l'objet 118 // PIConsole "cons". 118 // PIConsole "cons". si "cons==NULL", redirection 119 // sur le flot original. 119 120 // 120 121 // void RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Def) 121 122 // Redirige le flot des messages d'erreur ("stderr" sous Unix) 122 // vers l'objet PIConsole "cons". 123 // vers l'objet PIConsole "cons". si "cons==NULL", redirection 124 // sur le flot original. 123 125 //-- 124 126 -
trunk/SophyaPI/PI/piapplx.cc
r132 r135 8 8 #include <unistd.h> 9 9 #include <fcntl.h> 10 11 #include <iostream.h> 10 12 11 13 … … 218 220 static unsigned char streamva[2] = { PIVA_Def, PIVA_Ital}; 219 221 static int streamno[2] = {0,1}; 222 static XtInputId inputid[2]; 223 static int origfiledes[2]={-1, -1}; // descripteurs de fichiers de depart 224 static bool firstcall[2]={true, true}; // 1er appel a Redirect 220 225 221 226 static void redirectstream_callback(XtPointer cld, int * fd, XtInputId* /*iid*/) … … 226 231 int idx = *((int*)cld); 227 232 if (idx != 1) idx = 0; 233 if (!consstream[idx]) return; 228 234 while ( (nr=read(*fd, buff, 127)) > 0 ) { 229 235 buff[nr] = '\0'; consstream[idx]->AddStr(buff, streamva[idx], false); … … 235 241 void PIApplicationX::RedirectOutStream(PIConsole* cons, unsigned char va) 236 242 { 237 if (!cons) return; 238 239 if (consstream[0]) { consstream[0] = cons; streamva[0] = va; return; } 243 if ( origfiledes[0]<0 ) origfiledes[0] = fcntl(1, F_DUPFD); 244 if ( cons == consstream[0]) return; 245 if ( (consstream[0]) && (cons) ) { consstream[0] = cons; streamva[0] = va; return; } 246 else if (!cons) { 247 consstream[0] = NULL; 248 XtRemoveInput(inputid[0]); 249 dup2(origfiledes[0], 1); 250 return; 251 } 252 240 253 consstream[0] = cons; streamva[0] = va; 241 254 … … 247 260 close(p[1]); 248 261 fcntl(p[0], F_SETFL, O_NONBLOCK); 262 249 263 setlinebuf(stdout); 264 ios::sync_with_stdio(); 250 265 251 266 int szx, szy, szf; 252 267 XtAppContext * appctx = PIXtAppCtx(szx, szy, szf); 253 XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) streamno); 268 inputid[0] = XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, 269 redirectstream_callback, (XtPointer) streamno); 254 270 } 255 271 … … 257 273 void PIApplicationX::RedirectErrStream(PIConsole* cons, unsigned char va) 258 274 { 259 if (!cons) return; 260 261 if (consstream[1]) { consstream[1] = cons; streamva[1] = va; return; } 275 if ( origfiledes[1]<0 ) origfiledes[1] = fcntl(2, F_DUPFD); 276 if ( cons == consstream[1]) return; 277 if ( (consstream[1]) && (cons) ) { consstream[1] = cons; streamva[1] = va; return; } 278 else if (!cons) { 279 consstream[1] = NULL; 280 XtRemoveInput(inputid[1]); 281 dup2(origfiledes[1], 2); 282 return; 283 } 284 262 285 consstream[1] = cons; streamva[1] = va; 263 286 264 287 int p[2]; 265 288 pipe(p); 266 // Redirection de stderr (fid= 0) :289 // Redirection de stderr (fid=2) : 267 290 close(2); 268 291 dup(p[1]); 269 292 close(p[1]); 270 293 fcntl(p[0], F_SETFL, O_NONBLOCK); 294 271 295 setlinebuf(stderr); 296 ios::sync_with_stdio(); 272 297 273 298 int szx, szy, szf; 274 299 XtAppContext * appctx = PIXtAppCtx(szx, szy, szf); 275 XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, redirectstream_callback, (XtPointer) (streamno+1)); 276 } 277 300 inputid[1] = XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, 301 redirectstream_callback, (XtPointer) (streamno+1)); 302 } 303 -
trunk/SophyaPI/PI/piwdgx.cc
r132 r135 30 30 static XFontStruct * stdfnt = NULL; 31 31 32 // Variable globale Widget qui possede la selection pour le copier-coller 33 static PIWdgX* curselwdg = NULL; // Le PIWdg qui possede la selection 34 32 35 /* Nouvelle-Fonction */ 33 36 XtAppContext* PIXtAppCtx(int& szx, int& szy, int& szf) … … 179 182 printf("Debug_PIWdgX::~PIWdgX() %lx %lx \n", (long)this, (long)sdw); 180 183 #endif 184 if (curselwdg == this) { SelectionLost(); curselwdg = NULL; } 181 185 if (!sdw) XtDestroyWidget(sdw); 182 186 } … … 592 596 XtPointer value, unsigned long* len, int* format ); 593 597 594 static PIWdgX* curselwdg = NULL; // Le PIWdg qui possede la selection595 598 static unsigned int curseltype = PICP_string; // Type de selcetion qu'il peut fournir 596 599 static unsigned int reqseltype = PICP_string; // Type de selection demande
Note:
See TracChangeset
for help on using the changeset viewer.