From aea2fc86a49a83ed8a9c23c92d8ebe174a36cdca Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 14 Mar 2016 11:00:00 -0400 Subject: Finish getting the special keys handled in lumina-terminal. Now the terminal is completely functional - I just have other special ANSI codes (colors for particular text) to implement still (but this is just for appearance-sake). --- desktop-utilities/lumina-terminal/TerminalWidget.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/desktop-utilities/lumina-terminal/TerminalWidget.cpp b/desktop-utilities/lumina-terminal/TerminalWidget.cpp index a8947f75..3d247d5f 100644 --- a/desktop-utilities/lumina-terminal/TerminalWidget.cpp +++ b/desktop-utilities/lumina-terminal/TerminalWidget.cpp @@ -128,13 +128,22 @@ void TerminalWidget::applyANSI(QByteArray code){ qDebug() << "Erase Number" << num; //Now determine what should be cleared based on code if(num==1){ - + //Clear from current cursor to beginning of line + for(int i=this->textCursor().position(); i>=0; i--){ + if(this->document()->characterAt(this->textCursor().position())=='\n'){ break; } + this->textCursor().deleteChar(); + } }else if(num==2){ - + //Clear the entire line + // rewind the starting point to the beginning of the line + int start = this->document()->find("\n", this->textCursor().position(), QTextDocument::FindBackward).position(); + for(int i=start+1; idocument()->characterCount()+1; i++){ + if(this->document()->characterAt(this->textCursor().position())=='\n'){ break; } + this->textCursor().deleteChar(); + } }else{ //Clear from current cursor to end of line for(int i=this->textCursor().position(); idocument()->characterCount()+1; i++){ - //while(this->document()->characterAt(this->textCursor().position())!=QChar('\n') && this->textCursor().position() < this->document()->characterCount()){ if(this->document()->characterAt(this->textCursor().position())=='\n'){ break; } this->textCursor().deleteChar(); } -- cgit