21 #include "processlinemaker.moc" 25 ProcessLineMaker::ProcessLineMaker()
29 ProcessLineMaker::ProcessLineMaker(
const TDEProcess* proc )
31 connect(proc, TQT_SIGNAL(receivedStdout(TDEProcess*,
char*,
int)),
32 this, TQT_SLOT(slotReceivedStdout(TDEProcess*,
char*,
int)) );
34 connect(proc, TQT_SIGNAL(receivedStderr(TDEProcess*,
char*,
int)),
35 this, TQT_SLOT(slotReceivedStderr(TDEProcess*,
char*,
int)) );
38 void ProcessLineMaker::slotReceivedStdout(
const char *buffer )
42 while ( (pos = stdoutbuf.find(
'\n')) != -1) {
43 TQCString line = stdoutbuf.left( pos );
44 emit receivedStdoutLine(line);
45 stdoutbuf.remove(0, pos+1);
47 if( !stdoutbuf.isEmpty() ) {
48 emit receivedPartialStdoutLine( stdoutbuf );
49 stdoutbuf.truncate(0);
53 void ProcessLineMaker::slotReceivedStdout( TDEProcess*,
char *buffer,
int )
55 slotReceivedStdout(buffer);
59 void ProcessLineMaker::slotReceivedStderr(
const char *buffer )
63 while ( (pos = stderrbuf.find(
'\n')) != -1) {
64 TQCString line = stderrbuf.left( pos );
65 emit receivedStderrLine(line);
66 stderrbuf.remove(0, pos+1);
68 if( !stderrbuf.isEmpty() ) {
69 emit receivedPartialStderrLine( stderrbuf );
70 stderrbuf.truncate(0);
74 void ProcessLineMaker::slotReceivedStderr( TDEProcess*,
char *buffer,
int )
76 slotReceivedStderr(buffer);
79 void ProcessLineMaker::clearBuffers( )
81 stderrbuf.truncate(0);
82 stdoutbuf.truncate(0);
85 void ProcessLineMaker::flush()
87 if( !stderrbuf.isEmpty() )
88 emit receivedStderrLine(stderrbuf);
89 if( !stdoutbuf.isEmpty() )
90 emit receivedStdoutLine(stdoutbuf);
Utility objects for process output views.