]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
fixed tab expansion
authorewt <ewt>
Tue, 10 Aug 1999 16:17:46 +0000 (16:17 +0000)
committerewt <ewt>
Tue, 10 Aug 1999 16:17:46 +0000 (16:17 +0000)
textbox.c

index 8ce1bda79ac874b21baf993cdcb7613843d0a5e9..331cb8f039390be9761b48087e96c5d4c9a9d1fc 100644 (file)
--- a/textbox.c
+++ b/textbox.c
@@ -118,6 +118,7 @@ static char * expandTabs(const char * text) {
     char * buf, * dest;
     const char * src;
     int bufUsed = 0;
+    int linePos = 0;
     int i;
 
     buf = malloc(bufAlloced + 1);
@@ -128,10 +129,15 @@ static char * expandTabs(const char * text) {
            dest = buf + bufUsed;
        }
        if (*src == '\t') {
-           i = 8 - (bufUsed & 8);
+           i = 8 - (linePos & 8);
            memset(dest, ' ', i);
-           dest += i, bufUsed += i;
+           dest += i, bufUsed += i, linePos += i;
        } else {
+           if (*src == '\n')
+               linePos = 0;
+           else
+               linePos++;
+
            *dest++ = *src;
            bufUsed++;
        }