diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp | 10 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp | 32 |
2 files changed, 23 insertions, 19 deletions
diff --git a/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp b/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp index 6893915b..398d80c0 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp +++ b/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp @@ -120,10 +120,6 @@ void TerminalWidget::applyData(QByteArray data){ i+=end; //move the final loop along - already handled these bytes }else if( data.at(i) != '\r' ){ - //Special Check: if inserting text within a line, clear the rest of this line first - /*if(i==0 && this->textCursor().position() < this->document()->characterCount()-1){ - applyANSI("[K"); - }*/ chars.append(data.at(i)); //Plaintext character - just add it here //qDebug() << "Insert Text:" << data.at(i) << CFMT.foreground().color() << CFMT.background().color(); @@ -136,7 +132,7 @@ void TerminalWidget::applyData(QByteArray data){ void TerminalWidget::applyANSI(QByteArray code){ //Note: the first byte is often the "[" character - qDebug() << "Handle ANSI:" << code; + //qDebug() << "Handle ANSI:" << code; if(code.length()==1){ //KEYPAD MODES if(code.at(0)=='='){ altkeypad = true; } @@ -419,7 +415,7 @@ void TerminalWidget::sendKeyPress(int key){ ba.append("\x1b[F"); break; } - qDebug() << "Forward Input:" << ba; + //qDebug() << "Forward Input:" << ba; if(!ba.isEmpty()){ PROC->writeTTY(ba); } } @@ -467,7 +463,7 @@ void TerminalWidget::keyPressEvent(QKeyEvent *ev){ sendKeyPress(Qt::Key_End); //just in case the cursor is not at the end (TTY will split lines and such - ugly) } QByteArray ba; ba.append(ev->text()); //avoid any byte conversions - qDebug() << "Forward Input:" << ba; + //qDebug() << "Forward Input:" << ba; PROC->writeTTY(ba); } diff --git a/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp b/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp index 6321699e..e3ec64d8 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp +++ b/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp @@ -4,6 +4,8 @@ #include <QProcessEnvironment> #include <QTimer> +#define DEBUG 0 + TTYProcess::TTYProcess(QObject *parent) : QObject(parent){ childProc = 0; sn = 0; @@ -21,9 +23,9 @@ bool TTYProcess::startTTY(QString prog, QStringList args, QString workdir){ if(workdir=="~"){ workdir = QDir::homePath(); } QDir::setCurrent(workdir); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - setenv("TERM","vt220-color",1);//"vt102-color",1); //vt100: VT100 emulation support (QTerminal sets "xterm" here) + setenv("TERM","xterm",1); //"vt220-color",1);//"vt102-color",1); //vt100: VT100 emulation support (QTerminal sets "xterm" here) unsetenv("TERMCAP"); - //setenv("TERMCAP","vt102-color",1); + setenv("TERMCAP","vt220-color",1); /*setenv("TERMCAP",":do=2\E[B:co#80:li#24:cl=50\E[H\E[J:sf=2*\ED:\ :le=^H:bs:am:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\ :ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\ @@ -60,12 +62,14 @@ bool TTYProcess::startTTY(QString prog, QStringList args, QString workdir){ cargs[i] = NULL; } } - qDebug() << "PTY Start:" << prog; + if(DEBUG){ qDebug() << "PTY Start:" << prog; } //Launch the process attached to a new PTY int FD = 0; pid_t tmp = LaunchProcess(FD, cprog, cargs); - qDebug() << " - PID:" << tmp; - qDebug() << " - FD:" << FD; + if(DEBUG){ + qDebug() << " - PID:" << tmp; + qDebug() << " - FD:" << FD; + } if(tmp<0){ return false; } //error else{ childProc = tmp; @@ -76,7 +80,7 @@ bool TTYProcess::startTTY(QString prog, QStringList args, QString workdir){ sn->setEnabled(true); connect(sn, SIGNAL(activated(int)), this, SLOT(checkStatus(int)) ); ttyfd = FD; - qDebug() << " - PTY:" << ptsname(FD); + if(DEBUG){ qDebug() << " - PTY:" << ptsname(FD); } starting = true; return true; } @@ -98,7 +102,7 @@ void TTYProcess::closeTTY(){ void TTYProcess::writeTTY(QByteArray output){ //qDebug() << "Write:" << output; static QList<QByteArray> knownFixes; - if(knownFixes.isEmpty()){ knownFixes << "\x1b[C" << "\x1b[D" << "\b"; } + if(knownFixes.isEmpty()){ knownFixes << "\x1b[C" << "\x1b[D" << "\b" << "\x7F" << "\x08"; } fixReply = knownFixes.indexOf(output); ::write(ttyfd, output.data(), output.size()); } @@ -124,7 +128,7 @@ QByteArray TTYProcess::readTTY(){ fragBA = BA; return readTTY(); }else{ - qDebug() << "Read Data:" << BA; + if(DEBUG){ qDebug() << "Read Data:" << BA; } //BUG BYPASS - 12/7/16 //If the PTY gets input fairly soon after starting, the PTY will re-print the initial line(s) if(starting && !BA.contains("\n") ){ @@ -136,9 +140,11 @@ QByteArray TTYProcess::readTTY(){ BA.remove(0, BA.indexOf("\n")+1); starting = false; } - //Apply known fixes for replies to particular inputs (mostly related to cursor position *within* the current line + //Apply known fixes for replies to particular inputs (mostly related to cursor position *within* the current line) + // This appears to be primarily from the concept that the cursor position is always at the end of the line (old VT limitation?) + // so almost all these fixes are for cursor positioning within the current line if(fixReply >= 0){ - qDebug() << "Fix Reply:" <<fixReply << BA; + if(DEBUG){ qDebug() << "Fix Reply:" <<fixReply << BA; } switch(fixReply){ case 0: //Right arrow ("\x1b[C") - PTY reply re-prints the next character rather than moving the cursor if(BA.length()>0){ @@ -152,7 +158,9 @@ QByteArray TTYProcess::readTTY(){ BA.prepend("\x1b[D"); //just move the cursor - don't send the "back" character (\b) } break; - case 2: //Backspace ("\b") - PTY works fine if on the end of the line, but when in the middle of a line it will backpace a number of times after clearing (same as left arrow issue) + case 2: //Backspace or delete - PTY works fine if on the end of the line, but when in the middle of a line it will backpace a number of times after clearing (same as left arrow issue) + case 3: + case 4: if(BA.contains("\x1b[K")){ while(BA.indexOf("\x1b[K") < BA.lastIndexOf("\b") ){ BA.replace( BA.lastIndexOf("\b"), 1, "\x1b[D"); //just move the cursor left - don't send the "back" character (\b) @@ -161,7 +169,7 @@ QByteArray TTYProcess::readTTY(){ break; } fixReply = -1; //done with the fix - resume normal operations - //qDebug() << " - Fixed:" << BA; + if(DEBUG){ qDebug() << " - Fixed:" << BA; } } return BA; } |