From 21f836c3b611614ec2e9b9a7cc68f0314eafbc2d Mon Sep 17 00:00:00 2001 From: skimo Date: Sun, 7 May 2000 19:49:39 +0000 Subject: [PATCH] use curses windows for screens --- cl/cl.h | 7 ++- cl/cl_bsd.c | 15 +++--- cl/cl_funcs.c | 138 +++++++++++++++++++++++++++++++++++++++--------------- cl/cl_screen.c | 12 +++-- common/gs.h | 4 +- common/screen.c | 3 +- common/screen.h | 3 +- dist/Makefile.in | 6 +-- dist/acconfig.h | 6 +-- dist/config.h.in | 4 +- dist/configure.in | 20 ++++---- ip/ip_funcs.c | 32 +++++++++++-- ipc/ip.h | 3 +- vi/vs_split.c | 49 ++++++++++++++----- 14 files changed, 211 insertions(+), 91 deletions(-) diff --git a/cl/cl.h b/cl/cl.h index 509c24be..5fb63ea4 100644 --- a/cl/cl.h +++ b/cl/cl.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: cl.h,v 10.22 1996/12/18 15:57:37 bostic Exp $ (Berkeley) $Date: 1996/12/18 15:57:37 $ + * $Id: cl.h,v 10.23 2000/05/07 19:49:39 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:39 $ */ typedef struct _cl_private { @@ -56,13 +56,18 @@ typedef struct _cl_private { #define CLP(sp) ((CL_PRIVATE *)((sp)->gp->cl_private)) #define GCLP(gp) ((CL_PRIVATE *)gp->cl_private) +#define CLSP(sp) ((WINDOW *)((sp)->cl_private)) /* Return possibilities from the keyboard read routine. */ typedef enum { INP_OK=0, INP_EOF, INP_ERR, INP_INTR, INP_TIMEOUT } input_t; /* The screen position relative to a specific window. */ +/* #define RCNO(sp, cno) (sp)->coff + (cno) #define RLNO(sp, lno) (sp)->roff + (lno) +*/ +#define RCNO(sp, cno) (cno) +#define RLNO(sp, lno) (lno) /* * XXX diff --git a/cl/cl_bsd.c b/cl/cl_bsd.c index 7970f36b..130f1d61 100644 --- a/cl/cl_bsd.c +++ b/cl/cl_bsd.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: cl_bsd.c,v 8.29 1996/07/01 10:03:17 bostic Exp $ (Berkeley) $Date: 1996/07/01 10:03:17 $"; +static const char sccsid[] = "$Id: cl_bsd.c,v 8.30 2000/05/07 19:49:39 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:39 $"; #endif /* not lint */ #include @@ -40,23 +40,24 @@ static char *vb; /* Visible bell string. */ * minimal set of functions. */ -#ifndef HAVE_CURSES_ADDNSTR +#ifndef HAVE_CURSES_WADDNSTR /* - * addnstr -- + * waddnstr -- * - * PUBLIC: #ifndef HAVE_CURSES_ADDNSTR - * PUBLIC: int addnstr __P((char *, int)); + * PUBLIC: #ifndef HAVE_CURSES_WADDNSTR + * PUBLIC: int waddnstr __P((WINDOW*, char *, int)); * PUBLIC: #endif */ int -addnstr(s, n) +waddnstr(w, s, n) + WINDOW *w; char *s; int n; { int ch; while (n-- && (ch = *s++)) - addch(ch); + waddch(w, ch); return (OK); } #endif diff --git a/cl/cl_funcs.c b/cl/cl_funcs.c index eacbef72..19f90840 100644 --- a/cl/cl_funcs.c +++ b/cl/cl_funcs.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: cl_funcs.c,v 10.56 1997/08/03 15:38:23 bostic Exp $ (Berkeley) $Date: 1997/08/03 15:38:23 $"; +static const char sccsid[] = "$Id: cl_funcs.c,v 10.57 2000/05/07 19:49:39 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:39 $"; #endif /* not lint */ #include @@ -46,28 +46,30 @@ cl_addstr(sp, str, len) size_t len; { CL_PRIVATE *clp; + WINDOW *win; size_t y, x; int iv; clp = CLP(sp); + win = CLSP(sp) ? CLSP(sp) : stdscr; /* * If ex isn't in control, it's the last line of the screen and * it's a split screen, use inverse video. */ iv = 0; - getyx(stdscr, y, x); + getyx(win, y, x); if (!F_ISSET(sp, SC_SCR_EXWROTE) && y == RLNO(sp, LASTLINE(sp)) && IS_SPLIT(sp)) { iv = 1; - (void)standout(); + (void)wstandout(win); } - if (addnstr(str, len) == ERR) + if (waddnstr(win, str, len) == ERR) return (1); if (iv) - (void)standend(); + (void)wstandend(win); return (0); } @@ -84,8 +86,10 @@ cl_attr(sp, attribute, on) int on; { CL_PRIVATE *clp; + WINDOW *win; clp = CLP(sp); + win = CLSP(sp) ? CLSP(sp) : stdscr; switch (attribute) { case SA_ALTERNATE: @@ -148,9 +152,9 @@ cl_attr(sp, attribute, on) (void)fflush(stdout); } else { if (on) - (void)standout(); + (void)wstandout(win); else - (void)standend(); + (void)wstandend(win); } break; default: @@ -212,7 +216,7 @@ int cl_bell(sp) SCR *sp; { - if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)) + if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE | SC_SCR_EX)) (void)write(STDOUT_FILENO, "\07", 1); /* \a */ else { /* @@ -237,17 +241,22 @@ int cl_clrtoeol(sp) SCR *sp; { + WINDOW *win; size_t spcnt, y, x; + win = CLSP(sp) ? CLSP(sp) : stdscr; + +#if 0 if (IS_VSPLIT(sp)) { /* The cursor must be returned to its original position. */ - getyx(stdscr, y, x); + getyx(win, y, x); for (spcnt = (sp->coff + sp->cols) - x; spcnt > 0; --spcnt) - (void)addch(' '); - (void)move(y, x); + (void)waddch(win, ' '); + (void)wmove(win, y, x); return (0); } else - return (clrtoeol() == ERR); +#endif + return (wclrtoeol(win) == ERR); } /* @@ -261,6 +270,8 @@ cl_cursor(sp, yp, xp) SCR *sp; size_t *yp, *xp; { + WINDOW *win; + win = CLSP(sp) ? CLSP(sp) : stdscr; /* * The curses screen support splits a single underlying curses screen * into multiple screens to support split screen semantics. For this @@ -268,9 +279,11 @@ cl_cursor(sp, yp, xp) * current screen, and not absolute. Screens that implement the split * using physically distinct screens won't need this hack. */ - getyx(stdscr, *yp, *xp); + getyx(win, *yp, *xp); + /* *yp -= sp->roff; *xp -= sp->coff; + */ return (0); } @@ -286,9 +299,11 @@ cl_deleteln(sp) { CHAR_T ch; CL_PRIVATE *clp; + WINDOW *win; size_t col, lno, spcnt, y, x; clp = CLP(sp); + win = CLSP(sp) ? CLSP(sp) : stdscr; /* * This clause is required because the curses screen uses reverse @@ -309,50 +324,72 @@ cl_deleteln(sp) * character following. */ if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) { - getyx(stdscr, y, x); + getyx(win, y, x); #ifdef mvchgat - mvchgat(RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL); + mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL); #else for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) { - (void)move(lno, col); - ch = winch(stdscr); + (void)wmove(win, lno, col); + ch = winch(win); if (isblank(ch)) ++spcnt; else { - (void)move(lno, col - spcnt); + (void)wmove(win, lno, col - spcnt); for (; spcnt > 0; --spcnt) - (void)addch(' '); - (void)addch(ch); + (void)waddch(win, ' '); + (void)waddch(win, ch); } if (++col >= sp->cols) break; } #endif - (void)move(y, x); + (void)wmove(win, y, x); } /* * The bottom line is expected to be blank after this operation, * and other screens must support that semantic. */ - return (deleteln() == ERR); + return (wdeleteln(win) == ERR); } /* * cl_discard -- * Discard a screen. * - * PUBLIC: int cl_discard __P((SCR *, SCR *)); + * PUBLIC: int cl_discard __P((SCR *, SCR **)); */ int cl_discard(discardp, acquirep) - SCR *discardp, *acquirep; + SCR *discardp, **acquirep; { CL_PRIVATE *clp; + SCR* tsp; + if (discardp) { clp = CLP(discardp); F_SET(clp, CL_LAYOUT); + if (CLSP(discardp)) { + delwin(CLSP(discardp)); + CLSP(discardp) = NULL; + } + } + + /* no screens got a piece; we're done */ + if (!acquirep) + return 0; + + for (; (tsp = *acquirep) != NULL; ++acquirep) { + clp = CLP(tsp); + F_SET(clp, CL_LAYOUT); + + if (CLSP(tsp)) + delwin(CLSP(tsp)); + CLSP(tsp) = subwin(stdscr, tsp->rows, tsp->cols, + tsp->roff, tsp->coff); + } + /* discardp is going away, acquirep is taking up its space. */ return (0); } @@ -425,11 +462,13 @@ int cl_insertln(sp) SCR *sp; { + WINDOW *win; + win = CLSP(sp) ? CLSP(sp) : stdscr; /* * The current line is expected to be blank after this operation, * and the screen must support that semantic. */ - return (insertln() == ERR); + return (winsertln(win) == ERR); } /* @@ -485,8 +524,10 @@ cl_move(sp, lno, cno) SCR *sp; size_t lno, cno; { + WINDOW *win; + win = CLSP(sp) ? CLSP(sp) : stdscr; /* See the comment in cl_cursor. */ - if (move(RLNO(sp, lno), RCNO(sp, cno)) == ERR) { + if (wmove(win, RLNO(sp, lno), RCNO(sp, cno)) == ERR) { msgq(sp, M_ERR, "Error: move: l(%u + %u) c(%u + %u)", lno, sp->roff, cno, sp->coff); return (1); @@ -507,11 +548,13 @@ cl_refresh(sp, repaint) { GS *gp; CL_PRIVATE *clp; + WINDOW *win; SCR *psp, *tsp; size_t y, x; gp = sp->gp; clp = CLP(sp); + win = CLSP(sp) ? CLSP(sp) : stdscr; /* * If we received a killer signal, we're done, there's no point @@ -530,13 +573,18 @@ cl_refresh(sp, repaint) * draw a dividing line. */ if (repaint || F_ISSET(clp, CL_LAYOUT)) { - getyx(stdscr, y, x); + getyx(win, y, x); for (psp = sp; psp != (void *)&gp->dq; psp = psp->q.cqe_next) for (tsp = psp->q.cqe_next; tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next) - if (psp->roff == tsp->roff) + if (psp->roff == tsp->roff) { + if (psp->coff + psp->cols + 1 == tsp->coff) + cl_rdiv(psp); + else + if (tsp->coff + tsp->cols + 1 == psp->coff) cl_rdiv(tsp); - (void)move(y, x); + } + (void)wmove(win, y, x); F_CLR(clp, CL_LAYOUT); } @@ -547,7 +595,7 @@ cl_refresh(sp, repaint) */ if (repaint) clearok(curscr, 1); - return (refresh() == ERR); + return (wrefresh(stdscr) == ERR || wrefresh(win) == ERR); } /* @@ -558,11 +606,14 @@ static void cl_rdiv(sp) SCR *sp; { + WINDOW *win; size_t cnt; + win = CLSP(sp) ? CLSP(sp) : stdscr; + for (cnt = 0; cnt < sp->rows - 1; ++cnt) { - move(sp->roff + cnt, sp->cols + 1); - addch('|'); + wmove(stdscr, sp->roff + cnt, sp->cols + sp->coff); + waddch(stdscr, '|'); } } @@ -663,6 +714,14 @@ cl_split(origp, newp) clp = CLP(origp); F_SET(clp, CL_LAYOUT); + if (CLSP(origp)) + delwin(CLSP(origp)); + + CLSP(origp) = subwin(stdscr, origp->rows, origp->cols, + origp->roff, origp->coff); + CLSP(newp) = subwin(stdscr, newp->rows, newp->cols, + newp->roff, newp->coff); + /* origp is the original screen, giving up space to newp. */ return (0); } @@ -680,12 +739,14 @@ cl_suspend(sp, allowedp) { struct termios t; CL_PRIVATE *clp; + WINDOW *win; GS *gp; size_t y, x; int changed; gp = sp->gp; clp = CLP(sp); + win = CLSP(sp) ? CLSP(sp) : stdscr; *allowedp = 1; /* @@ -725,9 +786,9 @@ cl_suspend(sp, allowedp) * Not sure this is necessary in System V implementations, but it * shouldn't hurt. */ - getyx(stdscr, y, x); - (void)move(LINES - 1, 0); - (void)refresh(); + getyx(win, y, x); + (void)wmove(win, LINES - 1, 0); + (void)wrefresh(win); /* * Temporarily end the screen. System V introduced a semantic where @@ -736,10 +797,8 @@ cl_suspend(sp, allowedp) * restarting after endwin(), so we have to do what clean up we can * without calling it. */ -#ifdef HAVE_BSD_CURSES /* Save the terminal settings. */ (void)tcgetattr(STDIN_FILENO, &t); -#endif /* Restore the cursor keys to normal mode. */ (void)keypad(stdscr, FALSE); @@ -776,11 +835,12 @@ cl_suspend(sp, allowedp) return (0); } -#ifdef HAVE_BSD_CURSES /* Restore terminal settings. */ + wrefresh(win); /* Needed on SunOs/Solaris ? */ if (F_ISSET(clp, CL_STDIN_TTY)) (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t); +#ifdef HAVE_BSD_CURSES (void)cl_attr(sp, SA_ALTERNATE, 1); #endif @@ -791,7 +851,7 @@ cl_suspend(sp, allowedp) (void)keypad(stdscr, TRUE); /* Refresh and repaint the screen. */ - (void)move(y, x); + (void)wmove(win, y, x); (void)cl_refresh(sp, 1); /* If the screen changed size, set the SIGWINCH bit. */ diff --git a/cl/cl_screen.c b/cl/cl_screen.c index 082850c8..c43a75fd 100644 --- a/cl/cl_screen.c +++ b/cl/cl_screen.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: cl_screen.c,v 10.49 1996/09/24 20:48:04 bostic Exp $ (Berkeley) $Date: 1996/09/24 20:48:04 $"; +static const char sccsid[] = "$Id: cl_screen.c,v 10.50 2000/05/07 19:49:39 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:39 $"; #endif /* not lint */ #include @@ -48,10 +48,12 @@ cl_screen(sp, flags) u_int32_t flags; { CL_PRIVATE *clp; + WINDOW *win; GS *gp; gp = sp->gp; clp = CLP(sp); + win = CLSP(sp) ? CLSP(sp) : stdscr; /* See if the current information is incorrect. */ if (F_ISSET(gp, G_SRESTART)) { @@ -91,11 +93,11 @@ cl_screen(sp, flags) F_CLR(sp, SC_SCR_VI); if (sp->q.cqe_next != (void *)&gp->dq) { - (void)move(RLNO(sp, sp->rows), 0); - clrtobot(); + (void)wmove(win, RLNO(sp, sp->rows), 0); + wclrtobot(win); } - (void)move(RLNO(sp, sp->rows) - 1, 0); - refresh(); + (void)wmove(win, RLNO(sp, sp->rows) - 1, 0); + wrefresh(win); } /* Enter the requested mode. */ diff --git a/common/gs.h b/common/gs.h index 22072f9d..ec940177 100644 --- a/common/gs.h +++ b/common/gs.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: gs.h,v 10.40 2000/05/01 19:59:28 skimo Exp $ (Berkeley) $Date: 2000/05/01 19:59:28 $ + * $Id: gs.h,v 10.41 2000/05/07 19:49:40 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:40 $ */ #define TEMPORARY_FILE_STRING "/tmp" /* Default temporary file name. */ @@ -168,7 +168,7 @@ struct _gs { /* Delete a line. */ int (*scr_deleteln) __P((SCR *)); /* Discard a screen. */ - int (*scr_discard) __P((SCR *, SCR *)); + int (*scr_discard) __P((SCR *, SCR **)); /* Get a keyboard event. */ int (*scr_event) __P((SCR *, EVENT *, u_int32_t, int)); /* Ex: screen adjustment routine. */ diff --git a/common/screen.c b/common/screen.c index bf68ec16..19e0b059 100644 --- a/common/screen.c +++ b/common/screen.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: screen.c,v 10.15 1996/09/15 15:57:50 bostic Exp $ (Berkeley) $Date: 1996/09/15 15:57:50 $"; +static const char sccsid[] = "$Id: screen.c,v 10.16 2000/05/07 19:49:40 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:40 $"; #endif /* not lint */ #include @@ -113,6 +113,7 @@ mem: msgq(orig, M_SYSERR, NULL); goto err; if (v_screen_copy(orig, sp)) /* Vi. */ goto err; + sp->cl_private = 0; /* XXX */ *spp = sp; return (0); diff --git a/common/screen.h b/common/screen.h index 96663fcd..97d59385 100644 --- a/common/screen.h +++ b/common/screen.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: screen.h,v 10.29 2000/04/21 21:29:52 skimo Exp $ (Berkeley) $Date: 2000/04/21 21:29:52 $ + * $Id: screen.h,v 10.30 2000/05/07 19:49:40 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:40 $ */ /* @@ -91,6 +91,7 @@ struct _scr { void *ex_private; /* Ex private area. */ void *vi_private; /* Vi private area. */ void *perl_private; /* Perl private area. */ + void *cl_private; /* Curses private area. */ /* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */ char *alt_name; /* Ex/vi: alternate file name. */ diff --git a/dist/Makefile.in b/dist/Makefile.in index a4022682..0bf3f0c7 100644 --- a/dist/Makefile.in +++ b/dist/Makefile.in @@ -25,7 +25,7 @@ COBJS= addbytes.o addch.o box.o clear.o clrtobot.o clrtoeol.o \ erase.o fullname.o getch.o getstr.o id_subwins.o idlok.o initscr.o \ insch.o insertln.o longname.o move.o mvwin.o newwin.o overlay.o \ overwrite.o putchar.o refresh.o scroll.o setterm.o standout.o \ - toucholap.o touchwin.o tscroll.o tstp.o tty.o unctrl.o waddnstr.o + toucholap.o touchwin.o tscroll.o tstp.o tty.o unctrl.o wwaddnstr.o IPOBJS= ip_funcs.o ip_main.o ip_read.o ip_screen.o ip_send.o ip_term.o REOBJS= regcomp.o regerror.o regexec.o regfree.o VIOBJS= api.o cut.o db.o delete.o ex.o ex_abbrev.o ex_append.o ex_args.o \ @@ -605,7 +605,7 @@ tty.o: $(srcdir)/curses/tty.c $(CC) -D_CURSES_PRIVATE $(CFLAGS) $? unctrl.o: $(srcdir)/curses/unctrl.c $(CC) -D_CURSES_PRIVATE $(CFLAGS) $? -waddnstr.o: $(srcdir)/curses/waddnstr.c +wwaddnstr.o: $(srcdir)/curses/waddnstr.c $(CC) -D_CURSES_PRIVATE $(CFLAGS) $? # Regular Expressions sources. @@ -619,7 +619,7 @@ regfree.o: $(srcdir)/regex/regfree.c $(CC) -D__REGEX_PRIVATE $(CFLAGS) $? # Random C library replacement and workaround sources. -addnstr.o: $(srcdir)/clib/addnstr.c +waddnstr.o: $(srcdir)/clib/addnstr.c $(CC) $(CFLAGS) $? bsearch.o: $(srcdir)/clib/bsearch.c $(CC) $(CFLAGS) $? diff --git a/dist/acconfig.h b/dist/acconfig.h index 922099d5..017ed8a4 100644 --- a/dist/acconfig.h +++ b/dist/acconfig.h @@ -1,4 +1,4 @@ -/* $Id: acconfig.h,v 8.19 2000/04/21 21:26:20 skimo Exp $ (Berkeley) $Date: 2000/04/21 21:26:20 $ */ +/* $Id: acconfig.h,v 8.20 2000/05/07 19:49:41 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:41 $ */ /* Define to `int' if doesn't define. */ #undef ssize_t @@ -15,8 +15,8 @@ /* Define if you have a BSD version of curses. */ #undef HAVE_BSD_CURSES -/* Define if you have the curses(3) addnstr function. */ -#undef HAVE_CURSES_ADDNSTR +/* Define if you have the curses(3) waddnstr function. */ +#undef HAVE_CURSES_WADDNSTR /* Define if you have the curses(3) beep function. */ #undef HAVE_CURSES_BEEP diff --git a/dist/config.h.in b/dist/config.h.in index 99158334..d36e2a51 100644 --- a/dist/config.h.in +++ b/dist/config.h.in @@ -52,8 +52,8 @@ /* Define if you have a BSD version of curses. */ #undef HAVE_BSD_CURSES -/* Define if you have the curses(3) addnstr function. */ -#undef HAVE_CURSES_ADDNSTR +/* Define if you have the curses(3) waddnstr function. */ +#undef HAVE_CURSES_WADDNSTR /* Define if you have the curses(3) beep function. */ #undef HAVE_CURSES_BEEP diff --git a/dist/configure.in b/dist/configure.in index e90c4a16..e6e7d8ca 100644 --- a/dist/configure.in +++ b/dist/configure.in @@ -452,19 +452,19 @@ dnl BSD or System V style curses. Use the newterm function, all System V dnl curses implementations have it, none, as far as I know, of the BSD ones do. if test "$vi_cv_curses" = "bundled curses"; then AC_DEFINE(HAVE_BSD_CURSES) - AC_DEFINE(HAVE_CURSES_ADDNSTR) + AC_DEFINE(HAVE_CURSES_WADDNSTR) AC_DEFINE(HAVE_CURSES_IDLOK) else - dnl Check for the addnstr function. - AC_MSG_CHECKING(for addnstr) - AC_CACHE_VAL(vi_cv_have_curses_addnstr, [dnl - AC_TRY_LINK([#include ], [addnstr(0, 0);], - [vi_cv_have_curses_addnstr=yes], - [vi_cv_have_curses_addnstr=no])]) - if test "$vi_cv_have_curses_addnstr" = yes; then - AC_DEFINE(HAVE_CURSES_ADDNSTR) + dnl Check for the waddnstr function. + AC_MSG_CHECKING(for waddnstr) + AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl + AC_TRY_LINK([#include ], [waddnstr(0, 0);], + [vi_cv_have_curses_waddnstr=yes], + [vi_cv_have_curses_waddnstr=no])]) + if test "$vi_cv_have_curses_waddnstr" = yes; then + AC_DEFINE(HAVE_CURSES_WADDNSTR) fi - AC_MSG_RESULT($vi_cv_have_curses_addnstr) + AC_MSG_RESULT($vi_cv_have_curses_waddnstr) dnl Check for the beep function. AC_MSG_CHECKING(for beep) diff --git a/ip/ip_funcs.c b/ip/ip_funcs.c index 99f6a55c..3b691cc5 100644 --- a/ip/ip_funcs.c +++ b/ip/ip_funcs.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ip_funcs.c,v 8.14 2000/04/21 19:00:38 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:38 $"; +static const char sccsid[] = "$Id: ip_funcs.c,v 8.15 2000/05/07 19:49:42 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:42 $"; #endif /* not lint */ #include @@ -57,6 +57,8 @@ ip_addstr(sp, str, len) ipb.len1 = len; ipb.str1 = str; rval = vi_send("a", &ipb); + /* XXXX */ + ipp->col += len; if (iv) ip_attr(sp, SA_INVERSE, 0); @@ -158,6 +160,28 @@ ip_clrtoeol(sp) SCR *sp; { IP_BUF ipb; + IP_PRIVATE *ipp = IPP(sp); + + /* Temporary hack until we can pass screen pointers + * or name screens + */ + if (IS_VSPLIT(sp)) { + size_t x, y, spcnt; + IP_PRIVATE *ipp; + int error; + + ipp = IPP(sp); + y = ipp->row; + x = ipp->col; + error = 0; + for (spcnt = sp->cols - x; + spcnt > 0 && ! error; --spcnt) + error = ip_addstr(sp, " ", 1); + if (sp->coff == 0) + error |= ip_addstr(sp, "|", 1); + error |= ip_move(sp, y, x); + return error; + } ipb.code = SI_CLRTOEOL; @@ -222,11 +246,11 @@ ip_deleteln(sp) * ip_discard -- * Discard a screen. * - * PUBLIC: int ip_discard __P((SCR *, SCR *)); + * PUBLIC: int ip_discard __P((SCR *, SCR **)); */ int ip_discard(discardp, acquirep) - SCR *discardp, *acquirep; + SCR *discardp, **acquirep; { return (0); } @@ -322,7 +346,7 @@ ip_move(sp, lno, cno) ipb.code = SI_MOVE; ipb.val1 = RLNO(sp, lno); - ipb.val2 = cno; + ipb.val2 = RCNO(sp, cno); return (vi_send("12", &ipb)); } diff --git a/ipc/ip.h b/ipc/ip.h index 69fb176d..da6e6a4a 100644 --- a/ipc/ip.h +++ b/ipc/ip.h @@ -4,7 +4,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: ip.h,v 8.19 2000/04/21 19:00:39 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:39 $ + * $Id: ip.h,v 8.20 2000/05/07 19:49:42 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:42 $ */ extern int vi_ifd; /* Input file descriptor. */ @@ -33,6 +33,7 @@ typedef struct _ip_private { /* The screen line relative to a specific window. */ #define RLNO(sp, lno) (sp)->roff + (lno) +#define RCNO(sp, cno) (sp)->coff + (cno) #define IPO_CODE_LEN 1 /* Length of a code value. */ #define IPO_INT_LEN 4 /* Length of an integer. */ diff --git a/vi/vs_split.c b/vi/vs_split.c index b6e74b60..e1fce1fb 100644 --- a/vi/vs_split.c +++ b/vi/vs_split.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: vs_split.c,v 10.34 1996/12/18 10:24:31 bostic Exp $ (Berkeley) $Date: 1996/12/18 10:24:31 $"; +static const char sccsid[] = "$Id: vs_split.c,v 10.35 2000/05/07 19:49:43 skimo Exp $ (Berkeley) $Date: 2000/05/07 19:49:43 $"; #endif /* not lint */ #include @@ -247,7 +247,7 @@ vs_vsplit(sp, new) cols = sp->cols / 2; new->cols = sp->cols - cols - 1; sp->cols = cols; - new->coff = cols + 1; + new->coff = sp->coff + cols + 1; sp->cno = 0; /* Nothing else changes. */ @@ -445,7 +445,7 @@ vs_discard(sp, spp) *spp = tsp; /* Tell the display that we're discarding a screen. */ - (void)gp->scr_discard(sp, tsp); + (void)gp->scr_discard(sp, list); return (0); } @@ -711,7 +711,7 @@ vs_swap(sp, nspp, name) char *name; { GS *gp; - SCR *nsp; + SCR *nsp, *list[2]; gp = sp->gp; @@ -788,6 +788,10 @@ vs_swap(sp, nspp, name) /* Draw the new screen from scratch, and add a status line. */ F_SET(nsp, SC_SCR_REDRAW | SC_STATUS); + + list[0] = nsp; list[1] = NULL; + (void)gp->scr_discard(sp, list); + return (0); } @@ -804,7 +808,7 @@ vs_resize(sp, count, adj) adj_t adj; { GS *gp; - SCR *g, *s; + SCR *g, *s, *prev, *next, *list[3] = {NULL, NULL, NULL}; size_t g_off, s_off; gp = sp->gp; @@ -827,6 +831,25 @@ vs_resize(sp, count, adj) } } + /* Find first overlapping screen */ + for (next = sp->q.cqe_next; + next != (void *)&gp->dq && + (next->coff >= sp->coff + sp->cols || + next->coff + next->cols <= sp->coff); + next = next->q.cqe_next); + /* See if we can use it */ + if (next != (void *)&gp->dq && + (sp->coff != next->coff || sp->cols != next->cols)) + next = (void *)&gp->dq; + for (prev = sp->q.cqe_prev; + prev != (void *)&gp->dq && + (prev->coff >= sp->coff + sp->cols || + prev->coff + prev->cols <= sp->coff); + prev = prev->q.cqe_prev); + if (prev != (void *)&gp->dq && + (sp->coff != prev->coff || sp->cols != prev->cols)) + prev = (void *)&gp->dq; + g_off = s_off = 0; if (adj == A_DECREASE) { if (count < 0) @@ -834,23 +857,21 @@ vs_resize(sp, count, adj) s = sp; if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count) goto toosmall; - if ((g = sp->q.cqe_prev) == (void *)&gp->dq) { - if ((g = sp->q.cqe_next) == (void *)&gp->dq) + if ((g = prev) == (void *)&gp->dq) { + if ((g = next) == (void *)&gp->dq) goto toobig; g_off = -count; } else s_off = count; } else { g = sp; - if ((s = sp->q.cqe_next) != (void *)&gp->dq) - if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count) - s = NULL; - else + if ((s = next) != (void *)&gp->dq && + s->t_maxrows >= MINIMUM_SCREEN_ROWS + count) s_off = count; else s = NULL; if (s == NULL) { - if ((s = sp->q.cqe_prev) == (void *)&gp->dq) { + if ((s = prev) == (void *)&gp->dq) { toobig: msgq(sp, M_BERR, adj == A_DECREASE ? "227|The screen cannot shrink" : "228|The screen cannot grow"); @@ -890,6 +911,10 @@ toosmall: msgq(sp, M_BERR, _TMAP(s) -= count; F_SET(s, SC_SCR_REFORMAT | SC_STATUS); + /* XXXX */ + list[0] = g; list[1] = s; + gp->scr_discard(0, list); + return (0); } -- 2.11.4.GIT