Skip to content

Commit

Permalink
Merge branch 'ansifix' into silica
Browse files Browse the repository at this point in the history
Cherry-picked commits provided by urjaman.

Fixes nemomobile#34.
  • Loading branch information
Ape committed Jul 16, 2015
2 parents d82635a + cb83d50 commit f542177
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 9 deletions.
70 changes: 62 additions & 8 deletions src/terminal.cpp
Expand Up @@ -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<iTabStops[cursorPos().y()-1].count(); i++) {
if(iTabStops[cursorPos().y()-1][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
}
Expand Down Expand Up @@ -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<iTabStops[cursorPos().y()-1].count(); i++) {
if(iTabStops[cursorPos().y()-1][i] > cursorPos().x()) {
setCursorPos(QPoint( iTabStops[cursorPos().y()-1][i], cursorPos().y() ));
break;
}
}
}
}


void Terminal::ansiSequence(const QString& seq)
{
Expand Down Expand Up @@ -609,6 +626,43 @@ 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 'I':
if(!extra.isEmpty() || (params.count()>1)) {
unhandled=true;
break;
}
if (params.count()==0) {
params.append(1);
}
for (int i=0;i<params.at(0);i++) {
forwardTab();
}
break;

case 'Z':
if(!extra.isEmpty() || (params.count()>1)) {
unhandled=true;
break;
}
if (params.count()==0) {
params.append(1);
}
for (int i=0;i<params.at(0);i++) {
backwardTab();
}
break;

case 'L': // insert lines
if(!extra.isEmpty()) {
unhandled=true;
Expand Down
4 changes: 3 additions & 1 deletion src/terminal.h
Expand Up @@ -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;
Expand Down

0 comments on commit f542177

Please sign in to comment.