]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed tab handling for locating cursor coordinates
authorMike Lowis <mike.lowis@gentex.com>
Wed, 5 Oct 2016 13:00:08 +0000 (09:00 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Wed, 5 Oct 2016 13:00:08 +0000 (09:00 -0400)
screen.c

index c7843b94c0c5e4c604edafe019749a5ff8757c39..9035ac683fbe53e5f21d26fde58dc553176c00d6 100644 (file)
--- a/screen.c
+++ b/screen.c
@@ -134,6 +134,7 @@ static void sync_view(Buf* buf, unsigned csr) {
 }
 
 void screen_update(Buf* buf, unsigned csr, unsigned* csrx, unsigned* csry) {
+    /* scroll the view and reflow the screen lines */
     sync_view(buf, csr);
     if (buf->insert_mode)
         screen_reflow(buf);
@@ -142,8 +143,15 @@ void screen_update(Buf* buf, unsigned csr, unsigned* csrx, unsigned* csry) {
         unsigned start = Rows[y]->off;
         unsigned end   = Rows[y]->off + Rows[y]->rlen - 1;
         if (start <= csr && csr <= end) {
-            *csry = y;
-            *csrx = csr - start;
+            unsigned pos = start;
+            for (unsigned x = 0; x < NumCols;) {
+                if (pos == csr) {
+                    *csry = y, *csrx = x;
+                    break;
+                }
+                if (buf_get(buf,pos++) == '\t')
+                    x += (TabWidth - (x % TabWidth));
+            }
             break;
         }
     }