diff options
-rw-r--r-- | port-files/FreeBSD/Makefile | 3 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_mouse.cpp | 4 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_theme.cpp | 2 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/BootSplash.cpp | 108 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp | 13 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-terminal/TermWindow.h | 1 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp | 45 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-terminal/TerminalWidget.h | 1 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp | 104 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-terminal/TtyProcess.h | 1 |
10 files changed, 235 insertions, 47 deletions
diff --git a/port-files/FreeBSD/Makefile b/port-files/FreeBSD/Makefile index 9b86ada1..20b1ab1d 100644 --- a/port-files/FreeBSD/Makefile +++ b/port-files/FreeBSD/Makefile @@ -17,7 +17,8 @@ RUN_DEPENDS= fluxbox>=0:x11-wm/fluxbox \ xbrightness:x11/xbrightness \ compton:x11-wm/compton \ xrandr:x11/xrandr \ - numlockx:x11/numlockx + numlockx:x11/numlockx \ + xinput:x11/xinput LIB_DEPENDS+= libxcb-ewmh.so:x11/xcb-util-wm \ libxcb-icccm.so:x11/xcb-util-wm \ libxcb-image.so:x11/xcb-util-image \ diff --git a/src-qt5/core-utils/lumina-config/pages/page_mouse.cpp b/src-qt5/core-utils/lumina-config/pages/page_mouse.cpp index 8f5c0c23..bda90ad4 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_mouse.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_mouse.cpp @@ -50,7 +50,7 @@ void page_mouse::SaveSettings(){ void page_mouse::LoadSettings(int){ emit HasPendingChanges(false); - emit ChangePageTitle( tr("Mouse Settings") ); + emit ChangePageTitle( tr("Input Device Settings") ); } @@ -151,7 +151,7 @@ void page_mouse::populateDeviceItemValue(QTreeWidget *tree, QTreeWidgetItem *it, tree->setItemWidget(it, 1, box); connect(box, SIGNAL(valueChanged(double)), this, SLOT(valueChanged()) ); - }else if(value.canConvert<QList<QVariant>>()){ + }else if(value.canConvert< QList<QVariant> >()){ //Not Modifiable - just use the label in the item QList<QVariant> list = value.toList(); QStringList txtList; diff --git a/src-qt5/core-utils/lumina-config/pages/page_theme.cpp b/src-qt5/core-utils/lumina-config/pages/page_theme.cpp index 0d946e81..52579ec2 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_theme.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_theme.cpp @@ -117,7 +117,7 @@ ui->combo_session_themefile->clear(); index = ui->combo_qt5_theme->findData("internal_custom"); } if(index>=0){ ui->combo_qt5_theme->setCurrentIndex(index); } - + checkQt5Theme(); //update item visibility QApplication::processEvents(); loading = false; } diff --git a/src-qt5/core/lumina-desktop/BootSplash.cpp b/src-qt5/core/lumina-desktop/BootSplash.cpp index f6c4c5fa..1a648973 100644 --- a/src-qt5/core/lumina-desktop/BootSplash.cpp +++ b/src-qt5/core/lumina-desktop/BootSplash.cpp @@ -16,8 +16,24 @@ BootSplash::BootSplash() : QWidget(0, Qt::SplashScreen | Qt::X11BypassWindowMana } void BootSplash::generateTipOfTheDay(){ - int index = qrand()%5; //Make sure this number matches the length of the case below (max value +1) - QString tip = "This desktop is generously sponsored by iXsystems\nwww.ixsystems.com"; //fallback message (just in case) + //Try to find a system-defined message of the day for lumina + QStringList dirs; dirs << LOS::AppPrefix()+"/etc/" << LOS::SysPrefix()+"/etc/" << L_ETCDIR+"/"; + QString sysMOTD = "lumina-motd"; + for(int i=0; i<dirs.length(); i++){ + if(QFile::exists(dirs[i]+sysMOTD)){ sysMOTD.prepend(dirs[i]); break; } + } + + QString tip; + if(sysMOTD.contains("/") && LUtils::isValidBinary(sysMOTD)){ + //is binary - run it to generate text + tip = LUtils::getCmdOutput(sysMOTD).join("\n"); + + }else if(QFile::exists(sysMOTD)){ + //text file - read it to generate text + tip = LUtils::readFile(sysMOTD).join("\n"); + + }else{ + int index = qrand()%46; //Make sure this number matches the length of the case below (max value +1) switch(index){ case 0: tip = tr("This desktop is powered by coffee, coffee, and more coffee."); break; @@ -30,11 +46,91 @@ void BootSplash::generateTipOfTheDay(){ case 4: tip = tr("Lumina can easily reproduce the interface from most other desktop environments."); break; case 5: - tip = tr(""); break; + tip = tr("This desktop is generously sponsored by iXsystems")+"\n\nwww.ixsystems.com"; break; case 6: - tip = tr(""); break; - } - ui->label_welcome->setText( "\""+tip+"\"" ); + tip = "\""+tr("I have never been hurt by what I have not said")+"\"\n\n- Calvin Coolidge -"; break; + case 7: + tip = "\""+tr("Gotta have more cowbell!")+"\"\n\n- Christopher Walken (SNL) -"; break; + case 8: + tip = "\""+tr("Everything has its beauty but not everyone sees it.")+"\"\n\n- Confucius -"; break; + case 9: + tip = "\""+tr("Before God we are all equally wise - and equally foolish.")+"\"\n\n- Albert Einstein -"; break; + case 10: + tip = "\""+tr("We cannot do everything at once, but we can do something at once.")+"\"\n\n- Calvin Coolidge -"; break; + case 11: + tip = "\""+tr("One with the law is a majority.")+"\"\n\n- Calvin Coolidge -"; break; + case 12: + tip = "\""+tr("Don't expect to build up the weak by pulling down the strong.")+"\"\n\n- Calvin Coolidge -"; break; + case 13: + tip = "\""+tr("You can't know too much, but you can say too much.")+"\"\n\n- Calvin Coolidge -"; break; + case 14: + tip = "\""+tr("Duty is not collective; it is personal.")+"\"\n\n- Calvin Coolidge -"; break; + case 15: + tip = "\""+tr("Any society that would give up a little liberty to gain a little security will deserve neither and lose both.")+"\"\n\n- Benjamin Franklin -"; break; + case 16: + tip = "\""+tr("Never trust a computer you can’t throw out a window.")+"\"\n\n- Steve Wozniak -"; break; + case 17: + tip = "\""+tr("Study the past if you would define the future.")+"\"\n\n- Confucius -"; break; + case 18: + tip = "\""+tr("The way to get started is to quit talking and begin doing.")+"\"\n\n- Walt Disney -"; break; + case 19: + tip = "\""+tr("Ask and it will be given to you; search, and you will find; knock and the door will be opened for you.")+"\"\n\n- Jesus Christ -"; break; + case 20: + tip = "\""+tr("Start where you are. Use what you have. Do what you can.")+"\"\n\n- Arthur Ashe -"; break; + case 21: + tip = "\""+tr("A person who never made a mistake never tried anything new.")+"\"\n\n- Albert Einstein -"; break; + case 22: + tip = "\""+tr("It does not matter how slowly you go as long as you do not stop.")+"\"\n\n- Confucius -"; break; + case 23: + tip = "\""+tr("Do what you can, where you are, with what you have.")+"\"\n\n- Theodore Roosevelt -"; break; + case 24: + tip = "\""+tr("Remember no one can make you feel inferior without your consent.")+"\"\n\n- Eleanor Roosevelt -"; break; + case 25: + tip = "\""+tr("It’s not the years in your life that count. It’s the life in your years.")+"\"\n\n- Abraham Lincoln -"; break; + case 26: + tip = "\""+tr("Either write something worth reading or do something worth writing.")+"\"\n\n- Benjamin Franklin -"; break; + case 27: + tip = "\""+tr("The only way to do great work is to love what you do.")+"\"\n\n- Steve Jobs -"; break; + case 28: + tip = "\""+tr("Political correctness is tyranny with manners.")+"\"\n\n- Charlton Heston -"; break; + case 29: + tip = "\""+tr("Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.")+"\"\n\n- Albert Einstein -"; break; + case 30: + tip = "\""+tr("I find that the harder I work, the more luck I seem to have.")+"\"\n\n- Thomas Jefferson -"; break; + case 31: + tip = "\""+tr("Do, or do not. There is no 'try'.")+"\"\n\n- Yoda -"; break; + case 32: + tip = "\""+tr("A mathematician is a device for turning coffee into theorems.")+"\"\n\n- Paul Erdos -"; break; + case 33: + tip = "\""+tr("Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws.")+"\"\n\n- Plato -"; break; + case 34: + tip = "\""+tr("Black holes are where God divided by zero.")+"\"\n\n- Steven Wright -"; break; + case 35: + tip = "\""+tr("It's kind of fun to do the impossible.")+"\"\n\n- Walt Disney -"; break; + case 36: + tip = "\""+tr("Knowledge speaks, but wisdom listens.")+"\"\n\n- Jimi Hendrix -"; break; + case 37: + tip = "\""+tr("A witty saying proves nothing.")+"\"\n\n- Voltaire -"; break; + case 38: + tip = "\""+tr("Success usually comes to those who are too busy to be looking for it.")+"\"\n\n- Henry David Thoreau -"; break; + case 39: + tip = "\""+tr("Well-timed silence hath more eloquence than speech.")+"\"\n\n- Martin Fraquhar Tupper -"; break; + case 40: + tip = "\""+tr("I have never let my schooling interfere with my education.")+"\"\n\n- Mark Twain -"; break; + case 41: + tip = "\""+tr("The best way to predict the future is to invent it.")+"\"\n\n- Alan Kay -"; break; + case 42: + tip = "\""+tr("Well done is better than well said.")+"\"\n\n- Benjamin Franklin -"; break; + case 43: + tip = "\""+tr("Sometimes it is not enough that we do our best; we must do what is required.")+"\"\n\n- Sir Winston Churchill -"; break; + case 44: + tip = "\""+tr("The truth is more important than the facts.")+"\"\n\n- Frank Lloyd Wright -"; break; + case 45: + tip = "\""+tr("Better to remain silent and be thought a fool than to speak out and remove all doubt.")+"\"\n\n- Abraham Lincoln -"; break; + } //end of switch for tips + + } //end of fallback tip generation + ui->label_welcome->setText( tip); } void BootSplash::showScreen(QString loading){ //update icon, text, and progress diff --git a/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp b/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp index 8ff3ecd1..15cfe047 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp +++ b/src-qt5/desktop-utils/lumina-terminal/TermWindow.cpp @@ -36,6 +36,11 @@ TermWindow::TermWindow(QSettings *set) : QWidget(0, Qt::Window | Qt::BypassWindo ANIM = new QPropertyAnimation(this, "geometry", this); ANIM->setDuration(300); //1/3 second animation connect(ANIM, SIGNAL(finished()), this, SLOT(AnimFinished()) ); + activeTimer = new QTimer(this); + activeTimer->setInterval(50); + activeTimer->setSingleShot(true); + connect(activeTimer, SIGNAL(timeout()), this, SLOT(activeStatusChanged()) ); + connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), activeTimer, SLOT(start()) ); //Create the keyboard shortcuts //hideS = new QShortcut(QKeySequence(Qt::Key_Escape),this); closeS = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q),this); @@ -57,7 +62,6 @@ TermWindow::TermWindow(QSettings *set) : QWidget(0, Qt::Window | Qt::BypassWindo connect(closeS, SIGNAL(activated()), this, SLOT(CloseWindow()) ); connect(prevTabS, SIGNAL(activated()), this, SLOT(Prev_Tab()) ); connect(nextTabS, SIGNAL(activated()), this, SLOT(Next_Tab()) ); - connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(activeStatusChanged()) ); //Now set the defaults screennum = 0; //default value setTopOfScreen(true); //default value @@ -283,12 +287,9 @@ void TermWindow::AnimFinished(){ } void TermWindow::activeStatusChanged(){ - //Note: Qt 5.6.1 returns the opposite value for isActiveWindow() (12/7/16) - //qDebug() << "active status changed:" << this->isActiveWindow() << (this == QApplication::activeWindow()); if(animRunning>=0){ return; } //ignore this event - already changing - //if(!this->isActiveWindow() && !this->isVisible()){ ShowWindow(); } - //else if(this->isActiveWindow() this->isVisible()){ HideWindow(); } - //ReShowWindow(); + QWidget *active = QApplication::activeWindow(); + if(active==0 && this->isVisible()){ HideWindow(); } } // =================== diff --git a/src-qt5/desktop-utils/lumina-terminal/TermWindow.h b/src-qt5/desktop-utils/lumina-terminal/TermWindow.h index d21fe502..5f583126 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TermWindow.h +++ b/src-qt5/desktop-utils/lumina-terminal/TermWindow.h @@ -41,6 +41,7 @@ private: bool onTop, CLOSING; QPropertyAnimation *ANIM; int animRunning; //internal flag for what animation is currently running + QTimer *activeTimer; //Calculate the window geometry necessary based on screen/location void CalculateGeom(); diff --git a/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp b/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp index 6342be59..83474f04 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp +++ b/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.cpp @@ -19,7 +19,10 @@ TerminalWidget::TerminalWidget(QWidget *parent, QString dir) : QTextEdit(parent){ //Setup the text widget closing = false; - this->setStyleSheet("QTextEdit{ background: black; color: white; }"); + QPalette P = this->palette(); + P.setColor(QPalette::Base, Qt::black); + P.setColor(QPalette::Text, Qt::white); + this->setPalette(P); this->setLineWrapMode(QTextEdit::WidgetWidth); this->setAcceptRichText(false); this->setOverwriteMode(true); @@ -37,14 +40,15 @@ TerminalWidget::TerminalWidget(QWidget *parent, QString dir) : QTextEdit(parent) QFontDatabase FDB; QStringList fonts = FDB.families(QFontDatabase::Latin); for(int i=0; i<fonts.length(); i++){ - if(FDB.isFixedPitch(fonts[i])){ this->setFont(QFont(fonts[i])); qDebug() << "Using Font:" << fonts[i]; break; } + if(FDB.isFixedPitch(fonts[i]) && FDB.isSmoothlyScalable(fonts[i]) ){ this->setFont(QFont(fonts[i])); qDebug() << "Using Font:" << fonts[i]; break; } + //if(FDB.isSmoothlyScalable(fonts[i]) ){ this->setFont(QFont(fonts[i])); qDebug() << "Using Font:" << fonts[i]; break; } } //Create/open the TTY port PROC = new TTYProcess(this); - qDebug() << "Open new TTY"; + //qDebug() << "Open new TTY"; //int fd; bool ok = PROC->startTTY( QProcessEnvironment::systemEnvironment().value("SHELL","/bin/sh"), QStringList(), dir); - qDebug() << " - opened:" << ok; + //qDebug() << " - opened:" << ok; this->setEnabled(PROC->isOpen()); contextMenu = new QMenu(this); copyA = contextMenu->addAction(LXDG::findIcon("edit-copy"), tr("Copy Selection"), this, SLOT(copySelection()) ); @@ -59,10 +63,14 @@ TerminalWidget::~TerminalWidget(){ aboutToClose(); } +void TerminalWidget::setTerminalFont(QFont font){ + this->setFont(font); +} + void TerminalWidget::aboutToClose(){ closing = true; if(PROC->isOpen()){ PROC->closeTTY(); } //TTY PORT - //delete PROC-> + } // ================== @@ -82,7 +90,7 @@ void TerminalWidget::InsertText(QString txt){ sel.cursor = cur; sels << sel; this->setExtraSelections(sels); - //qDebug() << "New Text. Format:" << CFMT.foreground() << CFMT.font(); + //qDebug() << "New Text Format:"<< txt << CFMT.foreground() << CFMT.font() << CFMT.fontWeight(); } void TerminalWidget::applyData(QByteArray data){ @@ -93,10 +101,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' ){ @@ -115,10 +128,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(); @@ -131,7 +140,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; } @@ -414,7 +423,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); } } @@ -484,9 +493,11 @@ void TerminalWidget::mousePressEvent(QMouseEvent *ev){ } void TerminalWidget::mouseMoveEvent(QMouseEvent *ev){ - if(ev->button()==Qt::LeftButton){ + //qDebug() << "MouseMove Event" << ev->button() << ev->buttons() << Qt::LeftButton; + if(ev->buttons().testFlag(Qt::LeftButton) ){ selCursor.setPosition(this->cursorForPosition(ev->pos()).position(), QTextCursor::KeepAnchor); if(selCursor.hasSelection()){ this->setTextCursor(selCursor); } + //qDebug() << "Mouse Movement:" << selCursor.hasSelection(); }else{ QTextEdit::mouseMoveEvent(ev); } diff --git a/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.h b/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.h index bdec606b..16509cb4 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.h +++ b/src-qt5/desktop-utils/lumina-terminal/TerminalWidget.h @@ -23,6 +23,7 @@ public: TerminalWidget(QWidget *parent =0, QString dir=""); ~TerminalWidget(); + void setTerminalFont(QFont); void aboutToClose(); private: diff --git a/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp b/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp index a1ee0be7..88eeb1ec 100644 --- a/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp +++ b/src-qt5/desktop-utils/lumina-terminal/TtyProcess.cpp @@ -4,11 +4,14 @@ #include <QProcessEnvironment> #include <QTimer> +#define DEBUG 0 + TTYProcess::TTYProcess(QObject *parent) : QObject(parent){ childProc = 0; sn = 0; ttyfd = 0; starting = true; + fixReply = -1; } TTYProcess::~TTYProcess(){ @@ -20,10 +23,26 @@ 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 - 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("TERM","vt220-color",1);//"vt102-color",1); //vt100: VT100 emulation support (QTerminal sets "xterm" here) + //unsetenv("TERM"); + //unsetenv("TERMCAP"); + setenv("TERMCAP","xterm",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"); } @@ -44,12 +63,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; @@ -60,13 +81,8 @@ 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); - //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 + if(DEBUG){ qDebug() << " - PTY:" << ptsname(FD); } starting = true; - //writeTTY("\n"); //newline - //writeTTY(QByteArray("\x1b[2J") ); //clear display return true; } } @@ -86,6 +102,9 @@ void TTYProcess::closeTTY(){ void TTYProcess::writeTTY(QByteArray output){ //qDebug() << "Write:" << output; + static QList<QByteArray> knownFixes; + if(knownFixes.isEmpty()){ knownFixes << "\x1b[C" << "\x1b[D" << "\b" << "\x7F" << "\x08"; } + fixReply = knownFixes.indexOf(output); ::write(ttyfd, output.data(), output.size()); } @@ -110,7 +129,9 @@ 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") ){ //qDebug() << "Starting phase 1:" << BA; writeTTY("\n\b"); //newline + backspace @@ -120,6 +141,37 @@ 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) + // 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){ + 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){ + BA.remove(0,1); + BA.prepend("\x1b[C"); //just move the cursor - don't re-print that 1 character + } + break; + case 1: //Left arrow ("\x1b[D") - PTY erases the previous character instead of moving the cursor + if(BA.startsWith("\b")){ + BA.remove(0,1); + BA.prepend("\x1b[D"); //just move the cursor - don't send the "back" character (\b) + } + break; + 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) + } + } + break; + } + fixReply = -1; //done with the fix - resume normal operations + if(DEBUG){ qDebug() << " - Fixed:" << BA; } + } return BA; } } @@ -182,6 +234,30 @@ 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"); + } +//Terminal Status request + index = raw.indexOf("\x1b[5n"); + while(index>=0){ + raw = raw.remove(index,1); + index = raw.indexOf("\x1b[5n"); + //Also send the proper reply to this identify request right away + writeTTY("\x1b[c"); //everything ok + } +//Terminal Identify request + index = raw.indexOf("\x1b[c"); + while(index>=0){ + raw = raw.remove(index,1); + index = raw.indexOf("\x1b[?1;7c"); + //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 |