billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=fae0d7ccee8f6f1696cae2f83f05f3477a781228

commit fae0d7ccee8f6f1696cae2f83f05f3477a781228
Author: Boris Faure <bill...@gmail.com>
Date:   Thu Dec 15 22:57:30 2016 +0100

    termptyesc: handle correctly Cursor Back Tab. Ref T4992
---
 src/bin/termpty.c    |  2 ++
 src/bin/termptyesc.c | 29 ++++++++++++-----------------
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 80e2939..f7449a8 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1507,8 +1507,10 @@ termpty_cell_codepoint_att_fill(Termpty *ty, 
Eina_Unicode codepoint,
 
    for (i = 0; i < n; i++)
      {
+        int had_tabmarker = dst[i].att.tab;
         _handle_block_codepoint_overwrite(ty, dst[i].codepoint, codepoint);
         dst[i] = local;
+        dst[i].att.tab = had_tabmarker;
      }
 }
 
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 14fe55d..1188d8d 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1077,35 +1077,30 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, 
Eina_Unicode *ce)
         break;
  */
       case 'g': // clear tabulation
+        /* TODO: handle correctly */
         arg = _csi_arg_get(&b);
         DBG("Tabulation Clear (TBC): %d", arg);
         break;
-       case 'Z': // Cursor Back Tab
+       case 'Z':
        {
-          int idx, size, cx = ty->cursor_state.cx, cy = ty->cursor_state.cy;
+          int cx = ty->cursor_state.cx, cy = ty->cursor_state.cy;
 
           arg = _csi_arg_get(&b);
+          DBG("Cursor Backward Tabulation (CBT): %d", arg);
           if (arg < 1) arg = 1;
 
-          size = ty->w * cy + cx + 1;
-          for (idx = size - 1; idx >= 0; idx--)
+          for (; arg > 0; arg--)
             {
-               if (TERMPTY_SCREEN(ty, cx, cy).att.tab) arg--;
-               cx--;
-               if (cx < 0)
+               do
                  {
-                    cx = ty->w - 1;
-                    cy--;
+                    cx--;
                  }
-               if (!arg) break;
-            }
-          if (!arg)
-            {
-               ty->cursor_state.cx = cx;
-               TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
-               ty->cursor_state.cy = cy;
-               TERMPTY_RESTRICT_FIELD(ty->cursor_state.cy, 0, ty->h);
+               while ((cx >= 0) &&
+                      ((!TERMPTY_SCREEN(ty, cx, cy).att.tab) && (cx % 8 != 
0)));
             }
+
+          ty->cursor_state.cx = cx;
+          TERMPTY_RESTRICT_FIELD(ty->cursor_state.cx, 0, ty->w);
        }
        break;
       default:

-- 


Reply via email to