From 5e785082cfacac9cac7d1509b4cfd6bd8669e41d Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Thu, 18 Aug 1983 00:41:26 -0800 Subject: [PATCH] better wrap around handling. SCCS-vsn: usr.bin/window/wwinit.c 3.6 SCCS-vsn: usr.bin/window/ww.h 3.6 SCCS-vsn: usr.bin/window/tt.h 3.6 SCCS-vsn: usr.bin/window/tth19.c 3.8 SCCS-vsn: usr.bin/window/wwinschar.c 3.6 SCCS-vsn: usr.bin/window/wwupdate.c 3.6 SCCS-vsn: usr.bin/window/ttgeneric.c 3.10 --- usr/src/usr.bin/window/tt.h | 3 +- usr/src/usr.bin/window/ttgeneric.c | 45 ++++++++++++------------------ usr/src/usr.bin/window/tth19.c | 8 +++--- usr/src/usr.bin/window/ww.h | 3 +- usr/src/usr.bin/window/wwinit.c | 3 +- usr/src/usr.bin/window/wwinschar.c | 5 ++-- usr/src/usr.bin/window/wwupdate.c | 28 ++++++++++++++++--- 7 files changed, 55 insertions(+), 40 deletions(-) diff --git a/usr/src/usr.bin/window/tt.h b/usr/src/usr.bin/window/tt.h index 798fe79c61..85480fb277 100644 --- a/usr/src/usr.bin/window/tt.h +++ b/usr/src/usr.bin/window/tt.h @@ -1,5 +1,5 @@ /* - * @(#)tt.h 3.5 83/08/17 + * @(#)tt.h 3.6 83/08/17 */ struct tt { @@ -20,6 +20,7 @@ struct tt { int tt_nrow; int tt_ncol; char tt_availmodes; + char tt_wrap; /* has auto wrap around */ char *tt_frame; }; diff --git a/usr/src/usr.bin/window/ttgeneric.c b/usr/src/usr.bin/window/ttgeneric.c index 1e5cf8e314..dc34b9a38f 100644 --- a/usr/src/usr.bin/window/ttgeneric.c +++ b/usr/src/usr.bin/window/ttgeneric.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)ttgeneric.c 3.9 83/08/17"; +static char *sccsid = "@(#)ttgeneric.c 3.10 83/08/17"; #endif #include "ww.h" @@ -110,8 +110,6 @@ gen_delline() 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); @@ -120,20 +118,16 @@ register char c; tt_tputs(gen_IP, gen_CO - gen_col); } else putchar(c); - if (++gen_col >= gen_CO) - if (gen_AM) { - gen_col = 0; - gen_row++; - } else + if (++gen_col == gen_CO) + if (gen_AM) + gen_col = 0, gen_row++; + else gen_col--; } 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) @@ -148,19 +142,16 @@ register char *start, *end; while (start <= end) putchar(*start++); } - if (gen_col >= gen_CO) - if (gen_AM) { - gen_col = 0; - gen_row++; - } else + if (gen_col == gen_CO) + if (gen_AM) + gen_col = 0, gen_row++; + else gen_col--; } 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) { @@ -177,11 +168,10 @@ register n; while (--n >= 0) putchar(' '); } - if (gen_col >= gen_CO) - if (gen_AM) { - gen_col = 0; - gen_row++; - } else + if (gen_col == gen_CO) + if (gen_AM) + gen_col = 0, gen_row++; + else gen_col--; } @@ -334,10 +324,6 @@ tt_generic() ospeed = wwoldtty.ww_sgttyb.sg_ospeed; } - if (gen_SO) - tt.tt_availmodes |= WWM_REV; - if (gen_US) - tt.tt_availmodes |= WWM_UL; if (gen_IM) tt.tt_setinsert = gen_setinsert; if (gen_DC) @@ -352,6 +338,11 @@ tt_generic() tt.tt_clreos = gen_clreos; if (gen_CL) tt.tt_clear = gen_clear; + if (gen_SO) + tt.tt_availmodes |= WWM_REV; + if (gen_US) + tt.tt_availmodes |= WWM_UL; + tt.tt_wrap = gen_AM; tt.tt_ncol = gen_CO; tt.tt_nrow = gen_LI; tt.tt_init = gen_init; diff --git a/usr/src/usr.bin/window/tth19.c b/usr/src/usr.bin/window/tth19.c index f9ce5b07ae..bad08d32bb 100644 --- a/usr/src/usr.bin/window/tth19.c +++ b/usr/src/usr.bin/window/tth19.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)tth19.c 3.7 83/08/17"; +static char *sccsid = "@(#)tth19.c 3.8 83/08/17"; #endif #include "ww.h" @@ -91,7 +91,7 @@ register char c; } if (h19_insert) ICPAD(); - if (++h19_col >= 80) + if (++h19_col == 80) h19_col = 79; } @@ -125,7 +125,7 @@ register char *start, *end; putchar(c); } } - if (h19_col >= 80) + if (h19_col == 80) h19_col = 79; } @@ -147,7 +147,7 @@ register n; while (--n >= 0) putchar(' '); } - if (h19_col >= 80) + if (h19_col == 80) h19_col = 79; } diff --git a/usr/src/usr.bin/window/ww.h b/usr/src/usr.bin/window/ww.h index 7a167f050b..e26ba5fd58 100644 --- a/usr/src/usr.bin/window/ww.h +++ b/usr/src/usr.bin/window/ww.h @@ -1,5 +1,5 @@ /* - * @(#)ww.h 3.5 83/08/17 + * @(#)ww.h 3.6 83/08/17 */ #include @@ -116,6 +116,7 @@ char wwkeys[512]; /* termcap fields for the function keys */ int wwnrow, wwncol; /* the screen size */ char wwavailmodes; /* actually supported modes */ +char wwwrap; /* terminal has auto wrap around */ int wwdtablesize; /* result of getdtablesize() call */ char **wwsmap; /* the screen map */ char **wwfmap; /* the frame map */ diff --git a/usr/src/usr.bin/window/wwinit.c b/usr/src/usr.bin/window/wwinit.c index b2dd8dfff9..4508893045 100644 --- a/usr/src/usr.bin/window/wwinit.c +++ b/usr/src/usr.bin/window/wwinit.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwinit.c 3.5 83/08/17"; +static char *sccsid = "@(#)wwinit.c 3.6 83/08/17"; #endif #include "ww.h" @@ -42,6 +42,7 @@ wwinit() wwnrow = tt.tt_nrow; wwncol = tt.tt_ncol; wwavailmodes = tt.tt_availmodes; + wwwrap = tt.tt_wrap; (*tt.tt_init)(); if ((wwsmap = wwalloc(wwnrow, wwncol, sizeof (char))) == 0) diff --git a/usr/src/usr.bin/window/wwinschar.c b/usr/src/usr.bin/window/wwinschar.c index 8a52ac566d..53a17ce802 100644 --- a/usr/src/usr.bin/window/wwinschar.c +++ b/usr/src/usr.bin/window/wwinschar.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwinschar.c 3.5 83/08/17"; +static char *sccsid = "@(#)wwinschar.c 3.6 83/08/17"; #endif #include "ww.h" @@ -67,7 +67,8 @@ short c; } col += w->ww_w.l; row += w->ww_w.t; - if (tt.tt_setinsert != 0 && nvis > (wwncol - col) / 2) { + if (tt.tt_setinsert != 0 && nvis > (wwncol - col) / 2 + && col != wwncol - 1) { register union ww_char *p, *q; (*tt.tt_setinsert)(1); diff --git a/usr/src/usr.bin/window/wwupdate.c b/usr/src/usr.bin/window/wwupdate.c index 003d3cff5f..bef1adfda1 100644 --- a/usr/src/usr.bin/window/wwupdate.c +++ b/usr/src/usr.bin/window/wwupdate.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)wwupdate.c 3.5 83/08/16"; +static char *sccsid = "@(#)wwupdate.c 3.6 83/08/17"; #endif #include "ww.h" @@ -16,6 +16,7 @@ wwupdate() char *touched; register didit; char buf[512]; /* > wwncol */ + union ww_char lastc; wwnupdate++; (*tt.tt_setinsert)(0); @@ -50,13 +51,32 @@ wwupdate() } else { x = 5; q = p; + lastc = *os; *os++ = *ns++; } j++; } - (*tt.tt_move)(i, c); - (*tt.tt_setmodes)(m); - (*tt.tt_write)(buf, q - 1); + if (wwwrap + && i == wwnrow - 1 && q - buf + c == wwncol) { + if (tt.tt_setinsert != 0) { + (*tt.tt_move)(i, c); + (*tt.tt_setmodes)(m); + (*tt.tt_write)(buf + 1, q - 1); + (*tt.tt_move)(i, c); + (*tt.tt_setinsert)(1); + (*tt.tt_write)(buf, buf); + (*tt.tt_setinsert)(0); + } else { + os[-1] = lastc; + (*tt.tt_move)(i, c); + (*tt.tt_setmodes)(m); + (*tt.tt_write)(buf, q - 2); + } + } else { + (*tt.tt_move)(i, c); + (*tt.tt_setmodes)(m); + (*tt.tt_write)(buf, q - 1); + } didit++; } if (!didit) -- 2.20.1