diff options
author | Ken Moore <moorekou@gmail.com> | 2016-03-10 16:28:06 -0500 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-03-10 16:28:06 -0500 |
commit | b398d10fdc3fe0f15228051de6e28288090c1db5 (patch) | |
tree | 3dc23d610fdb3d8712adfdb7b4cdbc5d8e73b133 /desktop-utilities/lumina-terminal | |
parent | Clean up a lot of the ANSI control codes (tested with csh) (diff) | |
download | lumina-b398d10fdc3fe0f15228051de6e28288090c1db5.tar.gz lumina-b398d10fdc3fe0f15228051de6e28288090c1db5.tar.bz2 lumina-b398d10fdc3fe0f15228051de6e28288090c1db5.zip |
Start adding the compatibility section for various key presses/codes. The exact replacements are commented out as they are still unfunctional.
Diffstat (limited to 'desktop-utilities/lumina-terminal')
-rw-r--r-- | desktop-utilities/lumina-terminal/TerminalWidget.cpp | 28 | ||||
-rw-r--r-- | desktop-utilities/lumina-terminal/TtyProcess.cpp | 33 | ||||
-rw-r--r-- | desktop-utilities/lumina-terminal/TtyProcess.h | 2 |
3 files changed, 38 insertions, 25 deletions
diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.cpp b/desktop-utilities/lumina-terminal/TerminalWidget.cpp index fa67093b..96b86bda 100644 --- a/desktop-utilities/lumina-terminal/TerminalWidget.cpp +++ b/desktop-utilities/lumina-terminal/TerminalWidget.cpp @@ -62,26 +62,14 @@ void TerminalWidget::ShellClosed(){ // PROTECTED // ================== void TerminalWidget::keyPressEvent(QKeyEvent *ev){ - //Check for special key combinations first - QString txt = ev->text(); - if(txt.isEmpty()){ return; } // modifier key - nothing to send yet - /*switch(ev->key()){ - //case Qt::Key_Backspace: - case Qt::Key_Left: - case Qt::Key_Right: - case Qt::Key_Up: - case Qt::Key_Down: - break; - //case Qt::Key_Return: - //case Qt::Key_Enter: - //txt = "\r"; - //default: - //All other events can get echoed onto the widget (non-movement) - //QTextEdit::keyPressEvent(ev); //echo the input on the widget - }*/ - QByteArray ba; ba.append(txt); //avoid any byte conversions - //qDebug() << "Forward Input:" << txt << ev->key() << ba; - PROC->writeTTY(ba); + + if(ev->text().isEmpty() || ev->text()=="\b" ){ + PROC->writeQtKey(ev->key()); + }else{ + QByteArray ba; ba.append(ev->text()); //avoid any byte conversions + PROC->writeTTY(ba); + } + ev->ignore(); } diff --git a/desktop-utilities/lumina-terminal/TtyProcess.cpp b/desktop-utilities/lumina-terminal/TtyProcess.cpp index 8d59cdde..1941ecd9 100644 --- a/desktop-utilities/lumina-terminal/TtyProcess.cpp +++ b/desktop-utilities/lumina-terminal/TtyProcess.cpp @@ -63,9 +63,31 @@ void TTYProcess::closeTTY(){ } void TTYProcess::writeTTY(QByteArray output){ - //int written = + qDebug() << "Write:" << output; ::write(ttyfd, output.data(), output.size()); - //qDebug() << "Wrote:" << written; +} + +void TTYProcess::writeQtKey(int key){ + //Note that a shell does *not* take ANSI + QByteArray ba; + //Check for special keys + switch(key){ + case Qt::Key_Backspace: + //ba.append("^H/x1b[8p"); + break; + case Qt::Key_Left: + case Qt::Key_Right: + break; + case Qt::Key_Up: + //ba.append("\x1b[(224;72)p"); + break; + case Qt::Key_Down: + //ba.append("\x1b[(224;80)p"); + break; + } + + //qDebug() << "Forward Input:" << txt << ev->key() << ba; + if(!ba.isEmpty()){ this->writeTTY(ba); } } QByteArray TTYProcess::readTTY(){ @@ -87,6 +109,7 @@ QByteArray TTYProcess::readTTY(){ fragBA = BA; return readTTY(); }else{ + qDebug() << "Read Data:" << BA; return BA; } } @@ -97,7 +120,7 @@ bool TTYProcess::isOpen(){ QByteArray TTYProcess::CleanANSI(QByteArray raw, bool &incomplete){ incomplete = true; - qDebug() << "Clean ANSI Data:" << raw; + //qDebug() << "Clean ANSI Data:" << raw; //IN_LINE TERMINAL COLOR CODES (ANSI Escape Codes) "\x1B[<colorcode>m" // - Just remove them for now @@ -119,7 +142,7 @@ QByteArray TTYProcess::CleanANSI(QByteArray raw, bool &incomplete){ raw = raw.remove(index, end-index+1); index = raw.indexOf("\x1B["); } - qDebug() << " - Removed Color Codes:" << raw; + //qDebug() << " - Removed Color Codes:" << raw; // SYSTEM BELL index = raw.indexOf("\x07"); @@ -128,7 +151,7 @@ QByteArray TTYProcess::CleanANSI(QByteArray raw, bool &incomplete){ raw = raw.remove(index,1); index = raw.indexOf("\x07"); } - qDebug() << " - Fully Cleaned:" << raw; + //qDebug() << " - Fully Cleaned:" << raw; incomplete = false; return raw; diff --git a/desktop-utilities/lumina-terminal/TtyProcess.h b/desktop-utilities/lumina-terminal/TtyProcess.h index 26cf3ed5..ba5606de 100644 --- a/desktop-utilities/lumina-terminal/TtyProcess.h +++ b/desktop-utilities/lumina-terminal/TtyProcess.h @@ -14,6 +14,7 @@ #include <QDebug> #include <QSocketNotifier> +#include <QKeyEvent> //Standard C library functions for PTY access/setup #include <stdlib.h> @@ -36,6 +37,7 @@ public: //Primary read/write functions void writeTTY(QByteArray output); + void writeQtKey(int key); //simplification function for handling special keys like arrows and such ( QKeyEvent()->key() ) QByteArray readTTY(); //Status update checks |