fixed wrap around problem
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Thu, 18 Aug 1983 07:36:27 +0000 (23:36 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Thu, 18 Aug 1983 07:36:27 +0000 (23:36 -0800)
SCCS-vsn: usr.bin/window/tth19.c 3.7
SCCS-vsn: usr.bin/window/ttgeneric.c 3.9

usr/src/usr.bin/window/ttgeneric.c
usr/src/usr.bin/window/tth19.c

index c990511..1e5cf8e 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttgeneric.c 3.8 83/08/17";
+static char *sccsid = "@(#)ttgeneric.c 3.9 83/08/17";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -110,6 +110,8 @@ gen_delline()
 gen_putc(c)
 register char c;
 {
 gen_putc(c)
 register char c;
 {
+       if (gen_AM && gen_row == gen_LI - 1 && gen_col + 1 >= gen_CO)
+               return;
        if (gen_insert) {
                if (gen_IC)
                        tt_tputs(gen_IC, gen_CO - gen_col);
        if (gen_insert) {
                if (gen_IC)
                        tt_tputs(gen_IC, gen_CO - gen_col);
@@ -118,12 +120,20 @@ register char c;
                        tt_tputs(gen_IP, gen_CO - gen_col);
        } else
                putchar(c);
                        tt_tputs(gen_IP, gen_CO - gen_col);
        } else
                putchar(c);
-       gen_col++;
+       if (++gen_col >= gen_CO)
+               if (gen_AM) {
+                       gen_col = 0;
+                       gen_row++;
+               } else
+                       gen_col--;
 }
 
 gen_write(start, end)
 register char *start, *end;
 {
 }
 
 gen_write(start, end)
 register char *start, *end;
 {
+       if (gen_AM && gen_row == gen_LI - 1
+           && gen_col + (end - start + 1) >= gen_CO)
+               end--;
        if (gen_insert) {
                while (start <= end) {
                        if (gen_IC)
        if (gen_insert) {
                while (start <= end) {
                        if (gen_IC)
@@ -138,11 +148,19 @@ register char *start, *end;
                while (start <= end)
                        putchar(*start++);
        }
                while (start <= end)
                        putchar(*start++);
        }
+       if (gen_col >= gen_CO)
+               if (gen_AM) {
+                       gen_col = 0;
+                       gen_row++;
+               } else
+                       gen_col--;
 }
 
 gen_blank(n)
 register n;
 {
 }
 
 gen_blank(n)
 register n;
 {
+       if (gen_AM && gen_row == gen_LI - 1 && gen_col + n >= gen_CO)
+               n--;
        if (n <= 0)
                return;
        if (gen_insert) {
        if (n <= 0)
                return;
        if (gen_insert) {
@@ -159,6 +177,12 @@ register n;
                while (--n >= 0)
                        putchar(' ');
        }
                while (--n >= 0)
                        putchar(' ');
        }
+       if (gen_col >= gen_CO)
+               if (gen_AM) {
+                       gen_col = 0;
+                       gen_row++;
+               } else
+                       gen_col--;
 }
 
 gen_move(row, col)
 }
 
 gen_move(row, col)
@@ -329,8 +353,6 @@ tt_generic()
        if (gen_CL)
                tt.tt_clear = gen_clear;
        tt.tt_ncol = gen_CO;
        if (gen_CL)
                tt.tt_clear = gen_clear;
        tt.tt_ncol = gen_CO;
-       if (gen_AM)
-               tt.tt_ncol--;
        tt.tt_nrow = gen_LI;
        tt.tt_init = gen_init;
        tt.tt_end = gen_end;
        tt.tt_nrow = gen_LI;
        tt.tt_init = gen_init;
        tt.tt_end = gen_end;
index eb59b73..f9ce5b0 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)tth19.c     3.6 83/08/17";
+static char *sccsid = "@(#)tth19.c     3.7 83/08/17";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -91,7 +91,8 @@ register char c;
        }
        if (h19_insert)
                ICPAD();
        }
        if (h19_insert)
                ICPAD();
-       h19_col++;
+       if (++h19_col >= 80)
+               h19_col = 79;
 }
 
 h19_write(start, end)
 }
 
 h19_write(start, end)
@@ -124,6 +125,8 @@ register char *start, *end;
                                putchar(c);
                        }
        }
                                putchar(c);
                        }
        }
+       if (h19_col >= 80)
+               h19_col = 79;
 }
 
 h19_blank(n)
 }
 
 h19_blank(n)
@@ -144,6 +147,8 @@ register n;
                while (--n >= 0)
                        putchar(' ');
        }
                while (--n >= 0)
                        putchar(' ');
        }
+       if (h19_col >= 80)
+               h19_col = 79;
 }
 
 h19_move(row, col)
 }
 
 h19_move(row, col)