diff options
Diffstat (limited to 'desktop-utilities')
4 files changed, 39 insertions, 6 deletions
diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.cpp b/desktop-utilities/lumina-terminal/TerminalWidget.cpp index c08c9d81..123e6654 100644 --- a/desktop-utilities/lumina-terminal/TerminalWidget.cpp +++ b/desktop-utilities/lumina-terminal/TerminalWidget.cpp @@ -84,11 +84,13 @@ void TerminalWidget::applyANSI(QByteArray code){ }else if(code.endsWith("C")){ //Move Forward int num = 1; if(code.size()>2){ num = code.mid(1, code.size()-2).toInt(); } //everything in the middle - this->textCursor().movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, num); + for(int i=0; i<num; i++){ this->moveCursor(QTextCursor::Right, QTextCursor::MoveAnchor); } + //this->textCursor().movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, num); }else if(code.endsWith("D")){ //Move Back int num = 1; if(code.size()>2){ num = code.mid(1, code.size()-2).toInt(); } //everything in the middle - this->textCursor().movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, num); + for(int i=0; i<num; i++){ this->moveCursor(QTextCursor::Left, QTextCursor::MoveAnchor); } + //this->textCursor().movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, num); }else if(code.endsWith("E")){ //Move Next/down Lines (go to beginning) int num = 1; if(code.size()>2){ num = code.mid(1, code.size()-2).toInt(); } //everything in the middle @@ -116,6 +118,35 @@ void TerminalWidget::applyANSI(QByteArray code){ } } +//Outgoing Data parsing +void TerminalWidget::sendKeyPress(int key){ + QByteArray ba; + //Check for special keys + switch(key){ + case Qt::Key_Delete: + ba.append("\x7F"); + break; + case Qt::Key_Backspace: + ba.append("\x08"); + break; + case Qt::Key_Left: + ba.append("\x1b[D"); + break; + case Qt::Key_Right: + ba.append("\x1b[C"); + break; + case Qt::Key_Up: + ba.append("\x1b[A"); + break; + case Qt::Key_Down: + ba.append("\x1b[B"); + break; + } + + //qDebug() << "Forward Input:" << txt << ev->key() << ba; + if(!ba.isEmpty()){ PROC->writeTTY(ba); } +} + // ================== // PRIVATE SLOTS // ================== @@ -138,7 +169,7 @@ void TerminalWidget::ShellClosed(){ void TerminalWidget::keyPressEvent(QKeyEvent *ev){ if(ev->text().isEmpty() || ev->text()=="\b" ){ - PROC->writeQtKey(ev->key()); + sendKeyPress(ev->key()); }else{ QByteArray ba; ba.append(ev->text()); //avoid any byte conversions PROC->writeTTY(ba); diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.h b/desktop-utilities/lumina-terminal/TerminalWidget.h index 18f0054f..7f65f7d7 100644 --- a/desktop-utilities/lumina-terminal/TerminalWidget.h +++ b/desktop-utilities/lumina-terminal/TerminalWidget.h @@ -28,8 +28,11 @@ private: QSocketNotifier *sn; + //Incoming Data parsing void applyData(QByteArray data); //overall data parsing void applyANSI(QByteArray code); //individual code application + //Outgoing Data parsing + void sendKeyPress(int key); private slots: void UpdateText(); diff --git a/desktop-utilities/lumina-terminal/TtyProcess.cpp b/desktop-utilities/lumina-terminal/TtyProcess.cpp index 8121b365..fefc96ea 100644 --- a/desktop-utilities/lumina-terminal/TtyProcess.cpp +++ b/desktop-utilities/lumina-terminal/TtyProcess.cpp @@ -67,7 +67,7 @@ void TTYProcess::writeTTY(QByteArray output){ ::write(ttyfd, output.data(), output.size()); } -void TTYProcess::writeQtKey(int key){ +/*void TTYProcess::writeQtKey(int key){ QByteArray ba; //Check for special keys switch(key){ @@ -90,7 +90,7 @@ void TTYProcess::writeQtKey(int key){ //qDebug() << "Forward Input:" << txt << ev->key() << ba; if(!ba.isEmpty()){ this->writeTTY(ba); } -} +}*/ QByteArray TTYProcess::readTTY(){ QByteArray BA; diff --git a/desktop-utilities/lumina-terminal/TtyProcess.h b/desktop-utilities/lumina-terminal/TtyProcess.h index b1703fb7..897d4b31 100644 --- a/desktop-utilities/lumina-terminal/TtyProcess.h +++ b/desktop-utilities/lumina-terminal/TtyProcess.h @@ -44,7 +44,6 @@ 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(); //Setup the terminal size (characters and pixels) |