From e9b51aab0100ba3d916a3fffaf650317f99657fd Mon Sep 17 00:00:00 2001 From: Kris Moore Date: Thu, 10 Mar 2016 07:43:07 -0500 Subject: Now we can send input back to the TTY --- desktop-utilities/lumina-terminal/TerminalWidget.cpp | 3 +-- desktop-utilities/lumina-terminal/TtyProcess.cpp | 6 ++++++ desktop-utilities/lumina-terminal/TtyProcess.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'desktop-utilities/lumina-terminal') diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.cpp b/desktop-utilities/lumina-terminal/TerminalWidget.cpp index d9e6c3f7..939b9711 100644 --- a/desktop-utilities/lumina-terminal/TerminalWidget.cpp +++ b/desktop-utilities/lumina-terminal/TerminalWidget.cpp @@ -61,7 +61,6 @@ void TerminalWidget::UpdateText(){ qDebug() << "Reading all 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)); @@ -96,7 +95,7 @@ void TerminalWidget::keyPressEvent(QKeyEvent *ev){ } QByteArray ba; ba.append(txt); //avoid any byte conversions qDebug() << "Forward Input:" << txt << ev->key(); - PROC->write(ba); + PROC->writeTTY(ba); } void TerminalWidget::mousePressEvent(QMouseEvent *ev){ diff --git a/desktop-utilities/lumina-terminal/TtyProcess.cpp b/desktop-utilities/lumina-terminal/TtyProcess.cpp index bafdb0ef..e0375410 100644 --- a/desktop-utilities/lumina-terminal/TtyProcess.cpp +++ b/desktop-utilities/lumina-terminal/TtyProcess.cpp @@ -46,12 +46,18 @@ bool TTYProcess::startTTY(int &retfd, QString prog, QStringList args){ childProc = tmp; this->setFileName( ptsname(FD) ); retfd = FD; + ttyfd = FD; qDebug() << " - PTY:" << ptsname(FD); return this->open(QIODevice::ReadWrite | QIODevice::Unbuffered); //return true; } } +void TTYProcess::writeTTY(QByteArray output){ + int written = ::write(ttyfd, output.data(), output.size()); + qDebug() << "Wrote:" << written; +} + // === PRIVATE === pid_t TTYProcess::LaunchProcess(int& fd, char *prog, char **child_args){ //Returns: -1 for errors, positive value (file descriptor) for the master side of the TTY to watch diff --git a/desktop-utilities/lumina-terminal/TtyProcess.h b/desktop-utilities/lumina-terminal/TtyProcess.h index 4631b922..38cca5a4 100644 --- a/desktop-utilities/lumina-terminal/TtyProcess.h +++ b/desktop-utilities/lumina-terminal/TtyProcess.h @@ -32,9 +32,11 @@ public: ~TTYProcess(); bool startTTY(int &retfd, QString prog, QStringList args = QStringList()); + void writeTTY(QByteArray output); private: pid_t childProc; + int ttyfd; //==================================== // C Library function for setting up the PTY -- cgit