aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp19
-rw-r--r--src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp63
-rw-r--r--src-qt5/desktop-utils/lumina-terminal/TtyProcess.h1
3 files changed, 67 insertions, 16 deletions
diff --git a/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp b/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp
index 6342be59..6893915b 100644
--- a/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp
@@ -93,10 +93,15 @@ void TerminalWidget::applyData(QByteArray data){
//qDebug() << "Data:" << data;
for(int i=0; i<data.size(); i++){
if( data.at(i)=='\b' ){
- //Flush current text buffer to widget
- //Simple cursor backward 1 (NOT backspace in this context!! - this widget should be in "insert" mode instead)
- InsertText(chars); chars.clear();
- this->moveCursor(QTextCursor::Left, QTextCursor::MoveAnchor);
+ //Backspace
+ if(!chars.isEmpty()){ chars.chop(1); }
+ else{
+ QTextCursor cur = this->textCursor();
+ cur.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor, 1);
+ cur.removeSelectedText();
+ this->setTextCursor(cur);
+ }
+
//}else if( data.at(i)=='\t' ){
//chars.append(" ");
}else if( data.at(i)=='\x1B' ){
@@ -116,9 +121,9 @@ void TerminalWidget::applyData(QByteArray data){
}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){
+ /*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();
@@ -462,7 +467,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 a1ee0be7..a92b33f8 100644
--- a/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp
+++ b/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp
@@ -9,6 +9,7 @@ TTYProcess::TTYProcess(QObject *parent) : QObject(parent){
sn = 0;
ttyfd = 0;
starting = true;
+ fixReply = -1;
}
TTYProcess::~TTYProcess(){
@@ -20,10 +21,25 @@ bool TTYProcess::startTTY(QString prog, QStringList args, QString workdir){
if(workdir=="~"){ workdir = QDir::homePath(); }
QDir::setCurrent(workdir);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
- setenv("TERM","xterm",1);//"vt100",1); //vt100: VT100 emulation support
+ setenv("TERM","vt220-color",1);//"vt102-color",1); //vt100: VT100 emulation support (QTerminal sets "xterm" here)
unsetenv("TERMCAP");
- /*setenv("TERMCAP","mvterm|vv100|mvterm emulator with ANSI colors:\
- :pa#64:Co#8:AF=\E[3%dm:AB=\E[4%dm:op=\E[100m:tc=vt102:",1); //see /etc/termcap as well*/
+ //setenv("TERMCAP","vt102-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:\
+ :md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:\
+ :is=\E>\E[?1;3;4;5l\E[?7;8h\E[1;24r\E[24;1H:\
+ :if=/usr/share/tabset/vt100:nw=2\EE:ho=\E[H:\
+ :as=2\E(0:ae=2\E(B:\
+ :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||:\
+ :rs=\E>\E[?1;3;4;5l\E[?7;8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\
+ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=\177:\
+ :k0=\EOy:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\EOt:\
+ :k6=\EOu:k7=\EOv:k8=\EOl:k9=\EOw:k;=\EOx:@8=\EOM:\
+ :K1=\EOq:K2=\EOr:K3=\EOs:K4=\EOp:K5=\EOn:pt:sr=2*\EM:xn:\
+ :sc=2\E7:rc=2\E8:cs=5\E[%i%d;%dr:UP=2\E[%dA:DO=2\E[%dB:RI=2\E[%dC:\
+ :LE=2\E[%dD:ct=2\E[3g:st=2\EH:ta=^I:ms:bl=^G:cr=^M:eo:it#8:\
+ :RA=\E[?7l:SA=\E[?7h:po=\E[5i:pf=\E[4i:",1); //see /etc/termcap as well*/
QStringList filter = env.keys().filter("XTERM");
for(int i=0; i<filter.length(); i++){ unsetenv(filter[i].toLocal8Bit().data()); }
//if(env.contains("TERM")){ unsetenv("TERM"); }
@@ -61,12 +77,7 @@ bool TTYProcess::startTTY(QString prog, QStringList args, QString workdir){
connect(sn, SIGNAL(activated(int)), this, SLOT(checkStatus(int)) );
ttyfd = FD;
qDebug() << " - PTY:" << ptsname(FD);
- //BUG BYPASS - 12/7/16
- //If the PTY gets input fairly soon after starting, the PTY will re-print the initial line(s)
- // So send the "newline" signal now to get things started
starting = true;
- //writeTTY("\n"); //newline
- //writeTTY(QByteArray("\x1b[2J") ); //clear display
return true;
}
}
@@ -86,6 +97,9 @@ void TTYProcess::closeTTY(){
void TTYProcess::writeTTY(QByteArray output){
//qDebug() << "Write:" << output;
+ static QList<QByteArray> knownFixes;
+ if(knownFixes.isEmpty()){ knownFixes << "\x1b[C" << "\x1b[D"; }
+ fixReply = knownFixes.indexOf(output);
::write(ttyfd, output.data(), output.size());
}
@@ -110,7 +124,9 @@ QByteArray TTYProcess::readTTY(){
fragBA = BA;
return readTTY();
}else{
- //qDebug() << "Read Data:" << BA;
+ 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") ){
//qDebug() << "Starting phase 1:" << BA;
writeTTY("\n\b"); //newline + backspace
@@ -120,6 +136,26 @@ QByteArray TTYProcess::readTTY(){
BA.remove(0, BA.indexOf("\n")+1);
starting = false;
}
+ //Apply known fixes for replies to particular inputs
+ if(fixReply >= 0){
+ qDebug() << "Fix Reply:" <<fixReply << BA;
+ switch(fixReply){
+ case 0: //Right arrow ("\x1b[C") - PTY reply clears the screen after printing only the first char (not everything)
+ if(BA.length()>0){
+ BA.remove(0,1);
+ BA.prepend("\x1b[C"); //just move the cursor - don't re-print that 1 character
+ }
+ break;
+ case 1: //Right arrow ("\x1b[D") - PTY reply clears the screen after printing only the first char (not everything)
+ if(BA.startsWith("\b")){
+ BA.remove(0,1);
+ BA.prepend("\x1b[D"); //just move the cursor - don't send the "back" character (\b)
+ }
+ break;
+ }
+ fixReply = -1; //done with the fix - resume normal operations
+ //qDebug() << " - Fixed:" << BA;
+ }
return BA;
}
}
@@ -182,6 +218,15 @@ QByteArray TTYProcess::CleanANSI(QByteArray raw, bool &incomplete){
index = raw.indexOf("\x07");
}
+ //VT102 Identify request
+ index = raw.indexOf("\x1b[Z");
+ while(index>=0){
+ raw = raw.remove(index,1);
+ index = raw.indexOf("\x1b[Z");
+ //Also send the proper reply to this identify request right away
+ writeTTY("\x1b[/Z");
+ }
+
incomplete = false;
return raw;
}
diff --git a/src-qt5/desktop-utils/lumina-terminal/TtyProcess.h b/src-qt5/desktop-utils/lumina-terminal/TtyProcess.h
index 1603fe5e..c2b483a9 100644
--- a/src-qt5/desktop-utils/lumina-terminal/TtyProcess.h
+++ b/src-qt5/desktop-utils/lumina-terminal/TtyProcess.h
@@ -61,6 +61,7 @@ private:
QSocketNotifier *sn;
QByteArray fragBA; //fragment ByteArray
bool starting;
+ int fixReply; //flag for detecting particular inputs and "fixing" the reply to it as needed
//====================================
// C Library function for setting up the PTY
bgstack15