From 6faf36bf9ce85a8b7ea12f288056dd5305dcefe7 Mon Sep 17 00:00:00 2001 From: bostic Date: Thu, 18 Nov 1993 13:50:21 +0000 Subject: [PATCH] convert screen queue and parent/child queue to queues --- common/db.c | 12 ++++++--- common/gs.h | 5 ++-- common/main.c | 6 +++-- common/recover.c | 81 ++++++++++++++++++++++++++++++++++---------------------- common/screen.c | 25 +++++------------ common/screen.h | 53 +++++++++++++++++------------------- common/search.c | 6 ++--- ex/ex_global.c | 5 ++-- ex/ex_screen.c | 16 ++++------- vi/v_screen.c | 14 +++++----- vi/vs_line.c | 4 +-- vi/vs_refresh.c | 21 ++++++++++----- vi/vs_split.c | 78 +++++++++++++++++++++-------------------------------- 13 files changed, 159 insertions(+), 167 deletions(-) diff --git a/common/db.c b/common/db.c index 1d5f209b..dc352a91 100644 --- a/common/db.c +++ b/common/db.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: db.c,v 8.15 1993/11/18 10:08:34 bostic Exp $ (Berkeley) $Date: 1993/11/18 10:08:34 $"; +static char sccsid[] = "$Id: db.c,v 8.16 1993/11/18 13:50:22 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:22 $"; #endif /* not lint */ #include @@ -402,12 +402,18 @@ scr_update(sp, ep, lno, op, current) SCR *tsp; if (ep->refcnt != 1) { - for (tsp = sp->parent; tsp != NULL; tsp = tsp->parent) + for (tsp = sp;;) { + if ((tsp = tsp->q.cqe_prev) == (void *)&sp->gp->dq) + break; if (tsp->ep == ep) (void)sp->s_change(tsp, ep, lno, op); - for (tsp = sp->child; tsp != NULL; tsp = tsp->child) + } + for (tsp = sp;;) { + if ((tsp = tsp->q.cqe_next) == (void *)&sp->gp->dq) + break; if (tsp->ep == ep) (void)sp->s_change(tsp, ep, lno, op); + } } return (current && sp->s_change(sp, ep, lno, op)); } diff --git a/common/gs.h b/common/gs.h index 65f7bf1b..c18ac155 100644 --- a/common/gs.h +++ b/common/gs.h @@ -4,11 +4,12 @@ * * %sccs.include.redist.c% * - * $Id: gs.h,v 8.19 1993/11/18 10:55:00 bostic Exp $ (Berkeley) $Date: 1993/11/18 10:55:00 $ + * $Id: gs.h,v 8.20 1993/11/18 13:50:21 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:21 $ */ struct _gs { - LIST_HEAD(_scrh, _scr) scrq; /* Linked list of SCR structures. */ + CIRCLEQ_HEAD(_dqh, _scr) dq; /* Displayed screens. */ + CIRCLEQ_HEAD(_hqh, _scr) hq; /* Hidden screens. */ mode_t origmode; /* Original terminal mode. */ struct termios diff --git a/common/main.c b/common/main.c index 19d62ba8..030861d6 100644 --- a/common/main.c +++ b/common/main.c @@ -12,7 +12,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "$Id: main.c,v 8.44 1993/11/18 10:55:01 bostic Exp $ (Berkeley) $Date: 1993/11/18 10:55:01 $"; +static char sccsid[] = "$Id: main.c,v 8.45 1993/11/18 13:50:23 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:23 $"; #endif /* not lint */ #include @@ -170,6 +170,7 @@ main(argc, argv) /* Build and initialize the first/current screen. */ if (screen_init(NULL, &sp, flags)) goto err1; + CIRCLEQ_INSERT_HEAD(&__global_list->dq, sp, q); if (trace_f != NULL) { #ifdef DEBUG @@ -400,7 +401,8 @@ gs_init() err(1, NULL); memset(gp, 0, sizeof(GS)); - LIST_INIT(&gp->scrq); + CIRCLEQ_INIT(&gp->dq); + CIRCLEQ_INIT(&gp->hq); LIST_INIT(&gp->msgq); /* Structures shared by screens so stored in the GS structure. */ diff --git a/common/recover.c b/common/recover.c index 91bfa7fe..85066b43 100644 --- a/common/recover.c +++ b/common/recover.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: recover.c,v 8.37 1993/11/18 09:20:29 bostic Exp $ (Berkeley) $Date: 1993/11/18 09:20:29 $"; +static char sccsid[] = "$Id: recover.c,v 8.38 1993/11/18 13:50:25 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:25 $"; #endif /* not lint */ #include @@ -68,6 +68,7 @@ static char sccsid[] = "$Id: recover.c,v 8.37 1993/11/18 09:20:29 bostic Exp $ ( static void rcv_alrm __P((int)); static int rcv_mailfile __P((SCR *, EXF *)); +static void rcv_syncit __P((SCR *, int)); /* * rcv_tmp -- @@ -314,31 +315,17 @@ void rcv_hup() { SCR *sp; - char comm[4096]; /* - * Walk the list of screens, sync'ing the files; only sync + * Walk the lists of screens, sync'ing the files; only sync * each file once. Send email to the user for each file saved. - * - * !!! - * If you need to port this to a system that doesn't have sendmail, - * the -t flag being used causes sendmail to read the message for - * the recipients instead of us specifying them some other way. */ - for (sp = __global_list->scrq.lh_first; sp != NULL; sp = sp->q.le_next) - if (sp->ep != NULL) { - if (F_ISSET(sp->ep, F_MODIFIED) && - F_ISSET(sp->ep, F_RCV_ON)) { - (void)sp->ep->db->sync(sp->ep->db, R_RECNOSYNC); - F_SET(sp->ep, F_RCV_NORM); - - (void)snprintf(comm, sizeof(comm), - "%s -t < %s", _PATH_SENDMAIL, - sp->ep->rcv_mpath); - (void)system(comm); - } - (void)file_end(sp, sp->ep, 1); - } + for (sp = __global_list->dq.cqh_first; + sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) + rcv_syncit(sp, 1); + for (sp = __global_list->hq.cqh_first; + sp != (void *)&__global_list->hq; sp = sp->q.cqe_next) + rcv_syncit(sp, 1); /* * Die with the proper exit status. Don't bother using @@ -361,18 +348,15 @@ rcv_term() SCR *sp; /* - * Walk the list of screens, sync'ing the files; only sync + * Walk the lists of screens, sync'ing the files; only sync * each file once. */ - for (sp = __global_list->scrq.lh_first; sp != NULL; sp = sp->q.le_next) - if (sp->ep != NULL) { - if (F_ISSET(sp->ep, F_MODIFIED) && - F_ISSET(sp->ep, F_RCV_ON)) { - (void)sp->ep->db->sync(sp->ep->db, R_RECNOSYNC); - F_SET(sp->ep, F_RCV_NORM); - } - (void)file_end(sp, sp->ep, 1); - } + for (sp = __global_list->dq.cqh_first; + sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) + rcv_syncit(sp, 0); + for (sp = __global_list->hq.cqh_first; + sp != (void *)&__global_list->hq; sp = sp->q.cqe_next) + rcv_syncit(sp, 0); /* * Die with the proper exit status. Don't bother using @@ -386,6 +370,39 @@ rcv_term() } /* + * rcv_syncit -- + * Sync the file, optionally send mail. + */ +static void +rcv_syncit(sp, email) + SCR *sp; + int email; +{ + EXF *ep; + char comm[1024]; + + if ((ep = sp->ep) == NULL || + !F_ISSET(ep, F_MODIFIED) || !F_ISSET(ep, F_RCV_ON)) + return; + + (void)ep->db->sync(ep->db, R_RECNOSYNC); + F_SET(ep, F_RCV_NORM); + + /* + * !!! + * If you need to port this to a system that doesn't have sendmail, + * the -t flag being used causes sendmail to read the message for + * the recipients instead of us specifying them some other way. + */ + if (email) { + (void)snprintf(comm, sizeof(comm), + "%s -t < %s", _PATH_SENDMAIL, ep->rcv_mpath); + (void)system(comm); + } + (void)file_end(sp, ep, 1); +} + +/* * people making love * never exactly the same * just like a snowflake diff --git a/common/screen.c b/common/screen.c index 38089f50..5d4a1723 100644 --- a/common/screen.c +++ b/common/screen.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: screen.c,v 8.37 1993/11/18 10:55:04 bostic Exp $ (Berkeley) $Date: 1993/11/18 10:55:04 $"; +static char sccsid[] = "$Id: screen.c,v 8.38 1993/11/18 13:50:27 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:27 $"; #endif /* not lint */ #include @@ -35,7 +35,7 @@ screen_init(orig, spp, flags) size_t len; if ((sp = malloc(sizeof(SCR))) == NULL) { - msgq(NULL, M_SYSERR, NULL); + msgq(orig, M_SYSERR, NULL); return (1); } memset(sp, 0, sizeof(SCR)); @@ -79,7 +79,6 @@ screen_init(orig, spp, flags) } sp->flags = flags; - LIST_INSERT_HEAD(&__global_list->scrq, sp, q); } else { if (orig->alt_fname != NULL && (sp->alt_fname = strdup(orig->alt_fname)) == NULL) @@ -157,7 +156,6 @@ mem: msgq(orig, M_SYSERR, "new screen attributes"); sp->s_up = orig->s_up; F_SET(sp, F_ISSET(orig, S_SCREENS)); - LIST_INSERT_AFTER(orig, sp, q); } /* Copy screen private information. */ @@ -216,16 +214,13 @@ screen_end(sp) * any screen, the global area. */ { SCR *c_sp; MSG *mp, *next; - if (sp->parent != NULL) { - c_sp = sp->parent; + if ((c_sp = sp->q.cqe_prev) != (void *)&sp->gp->dq) { if (F_ISSET(sp, S_BELLSCHED)) F_SET(c_sp, S_BELLSCHED); - } else if (sp->child != NULL) { - c_sp = sp->child; + } else if ((c_sp = sp->q.cqe_next) != (void *)&sp->gp->dq) { if (F_ISSET(sp, S_BELLSCHED)) F_SET(c_sp, S_BELLSCHED); - } else if (sp->q.le_next != NULL) { - c_sp = sp->q.le_next; + } else if ((c_sp = sp->q.cqe_next) != NULL) { if (F_ISSET(sp, S_BELLSCHED)) F_SET(c_sp, S_BELLSCHED); } else { @@ -246,15 +241,7 @@ screen_end(sp) } /* Remove the screen from the global screen chain. */ - LIST_REMOVE(sp, q); - - /* Remove the screen from the chain of related screens. */ - if (sp->parent != NULL) { - sp->parent->child = sp->child; - if (sp->child != NULL) - sp->child->parent = sp->parent; - } else if (sp->child != NULL) - sp->child->parent = NULL; + CIRCLEQ_REMOVE(&sp->gp->dq, sp, q); /* Free the screen itself. */ FREE(sp, sizeof(SCR)); diff --git a/common/screen.h b/common/screen.h index 39358198..087f32ea 100644 --- a/common/screen.h +++ b/common/screen.h @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * $Id: screen.h,v 8.61 1993/11/18 10:55:06 bostic Exp $ (Berkeley) $Date: 1993/11/18 10:55:06 $ + * $Id: screen.h,v 8.62 1993/11/18 13:50:29 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:29 $ */ /* @@ -23,7 +23,7 @@ #define MINIMUM_SCREEN_COLS 20 /* Line operations. */ enum operation { LINE_APPEND, LINE_DELETE, LINE_INSERT, LINE_RESET }; - /* Standard continue message. */ + /* Position values. */ enum position { P_BOTTOM, P_FILL, P_MIDDLE, P_TOP }; /* @@ -67,13 +67,11 @@ struct _fref { */ struct _scr { /* INITIALIZED AT SCREEN CREATE. */ - LIST_ENTRY(_scr) q; /* Linked list of screens. */ + CIRCLEQ_ENTRY(_scr) q; /* Screens. */ GS *gp; /* Pointer to global area. */ - SCR *child; /* split screen: child screen. */ - SCR *parent; /* split screen: parent screen. */ - SCR *snext; /* split screen: next display screen. */ + SCR *nextdisp; /* Next display screen. */ EXF *ep; /* Screen's current EXF structure. */ @@ -133,10 +131,10 @@ struct _scr { struct itimerval time_value; /* ITIMER_REAL saved value. */ struct sigaction time_handler; /* ITIMER_REAL saved handler. */ - void *vi_private; /* Vi information. */ - void *ex_private; /* Ex information. */ - void *svi_private; /* Vi curses screen information. */ - void *xaw_private; /* Vi XAW screen information. */ + void *vi_private; /* Vi private area. */ + void *ex_private; /* Ex private area. */ + void *svi_private; /* Vi curses screen private area. */ + void *xaw_private; /* Vi XAW screen private area. */ /* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */ char *alt_fname; /* Ex/vi: alternate file name. */ @@ -158,7 +156,7 @@ struct _scr { CHNAME const *cname; /* Display names of characters. */ u_char special[UCHAR_MAX]; /* Special character array. */ - u_int saved_vi_mode; /* Saved vi display. */ + u_int saved_vi_mode; /* Saved vi display type. */ OPTION opts[O_OPTIONCOUNT]; /* Options. */ @@ -174,11 +172,9 @@ struct _scr { /* Put up a busy message. */ int (*s_busy) __P((SCR *, char const *)); /* Change a screen line. */ - int (*s_change) __P((SCR *, - EXF *, recno_t, enum operation)); + int (*s_change) __P((SCR *, EXF *, recno_t, enum operation)); /* Return column close to specified. */ - size_t (*s_chposition) __P((SCR *, - EXF *, recno_t, size_t)); + size_t (*s_chposition) __P((SCR *, EXF *, recno_t, size_t)); /* Clear the screen. */ int (*s_clear) __P((SCR *)); enum confirm /* Confirm an action with the user. */ @@ -247,20 +243,19 @@ struct _scr { #define S_AUTOPRINT 0x0000100 /* Autoprint flag. */ #define S_BELLSCHED 0x0000200 /* Bell scheduled. */ #define S_CONTINUE 0x0000400 /* Need to ask the user to continue. */ -#define S_DISPLAYED 0x0000800 /* If screen is currently displayed. */ -#define S_GLOBAL 0x0001000 /* Doing a global command. */ -#define S_INPUT 0x0002000 /* Doing text input. */ -#define S_INTERRUPTED 0x0004000 /* If have been interrupted. */ -#define S_INTERRUPTIBLE 0x0008000 /* If can be interrupted. */ -#define S_REDRAW 0x0010000 /* Redraw the screen. */ -#define S_REFORMAT 0x0020000 /* Reformat the screen. */ -#define S_REFRESH 0x0040000 /* Refresh the screen. */ -#define S_RESIZE 0x0080000 /* Resize the screen. */ -#define S_SCRIPT 0x0100000 /* Window is a shell script. */ -#define S_SRE_SET 0x0200000 /* The search RE has been set. */ -#define S_SUBRE_SET 0x0400000 /* The substitute RE has been set. */ -#define S_TIMER_SET 0x0800000 /* If a busy timer is running. */ -#define S_UPDATE_MODE 0x1000000 /* Don't repaint modeline. */ +#define S_GLOBAL 0x0000800 /* Doing a global command. */ +#define S_INPUT 0x0001000 /* Doing text input. */ +#define S_INTERRUPTED 0x0002000 /* If have been interrupted. */ +#define S_INTERRUPTIBLE 0x0004000 /* If can be interrupted. */ +#define S_REDRAW 0x0008000 /* Redraw the screen. */ +#define S_REFORMAT 0x0010000 /* Reformat the screen. */ +#define S_REFRESH 0x0020000 /* Refresh the screen. */ +#define S_RESIZE 0x0040000 /* Resize the screen. */ +#define S_SCRIPT 0x0080000 /* Window is a shell script. */ +#define S_SRE_SET 0x0100000 /* The search RE has been set. */ +#define S_SUBRE_SET 0x0200000 /* The substitute RE has been set. */ +#define S_TIMER_SET 0x0400000 /* If a busy timer is running. */ +#define S_UPDATE_MODE 0x0800000 /* Don't repaint modeline. */ u_int flags; }; diff --git a/common/search.c b/common/search.c index b10fbe69..ab4558fa 100644 --- a/common/search.c +++ b/common/search.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: search.c,v 8.26 1993/11/18 08:17:17 bostic Exp $ (Berkeley) $Date: 1993/11/18 08:17:17 $"; +static char sccsid[] = "$Id: search.c,v 8.27 1993/11/18 13:50:31 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:31 $"; #endif /* not lint */ #include @@ -265,8 +265,8 @@ search_intr(signo) { SCR *sp; - for (sp = __global_list->scrq.lh_first; - sp != NULL; sp = sp->q.le_next) + for (sp = __global_list->dq.cqh_first; + sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) if (F_ISSET(sp, S_INTERRUPTIBLE)) F_SET(sp, S_INTERRUPTED); } diff --git a/ex/ex_global.c b/ex/ex_global.c index 91dd8a26..c64773fe 100644 --- a/ex/ex_global.c +++ b/ex/ex_global.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: ex_global.c,v 8.21 1993/11/18 08:17:42 bostic Exp $ (Berkeley) $Date: 1993/11/18 08:17:42 $"; +static char sccsid[] = "$Id: ex_global.c,v 8.22 1993/11/18 13:50:42 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:42 $"; #endif /* not lint */ #include @@ -281,7 +281,8 @@ global_intr(signo) { SCR *sp; - for (sp = __global_list->scrq.lh_first; sp != NULL; sp = sp->q.le_next) + for (sp = __global_list->dq.cqh_first; + sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) if (F_ISSET(sp, S_GLOBAL) && F_ISSET(sp, S_INTERRUPTIBLE)) F_SET(sp, S_INTERRUPTED); } diff --git a/ex/ex_screen.c b/ex/ex_screen.c index d2df0c89..f819aa30 100644 --- a/ex/ex_screen.c +++ b/ex/ex_screen.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: ex_screen.c,v 8.4 1993/11/18 08:17:44 bostic Exp $ (Berkeley) $Date: 1993/11/18 08:17:44 $"; +static char sccsid[] = "$Id: ex_screen.c,v 8.5 1993/11/18 13:50:43 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:43 $"; #endif /* not lint */ #include @@ -82,15 +82,12 @@ ex_sargs(sp, ep, cmdp) EXCMDARG *cmdp; { SCR *tsp; - FREF *frp; int cnt, col, len, sep; col = len = sep = 0; - for (cnt = 1, tsp = __global_list->scrq.lh_first; - tsp != NULL; tsp = tsp->q.le_next) { - frp = tsp->frp; - col += len = - frp->nlen + sep + (F_ISSET(tsp, S_DISPLAYED) ? 2 : 0); + for (cnt = 1, tsp = sp->gp->hq.cqh_first; + tsp != (void *)&sp->gp->hq; tsp = tsp->q.cqe_next) { + col += len = tsp->frp->nlen + sep; if (col >= sp->cols - 1) { col = len; sep = 0; @@ -99,10 +96,7 @@ ex_sargs(sp, ep, cmdp) sep = 1; (void)ex_printf(EXCOOKIE, " "); } - if (F_ISSET(tsp, S_DISPLAYED)) - (void)ex_printf(EXCOOKIE, "[%s]", frp->fname); - else - (void)ex_printf(EXCOOKIE, "%s", frp->fname); + (void)ex_printf(EXCOOKIE, "%s", tsp->frp->fname); ++cnt; } (void)ex_printf(EXCOOKIE, "\n"); diff --git a/vi/v_screen.c b/vi/v_screen.c index 333ab8bf..ed502ac5 100644 --- a/vi/v_screen.c +++ b/vi/v_screen.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: v_screen.c,v 8.5 1993/11/16 21:43:49 bostic Exp $ (Berkeley) $Date: 1993/11/16 21:43:49 $"; +static char sccsid[] = "$Id: v_screen.c,v 8.6 1993/11/18 13:50:56 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:50:56 $"; #endif /* not lint */ #include @@ -31,15 +31,13 @@ v_screen(sp, ep, vp, fm, tm, rp) * Try for the next lower screen, or, go back to the first * screen on the stack. */ - if (sp->child != NULL) - sp->snext = sp->child; - else if (sp->parent == NULL) { + if (sp->q.cqe_next != (void *)&sp->gp->dq) + sp->nextdisp = sp->q.cqe_next; + else if (sp->gp->dq.cqh_first == sp) { msgq(sp, M_ERR, "No other screen to switch to."); return (1); - } else { - for (p = sp; p->parent != NULL; p = p->parent); - sp->snext = p; - } + } else + sp->nextdisp = sp->gp->dq.cqh_first; /* * Display the old screen's status line so the user can diff --git a/vi/vs_line.c b/vi/vs_line.c index dcf561dc..5b4fbb57 100644 --- a/vi/vs_line.c +++ b/vi/vs_line.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: vs_line.c,v 8.10 1993/11/07 17:02:59 bostic Exp $ (Berkeley) $Date: 1993/11/07 17:02:59 $"; +static char sccsid[] = "$Id: vs_line.c,v 8.11 1993/11/18 13:51:07 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:51:07 $"; #endif /* not lint */ #include @@ -97,7 +97,7 @@ svi_line(sp, ep, smp, yp, xp) reverse_video = 0; cols_per_screen = sp->cols; if (is_infoline = ISINFOLINE(sp, smp)) { - if (sp->child != NULL) { + if (sp->q.cqe_next != (void *)&sp->gp->dq) { reverse_video = 1; standout(); } diff --git a/vi/vs_refresh.c b/vi/vs_refresh.c index d4aaba06..d994b13d 100644 --- a/vi/vs_refresh.c +++ b/vi/vs_refresh.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: vs_refresh.c,v 8.31 1993/11/18 10:55:17 bostic Exp $ (Berkeley) $Date: 1993/11/18 10:55:17 $"; +static char sccsid[] = "$Id: vs_refresh.c,v 8.32 1993/11/18 13:51:10 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:51:10 $"; #endif /* not lint */ #include @@ -65,18 +65,25 @@ svi_refresh(sp, ep) * modified as well. Refresh them if the dirty bit is set. */ #define PAINTBITS S_REDRAW | S_REFORMAT | S_REFRESH - for (tsp = sp->child; tsp != NULL; tsp = tsp->child) + for (tsp = sp;;) { + if ((tsp = tsp->q.cqe_prev) == (void *)&sp->gp->dq) + break; if (F_ISSET(tsp, PAINTBITS) || tsp->ep == ep && F_ISSET(SVP(tsp), SVI_SCREENDIRTY)) { (void)svi_paint(tsp, tsp->ep); F_CLR(SVP(tsp), SVI_SCREENDIRTY); } - for (tsp = sp->parent; tsp != NULL; tsp = tsp->parent) + } + for (tsp = sp;;) { + if ((tsp = tsp->q.cqe_next) == (void *)&sp->gp->dq) + break; if (F_ISSET(tsp, PAINTBITS) || tsp->ep == ep && F_ISSET(SVP(tsp), SVI_SCREENDIRTY)) { (void)svi_paint(tsp, tsp->ep); F_CLR(SVP(tsp), SVI_SCREENDIRTY); } + } + /* * 3: Refresh the current screen. * @@ -660,7 +667,8 @@ lcont: /* Move to the message line and clear it. */ * Turn on standout mode if requested, or, if we've split * the screen and need a divider. */ - if (F_ISSET(mp, M_INV_VIDEO) || sp->child != NULL) + if (F_ISSET(mp, M_INV_VIDEO) || + sp->q.cqe_next != (void *)&sp->gp->dq) standout(); /* @@ -702,7 +710,8 @@ lcont: /* Move to the message line and clear it. */ } /* Turn off standout mode. */ - if (F_ISSET(mp, M_INV_VIDEO) || sp->child != NULL) + if (F_ISSET(mp, M_INV_VIDEO) || + sp->q.cqe_next != (void *)&sp->gp->dq) standend(); if (mp->len) @@ -732,7 +741,7 @@ svi_modeline(sp, ep) clrtoeol(); /* Display the dividing line. */ - if (sp->child != NULL) + if (sp->q.cqe_next != (void *)&sp->gp->dq) svi_divider(sp); /* Display the ruler. */ diff --git a/vi/vs_split.c b/vi/vs_split.c index 848f5fd7..56a046c0 100644 --- a/vi/vs_split.c +++ b/vi/vs_split.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "$Id: vs_split.c,v 8.16 1993/11/18 08:18:09 bostic Exp $ (Berkeley) $Date: 1993/11/18 08:18:09 $"; +static char sccsid[] = "$Id: vs_split.c,v 8.17 1993/11/18 13:51:14 bostic Exp $ (Berkeley) $Date: 1993/11/18 13:51:14 $"; #endif /* not lint */ #include @@ -81,12 +81,8 @@ svi_split(sp, argv) sp->rows = half; sp->t_maxrows = sp->rows - 1; - /* Link into place. */ - if ((tsp->child = sp->child) != NULL) - sp->child->parent = tsp; - sp->child = tsp; - tsp->parent = sp; - + /* Link in after the parent. */ + CIRCLEQ_INSERT_AFTER(&sp->gp->dq, sp, tsp, q); splitup = 0; } else { /* Parent is bottom half. */ /* Child. */ @@ -103,12 +99,8 @@ svi_split(sp, argv) memmove(_HMAP(sp), _HMAP(sp) + tsp->rows, sp->t_maxrows * sizeof(SMAP)); - /* Link into place. */ - if ((tsp->parent = sp->parent) != NULL) - sp->parent->child = tsp; - sp->parent = tsp; - tsp->child = sp; - + /* Link in before the parent. */ + CIRCLEQ_INSERT_BEFORE(&sp->gp->dq, sp, tsp, q); splitup = 1; } @@ -229,11 +221,9 @@ svi_split(sp, argv) MOVE(tsp, INFOLINE(tsp), 0); clrtoeol(); - /* Redraw the status line for the parent screen, if it's on top. */ - if (splitup == 0) { - (void)status(sp, sp->ep, sp->lno, 0); - (void)svi_paint(sp, sp->ep); - } + /* Redraw the status line for the parent screen. */ + (void)status(sp, sp->ep, sp->lno, 0); + (void)svi_paint(sp, sp->ep); /* Save the parent screen's cursor information. */ sp->frp->lno = sp->lno; @@ -241,10 +231,10 @@ svi_split(sp, argv) F_SET(sp->frp, FR_CURSORSET); /* Completely redraw the child screen. */ - F_SET(tsp, S_DISPLAYED | S_REDRAW); + F_SET(tsp, S_REDRAW); /* Switch screens. */ - sp->snext = tsp; + sp->nextdisp = tsp; F_SET(sp, S_SSWITCH); return (0); @@ -275,7 +265,7 @@ svi_bg(csp) } /* Switch screens. */ - csp->snext = sp; + csp->nextdisp = sp; F_SET(csp, S_SSWITCH); return (0); @@ -298,8 +288,8 @@ svi_join(csp, nsp) * to clean up the screen's values. If it's not exiting, we'll * get it when the user asks to show it again. */ - if ((sp = csp->parent) == NULL) { - if ((sp = csp->child) == NULL) { + if ((sp = csp->q.cqe_prev) == (void *)&csp->gp->dq) { + if ((sp = csp->q.cqe_next) == (void *)&csp->gp->dq) { *nsp = NULL; return (0); } @@ -329,14 +319,9 @@ svi_join(csp, nsp) if (!F_ISSET(&sp->opts[O_SCROLL], OPT_SET)) O_VAL(sp, O_SCROLL) = sp->t_maxrows / 2; - /* Delete the screen from the parent/child list. */ - if (csp->parent != NULL) - csp->parent->child = csp->child; - if (csp->child != NULL) - csp->child->parent = csp->parent; - /* Screen is no longer displayed. */ - F_CLR(csp, S_DISPLAYED); + CIRCLEQ_REMOVE(&csp->gp->dq, csp, q); + CIRCLEQ_INSERT_TAIL(&csp->gp->hq, csp, q); *nsp = sp; return (0); @@ -369,7 +354,7 @@ svi_fg(csp, fname) /* * svi_swap -- - * Swap the two screens. + * Swap the current screen with a hidden one. */ int svi_swap(csp, nsp, fname) @@ -380,11 +365,11 @@ svi_swap(csp, nsp, fname) int issmallscreen; /* Find the screen, or, if fname is NULL, the first screen. */ - for (sp = __global_list->scrq.lh_first; sp != NULL; sp = sp->q.le_next) - if (!F_ISSET(sp, S_DISPLAYED) && - (fname == NULL || !strcmp(sp->frp->fname, fname))) + for (sp = csp->gp->hq.cqh_first; + sp != (void *)&csp->gp->hq; sp = sp->q.cqe_next) + if (fname == NULL || !strcmp(sp->frp->fname, fname)) break; - if (sp == NULL) { + if (sp == (void *)&csp->gp->hq) { *nsp = NULL; return (0); } @@ -396,9 +381,8 @@ svi_swap(csp, nsp, fname) F_SET(csp->frp, FR_CURSORSET); /* Switch screens. */ - csp->snext = sp; + csp->nextdisp = sp; F_SET(csp, S_SSWITCH); - F_CLR(csp, S_DISPLAYED); /* Initialize terminal information. */ SVP(sp)->srows = SVP(csp)->srows; @@ -454,14 +438,13 @@ svi_swap(csp, nsp, fname) if (svi_sm_fill(sp, sp->ep, sp->lno, P_FILL)) return (1); - F_SET(sp, S_DISPLAYED | S_REDRAW); - /* The new screen replaces the old screen in the parent/child list. */ - if ((sp->parent = csp->parent) != NULL) - csp->parent->child = sp; - if ((sp->child = csp->child) != NULL) - csp->child->parent = sp; + CIRCLEQ_REMOVE(&sp->gp->hq, sp, q); + CIRCLEQ_INSERT_AFTER(&csp->gp->dq, csp, sp, q); + CIRCLEQ_REMOVE(&csp->gp->dq, csp, q); + CIRCLEQ_INSERT_TAIL(&csp->gp->hq, csp, q); + F_SET(sp, S_REDRAW); return (0); } @@ -487,22 +470,21 @@ svi_resize(sp, count) s = sp; if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count) goto toosmall; - if ((g = sp->parent) == NULL) { - if ((g = sp->child) == NULL) + if ((g = sp->q.cqe_prev) == (void *)&sp->gp->dq) { + if ((g = sp->q.cqe_next) == (void *)&sp->gp->dq) goto toobig; g->woff -= count; } else s->woff += count; } else { g = sp; - if ((s = sp->child) != NULL) + if ((s = sp->q.cqe_next) != (void *)&sp->gp->dq) if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count) s = NULL; else s->woff += count; if (s == NULL) { - s = sp->parent; - if (s == NULL) { + if ((s = sp->q.cqe_prev) == (void *)&sp->gp->dq) { toobig: msgq(sp, M_BERR, "The screen cannot %s.", count < 0 ? "shrink" : "grow"); return (1); -- 2.11.4.GIT