From 8f5b141392c5a4adc4eb32394e3336100ae3e817 Mon Sep 17 00:00:00 2001 From: Urja Rannikko Date: Mon, 24 Nov 2014 18:30:14 +0200 Subject: [PATCH 1/3] terminal: Add support for ansi sequence CSI n X - erase n chars --- src/terminal.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/terminal.cpp b/src/terminal.cpp index 227de61..9ebece9 100644 --- a/src/terminal.cpp +++ b/src/terminal.cpp @@ -609,6 +609,17 @@ void Terminal::ansiSequence(const QString& seq) } break; + case 'X': + if(!extra.isEmpty() || (params.count()>1)) { + unhandled=true; + break; + } + if (params.count()==0) { + params.append(1); + } + eraseLineAtCursor(cursorPos().x(),cursorPos().x()+(params.at(0)?params.at(0)-1:0)); + break; + case 'L': // insert lines if(!extra.isEmpty()) { unhandled=true; From 7d863801772bfdc9bbd7a2313ed3efedd87741bd Mon Sep 17 00:00:00 2001 From: urjaman Date: Mon, 24 Nov 2014 19:04:38 +0200 Subject: [PATCH 2/3] terminal: Add CSI n I and CSI n Z support and cleanup tab code (Next: terminal.h) --- src/terminal.cpp | 69 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/src/terminal.cpp b/src/terminal.cpp index 9ebece9..5244ebc 100644 --- a/src/terminal.cpp +++ b/src/terminal.cpp @@ -297,14 +297,7 @@ void Terminal::insertInBuffer(const QString& chars) } } else if(ch.toLatin1()=='\t') { //tab - if(cursorPos().y() <= iTabStops.size()) { - for(int i=0; i cursorPos().x()) { - setCursorPos(QPoint( iTabStops[cursorPos().y()-1][i], cursorPos().y() )); - break; - } - } - } + forwardTab(); } else if(ch.toLatin1()==14 || ch.toLatin1()==15) { //SI and SO, related to character set... ignore } @@ -457,6 +450,30 @@ void Terminal::clearAll(bool wholeBuffer) setCursorPos(QPoint(1,1)); } +void Terminal::backwardTab(void) +{ + if(cursorPos().y() <= iTabStops.size()) { + for(int i=iTabStops[cursorPos().y()-1].count()-1; i>=0; i--) { + if(iTabStops[cursorPos().y()-1][i] < cursorPos().x()) { + setCursorPos(QPoint( iTabStops[cursorPos().y()-1][i], cursorPos().y() )); + break; + } + } + } +} + +void Terminal::forwardTab(void) +{ + if(cursorPos().y() <= iTabStops.size()) { + for(int i=0; i cursorPos().x()) { + setCursorPos(QPoint( iTabStops[cursorPos().y()-1][i], cursorPos().y() )); + break; + } + } + } +} + void Terminal::ansiSequence(const QString& seq) { @@ -614,11 +631,37 @@ void Terminal::ansiSequence(const QString& seq) unhandled=true; break; } - if (params.count()==0) { - params.append(1); - } - eraseLineAtCursor(cursorPos().x(),cursorPos().x()+(params.at(0)?params.at(0)-1:0)); - break; + if (params.count()==0) { + params.append(1); + } + eraseLineAtCursor(cursorPos().x(),cursorPos().x()+(params.at(0)?params.at(0)-1:0)); + break; + + case 'I': + if(!extra.isEmpty() || (params.count()>1)) { + unhandled=true; + break; + } + if (params.count()==0) { + params.append(1); + } + for (int i=0;i1)) { + unhandled=true; + break; + } + if (params.count()==0) { + params.append(1); + } + for (int i=0;i Date: Mon, 24 Nov 2014 19:06:00 +0200 Subject: [PATCH 3/3] Add definitions for the previous commit (tab CSI support) --- src/terminal.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/terminal.h b/src/terminal.h index 134a93e..206d12c 100644 --- a/src/terminal.h +++ b/src/terminal.h @@ -123,7 +123,9 @@ class Terminal : public QObject void resetTerminal(); void resetTabs(); void adjustSelectionPosition(int lines); - + void forwardTab(); + void backwardTab(); + TextRender* iRenderer; PtyIFace* iPtyIFace; QQuickView* iWindow;