aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop-utilities/lumina-terminal/TerminalWidget.cpp26
-rw-r--r--desktop-utilities/lumina-terminal/TerminalWidget.h4
-rw-r--r--desktop-utilities/lumina-terminal/TtyProcess.cpp5
-rw-r--r--desktop-utilities/lumina-terminal/TtyProcess.h2
4 files changed, 22 insertions, 15 deletions
diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.cpp b/desktop-utilities/lumina-terminal/TerminalWidget.cpp
index de7e47ff..d9e6c3f7 100644
--- a/desktop-utilities/lumina-terminal/TerminalWidget.cpp
+++ b/desktop-utilities/lumina-terminal/TerminalWidget.cpp
@@ -19,17 +19,22 @@ TerminalWidget::TerminalWidget(QWidget *parent, QString dir) : QTextEdit(parent)
//Create/open the TTY port
PROC = new TTYProcess(this);
qDebug() << "Open new TTY";
- bool ok = PROC->startTTY( QProcessEnvironment::systemEnvironment().value("SHELL","/bin/sh") );
+ int fd;
+ bool ok = PROC->startTTY( fd, QProcessEnvironment::systemEnvironment().value("SHELL","/bin/sh") );
qDebug() << " - opened:" << ok;
this->setEnabled(PROC->isOpen());
//Connect the signals/slots
- connect(PROC, SIGNAL(readyRead()), this, SLOT(UpdateText()) );
+ //connect(PROC, SIGNAL(readyRead()), this, SLOT(UpdateText()) );
connect(PROC, SIGNAL(aboutToClose()), this, SLOT(ShellClosed()) );
+
+ sn= new QSocketNotifier(fd, QSocketNotifier::Read);
+ sn->setEnabled(true);
+ connect(sn, SIGNAL(activated(int)), this, SLOT(UpdateText()));
upTimer = new QTimer(this);
upTimer->setInterval(1000);
- connect(upTimer, SIGNAL(timeout()), this, SLOT(UpdateText()) );
+ // connect(upTimer, SIGNAL(timeout()), this, SLOT(UpdateText()) );
upTimer->start();
}
@@ -50,15 +55,16 @@ void TerminalWidget::UpdateText(){
//read the data from the process
qDebug() << "UpdateText";
if(!PROC->isOpen()){ return; }
- if ( PROC->bytesAvailable() <= 0 )
- return;
+ //if ( PROC->bytesAvailable() <= 0 )
+ // return;
qDebug() << "Reading all data";
- QByteArray data = PROC->readAll(); //TTY PORT
- //QByteArray data = PROC->readAllStandardOutput(); //QProcess
- if(data.length()<=0){ return; }
- qDebug() << "Process Data:" << data;
- this->insertPlainText(QString(data));
+ char buffer[64];
+ ssize_t rtot = read(sn->socket(),&buffer,64);
+ qDebug()<<(quint8)buffer[0]<<(quint8)buffer[1]<<(quint8)buffer[2]<<(quint8)buffer[3];
+ buffer[rtot]='\0';
+ qDebug() << "Process Data:" << QString(buffer);
+ this->insertPlainText(QString(buffer));
//adjust the scrollbar as needed
}
diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.h b/desktop-utilities/lumina-terminal/TerminalWidget.h
index 6f13348e..7e08226a 100644
--- a/desktop-utilities/lumina-terminal/TerminalWidget.h
+++ b/desktop-utilities/lumina-terminal/TerminalWidget.h
@@ -9,6 +9,7 @@
#include <QTextEdit>
#include <QKeyEvent>
+#include <QSocketNotifier>
#include <QTimer>
#include "TtyProcess.h"
@@ -25,6 +26,7 @@ private:
TTYProcess *PROC;
//QProcess *PROC;
+ QSocketNotifier *sn;
QTimer *upTimer;
private slots:
@@ -41,4 +43,4 @@ protected:
void contextMenuEvent(QContextMenuEvent *ev);
};
-#endif \ No newline at end of file
+#endif
diff --git a/desktop-utilities/lumina-terminal/TtyProcess.cpp b/desktop-utilities/lumina-terminal/TtyProcess.cpp
index 757223ed..bafdb0ef 100644
--- a/desktop-utilities/lumina-terminal/TtyProcess.cpp
+++ b/desktop-utilities/lumina-terminal/TtyProcess.cpp
@@ -18,7 +18,7 @@ TTYProcess::~TTYProcess(){
}
// === PUBLIC ===
-bool TTYProcess::startTTY(QString prog, QStringList args){
+bool TTYProcess::startTTY(int &retfd, QString prog, QStringList args){
//Turn the program/arguments into C-compatible arrays
char cprog[prog.length()]; strcpy(cprog, prog.toLocal8Bit().data());
char *cargs[args.length()+2];
@@ -45,6 +45,7 @@ bool TTYProcess::startTTY(QString prog, QStringList args){
else{
childProc = tmp;
this->setFileName( ptsname(FD) );
+ retfd = FD;
qDebug() << " - PTY:" << ptsname(FD);
return this->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
//return true;
@@ -86,10 +87,8 @@ pid_t TTYProcess::LaunchProcess(int& fd, char *prog, char **child_args){
setsid(); //Make current process new session leader (so we can set controlling terminal)
ioctl(0,TIOCSCTTY, 1); //Set the controlling terminal to the slave PTY
- qDebug() << "Starting execvp";
//Execute the designated program
rc = execvp(prog, child_args);
- qDebug() << "Stopping execvp";
::close(fds); //no need to keep original file descriptor open any more
exit(rc);
}
diff --git a/desktop-utilities/lumina-terminal/TtyProcess.h b/desktop-utilities/lumina-terminal/TtyProcess.h
index 76b82d1f..4631b922 100644
--- a/desktop-utilities/lumina-terminal/TtyProcess.h
+++ b/desktop-utilities/lumina-terminal/TtyProcess.h
@@ -31,7 +31,7 @@ public:
TTYProcess(QObject *parent = 0);
~TTYProcess();
- bool startTTY(QString prog, QStringList args = QStringList());
+ bool startTTY(int &retfd, QString prog, QStringList args = QStringList());
private:
pid_t childProc;
bgstack15