[implement settable tabs
John Meacham <john@repetae.net>**20050725025537] {
addfile ./bitfield.h
hunk ./bitfield.h 1
+
+#include <malloc.h>
+
+typedef unsigned char bitfield_t;
+
+extern inline bitfield_t *
+bitfield_calloc(int size)
+{
+        return calloc(1, 1 + ((size_t)size / 8));
+}
+
+extern inline int
+change_bit(bitfield_t *addr, int nr, int wh)
+{
+        int	mask, retval;
+
+        addr += nr >> 3;
+        mask = 1 << (nr & 0x7);
+        retval = (mask & *addr) != 0;
+        if(wh) 
+                *addr |= mask;
+        else 
+                *addr &= ~mask;
+        return retval;
+}
+
+extern inline int
+set_bit(bitfield_t * addr, int nr)
+{
+	int	mask, retval;
+
+	addr += nr >> 3;
+	mask = 1 << (nr & 0x7);
+	retval = (mask & *addr) != 0;
+	*addr |= mask;
+	return retval;
+}
+
+extern inline int
+clear_bit(bitfield_t * addr, int nr)
+{
+	int	mask, retval;
+
+	addr += nr >> 3;
+	mask = 1 << (nr & 0x7);
+	retval = (mask & *addr) != 0;
+	*addr &= ~mask;
+	return retval;
+}
+
+extern inline int
+test_bit(bitfield_t * addr, int nr)
+{
+	int	mask;
+
+	addr += nr >> 3;
+	mask = 1 << (nr & 0x7);
+	return ((mask & *addr) != 0);
+}
+
+
hunk ./emulator.c 139
+        e->tabs = NULL;
hunk ./emulator.c 148
+        int i;
+        bitfield_t *tabs;
hunk ./emulator.c 154
+
+        tabs = bitfield_calloc(c);
+        for (i = 0; i < MIN(e->cols,c); ++i) 
+                change_bit(tabs,i,test_bit(e->tabs,i));
+
+        for (i = e->cols; i < c; ++i) 
+                change_bit(tabs, i, (0 == i % 8));
+        free(e->tabs);
+        e->tabs = tabs;
hunk ./emulator.c 262
-//            if (cursor.col < cols - 1) 
-//                cursor.col = cursor.col + 1;
-//            while (cursor.col < cols - 1 && !tabs[cursor.col])
-//                cursor.col = cursor.col + 1;  
-            e->cursor.col = ((e->cursor.col + 8) / 8) * 8; 
+            if (e->cursor.col < e->cols - 1) 
+                e->cursor.col = e->cursor.col + 1;
+            while (e->cursor.col < e->cols - 1 && !test_bit(e->tabs,e->cursor.col))
+                e->cursor.col = e->cursor.col + 1;  
+//            e->cursor.col = ((e->cursor.col + 8) / 8) * 8; 
hunk ./emulator.c 912
+        case 'Z': // Backtab
+            if (e->cursor.col > 0) 
+                e->cursor.col = e->cursor.col - 1;
+            while (e->cursor.col > 0 && !test_bit(e->tabs,e->cursor.col))
+                e->cursor.col = e->cursor.col - 1;  
+            return;
+
+
hunk ./emulator.c 1013
+                case 'H':
+                        if (!e->mode_decanm) {
+                                e->cursor.col = 0;
+                                e->cursor.row = (e->cursor.mode_decom) ? e->scroll_begin : 0;
+                        }
+                        else if (e->cursor.col >= 0 && e->cursor.col < e->cols) // HTS
+                                set_bit(e->tabs,e->cursor.col);
+                        //else if (e->cursor.col >= 0 && e->cursor.col < int(tabs.size())) // HTS
+                        //        e->tabs[e->cursor.col] = true;
+                        return;
+                case 'N':
+                        e->cursor.charset = 2;
+                        return;
+                case 'O':
+                        e->cursor.charset = 3;
+                        return;
hunk ./emulator.c 1037
-                           return;
-                           case 'H':
-                           if (!mode_decanm) {
-                           cursor.col = 0;
-                           cursor.row = (cursor.mode_decom) ? int(scroll_begin) : 0;
-                           }
-                           else if (cursor.col >= 0 && cursor.col < int(tabs.size())) // HTS
-                           tabs[cursor.col] = true;
-                           return;
-                           case 'N':
-                           cursor.charset = charset[2];
-                           return;
-                           case 'O':
-                           cursor.charset = charset[3];
hunk ./emulator.h 13
+#include "bitfield.h"
hunk ./emulator.h 66
+        bitfield_t *tabs;
hunk ./seven.c 217
-        unsigned char buf[41];
+        char buf[41];
hunk ./tests/charset.sh 7
+echo "	a	b1	c123	d1234	e"
+echo "	1	2	3	4	5"
}
