From e2f0a0f35c8c3ecbae359c67f0d5b3aac5ce43dc Mon Sep 17 00:00:00 2001 From: bde Date: Thu, 3 Jul 1997 03:28:27 +0000 Subject: Import Lite2's src/lib, except for non-i386 machine-dependent directories, libc/db, libc/gen/crypt.* and libtelnet. All affected files except 3 unimportant ones have already left the vendor branch. --- lib/libcurses/PSD.doc/Makefile | 4 +- lib/libcurses/PSD.doc/Master | 6 +- lib/libcurses/PSD.doc/fns.doc | 6 +- lib/libcurses/addbytes.c | 6 +- lib/libcurses/addch.c | 6 +- lib/libcurses/addnstr.c | 7 +- lib/libcurses/box.c | 6 +- lib/libcurses/clear.c | 6 +- lib/libcurses/clrtobot.c | 6 +- lib/libcurses/clrtoeol.c | 6 +- lib/libcurses/cr_put.c | 7 +- lib/libcurses/curses.c | 6 +- lib/libcurses/curses.h | 27 ++-- lib/libcurses/delch.c | 7 +- lib/libcurses/deleteln.c | 7 +- lib/libcurses/delwin.c | 7 +- lib/libcurses/erase.c | 6 +- lib/libcurses/getch.c | 6 +- lib/libcurses/getstr.c | 6 +- lib/libcurses/id_subwins.c | 6 +- lib/libcurses/idlok.c | 6 +- lib/libcurses/initscr.c | 7 +- lib/libcurses/insch.c | 7 +- lib/libcurses/insertln.c | 7 +- lib/libcurses/move.c | 6 +- lib/libcurses/mvwin.c | 6 +- lib/libcurses/newwin.c | 18 +-- lib/libcurses/overlay.c | 7 +- lib/libcurses/overwrite.c | 7 +- lib/libcurses/printw.c | 8 +- lib/libcurses/putchar.c | 6 +- lib/libcurses/refresh.c | 344 +++++++++++++++++++++++++++-------------- lib/libcurses/scanw.c | 8 +- lib/libcurses/scroll.c | 6 +- lib/libcurses/setterm.c | 24 +-- lib/libcurses/standout.c | 31 ++-- lib/libcurses/toucholap.c | 6 +- lib/libcurses/touchwin.c | 7 +- lib/libcurses/tscroll.c | 13 +- lib/libcurses/tstp.c | 6 +- lib/libcurses/tty.c | 53 ++++--- 41 files changed, 432 insertions(+), 295 deletions(-) (limited to 'lib/libcurses') diff --git a/lib/libcurses/PSD.doc/Makefile b/lib/libcurses/PSD.doc/Makefile index f93ee64..a09c460 100644 --- a/lib/libcurses/PSD.doc/Makefile +++ b/lib/libcurses/PSD.doc/Makefile @@ -1,4 +1,4 @@ -# @(#)Makefile 8.1 (Berkeley) 8/14/93 +# @(#)Makefile 8.2 (Berkeley) 5/23/94 DIR= psd/19.curses SRCS= Master @@ -22,7 +22,7 @@ VFONT= /usr/libexec/vfontedpr ${VFONT} $*.c | grep -v "^'wh" > $*.gr paper.ps: ${SRCS} - ${ROFF} ${SRCS} > ${.TARGET} + soelim ${SRCS} | ${ROFF} > ${.TARGET} Master: twinkle1.gr ex1.gr ex2.gr fns.doc intro.5 intro.2.tbl intro.0 intro.1 \ intro.3 intro.4 intro.6 macros c_macros diff --git a/lib/libcurses/PSD.doc/Master b/lib/libcurses/PSD.doc/Master index d9e7171..12db62b 100644 --- a/lib/libcurses/PSD.doc/Master +++ b/lib/libcurses/PSD.doc/Master @@ -29,7 +29,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)Master 8.1 (Berkeley) 6/8/93 +.\" @(#)Master 8.2 (Berkeley) 5/24/94 .\" .ds Ln Screen Package .so macros @@ -46,8 +46,8 @@ .bp .so appen.A .pn 2 -.oh '\*(Ln''PS1:19-%' -.eh 'PS1:19-%''\*(Ln' +.oh '\*(Ln''PSD:19-%' +.eh 'PSD:19-%''\*(Ln' .bp .bi Contents .sp diff --git a/lib/libcurses/PSD.doc/fns.doc b/lib/libcurses/PSD.doc/fns.doc index 30d5c4c..0fa89ab 100644 --- a/lib/libcurses/PSD.doc/fns.doc +++ b/lib/libcurses/PSD.doc/fns.doc @@ -29,7 +29,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)fns.doc 8.1 (Berkeley) 6/4/93 +.\" @(#)fns.doc 8.2 (Berkeley) 6/1/94 .\" .Ds .Fn addch "char ch" \(dg @@ -307,6 +307,7 @@ This will eventually signal to .Fn refresh that it is all right to use the insert and delete line sequences when updating the window. +.ne 1i .Ds .Fn inch "" \(dg .De @@ -514,6 +515,7 @@ Turn echoing of characters off. .De Unset the terminal to from nl mode. See .Fn nl . +.ne 1i .Ds .Fn noraw "" \(dg .De @@ -635,6 +637,7 @@ It does this using consecutive calls to (or .Fn wgetch ). \*(Es +.ne 1i .Ds .Fn scroll "WINDOW *win" .De @@ -744,6 +747,7 @@ Characters are 8 bits long. .De Returns the length of the ASCII representation of .Vn ch . +.ne 1i .Ds .Fn vwprintw "WINDOW *win" "const char *fmt" "va_list ap" .De diff --git a/lib/libcurses/addbytes.c b/lib/libcurses/addbytes.c index 5ec3a06..6dd8bf9 100644 --- a/lib/libcurses/addbytes.c +++ b/lib/libcurses/addbytes.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1987, 1993 + * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)addbytes.c 8.3 (Berkeley) 3/19/94"; +static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" #define SYNCH_IN {y = win->cury; x = win->curx;} #define SYNCH_OUT {win->cury = y; win->curx = x;} diff --git a/lib/libcurses/addch.c b/lib/libcurses/addch.c index a045c87..d5f3001 100644 --- a/lib/libcurses/addch.c +++ b/lib/libcurses/addch.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)addch.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)addch.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * waddch -- diff --git a/lib/libcurses/addnstr.c b/lib/libcurses/addnstr.c index bf607a0..92a6e68 100644 --- a/lib/libcurses/addnstr.c +++ b/lib/libcurses/addnstr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1993 + * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,12 +32,13 @@ */ #ifndef lint -static char sccsid[] = "@(#)addnstr.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)addnstr.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include #include +#include "curses.h" + /* * waddnstr -- * Add a string (at most n characters) to the given window diff --git a/lib/libcurses/box.c b/lib/libcurses/box.c index 4da2303..191e37c 100644 --- a/lib/libcurses/box.c +++ b/lib/libcurses/box.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)box.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)box.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * box -- diff --git a/lib/libcurses/clear.c b/lib/libcurses/clear.c index 89891e2..54c0b30 100644 --- a/lib/libcurses/clear.c +++ b/lib/libcurses/clear.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)clear.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)clear.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * wclear -- diff --git a/lib/libcurses/clrtobot.c b/lib/libcurses/clrtobot.c index 0e73ef8..81ee6a4 100644 --- a/lib/libcurses/clrtobot.c +++ b/lib/libcurses/clrtobot.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)clrtobot.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)clrtobot.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * wclrtobot -- diff --git a/lib/libcurses/clrtoeol.c b/lib/libcurses/clrtoeol.c index 6fa63b4..44fc190 100644 --- a/lib/libcurses/clrtoeol.c +++ b/lib/libcurses/clrtoeol.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)clrtoeol.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)clrtoeol.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * wclrtoeol -- diff --git a/lib/libcurses/cr_put.c b/lib/libcurses/cr_put.c index 2f7a9e9..ada2df5 100644 --- a/lib/libcurses/cr_put.c +++ b/lib/libcurses/cr_put.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,12 +32,13 @@ */ #ifndef lint -static char sccsid[] = "@(#)cr_put.c 8.2 (Berkeley) 1/9/94"; +static char sccsid[] = "@(#)cr_put.c 8.3 (Berkeley) 5/4/94"; #endif /* not lint */ -#include #include +#include "curses.h" + #define HARDTABS 8 /* diff --git a/lib/libcurses/curses.c b/lib/libcurses/curses.c index 87ed839..07cbb5b 100644 --- a/lib/libcurses/curses.c +++ b/lib/libcurses/curses.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)curses.c 8.2 (Berkeley) 1/2/94"; +static char sccsid[] = "@(#)curses.c 8.3 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* Private. */ int __echoit = 1; /* If stty indicates ECHO. */ diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h index 0eaef1e..d6f9d65 100644 --- a/lib/libcurses/curses.h +++ b/lib/libcurses/curses.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)curses.h 8.2 (Berkeley) 1/2/94 + * @(#)curses.h 8.5 (Berkeley) 4/29/95 */ #ifndef _CURSES_H_ @@ -45,7 +45,9 @@ * START BACKWARD COMPATIBILITY ONLY. */ #ifndef _CURSES_PRIVATE +#ifndef __cplusplus #define bool char +#endif #define reg register #ifndef TRUE @@ -137,14 +139,13 @@ typedef struct __window { /* Window structure. */ #define __ENDLINE 0x001 /* End of screen. */ #define __FLUSH 0x002 /* Fflush(stdout) after refresh. */ -#define __FULLLINE 0x004 /* Line width = terminal width. */ -#define __FULLWIN 0x008 /* Window is a screen. */ -#define __IDLINE 0x010 /* Insert/delete sequences. */ -#define __SCROLLWIN 0x020 /* Last char will scroll window. */ -#define __SCROLLOK 0x040 /* Scrolling ok. */ -#define __CLEAROK 0x080 /* Clear on next refresh. */ -#define __WSTANDOUT 0x100 /* Standout window */ -#define __LEAVEOK 0x200 /* If curser left */ +#define __FULLWIN 0x004 /* Window is a screen. */ +#define __IDLINE 0x008 /* Insert/delete sequences. */ +#define __SCROLLWIN 0x010 /* Last char will scroll window. */ +#define __SCROLLOK 0x020 /* Scrolling ok. */ +#define __CLEAROK 0x040 /* Clear on next refresh. */ +#define __WSTANDOUT 0x080 /* Standout window */ +#define __LEAVEOK 0x100 /* If curser left */ u_int flags; } WINDOW; @@ -287,8 +288,8 @@ int wmove __P((WINDOW *, int, int)); int wprintw __P((WINDOW *, const char *, ...)); int wrefresh __P((WINDOW *)); int wscanw __P((WINDOW *, const char *, ...)); -char *wstandend __P((WINDOW *)); -char *wstandout __P((WINDOW *)); +int wstandend __P((WINDOW *)); +int wstandout __P((WINDOW *)); int vwprintw __P((WINDOW *, const char *, _BSD_VA_LIST_)); /* Private functions that are needed for user programs prototypes. */ @@ -309,7 +310,7 @@ void __stop_signal_handler __P((int)); void __swflags __P((WINDOW *)); int __touchline __P((WINDOW *, int, int, int, int)); int __touchwin __P((WINDOW *)); -char *__tscroll __P((const char *, int)); +char *__tscroll __P((const char *, int, int)); int __waddch __P((WINDOW *, __LDATA *)); /* Private #defines. */ diff --git a/lib/libcurses/delch.c b/lib/libcurses/delch.c index ad7d352..b9cdc31 100644 --- a/lib/libcurses/delch.c +++ b/lib/libcurses/delch.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,12 +32,13 @@ */ #ifndef lint -static char sccsid[] = "@(#)delch.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)delch.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include #include +#include "curses.h" + /* * wdelch -- * Do an insert-char on the line, leaving (cury, curx) unchanged. diff --git a/lib/libcurses/deleteln.c b/lib/libcurses/deleteln.c index 6c4688a..4cb08ea 100644 --- a/lib/libcurses/deleteln.c +++ b/lib/libcurses/deleteln.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,12 +32,13 @@ */ #ifndef lint -static char sccsid[] = "@(#)deleteln.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)deleteln.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include #include +#include "curses.h" + /* * wdeleteln -- * Delete a line from the screen. It leaves (cury, curx) unchanged. diff --git a/lib/libcurses/delwin.c b/lib/libcurses/delwin.c index 3f6848a..7310db8 100644 --- a/lib/libcurses/delwin.c +++ b/lib/libcurses/delwin.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,12 +32,13 @@ */ #ifndef lint -static char sccsid[] = "@(#)delwin.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)delwin.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include #include +#include "curses.h" + /* * delwin -- * Delete a window and release it back to the system. diff --git a/lib/libcurses/erase.c b/lib/libcurses/erase.c index b19e15b..42ca68a 100644 --- a/lib/libcurses/erase.c +++ b/lib/libcurses/erase.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)erase.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)erase.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * werase -- diff --git a/lib/libcurses/getch.c b/lib/libcurses/getch.c index 77825bb..6108229 100644 --- a/lib/libcurses/getch.c +++ b/lib/libcurses/getch.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)getch.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * wgetch -- diff --git a/lib/libcurses/getstr.c b/lib/libcurses/getstr.c index 6194f1f..daf8e61 100644 --- a/lib/libcurses/getstr.c +++ b/lib/libcurses/getstr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)getstr.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)getstr.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * wgetstr -- diff --git a/lib/libcurses/id_subwins.c b/lib/libcurses/id_subwins.c index 6dc715c..3528348 100644 --- a/lib/libcurses/id_subwins.c +++ b/lib/libcurses/id_subwins.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)id_subwins.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)id_subwins.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * __id_subwins -- diff --git a/lib/libcurses/idlok.c b/lib/libcurses/idlok.c index ef0a1e2..4d3bb59 100644 --- a/lib/libcurses/idlok.c +++ b/lib/libcurses/idlok.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)idlok.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)idlok.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * idlok -- diff --git a/lib/libcurses/initscr.c b/lib/libcurses/initscr.c index 8ed0f9f..1af8b6f 100644 --- a/lib/libcurses/initscr.c +++ b/lib/libcurses/initscr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,13 +32,14 @@ */ #ifndef lint -static char sccsid[] = "@(#)initscr.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)initscr.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include #include #include +#include "curses.h" + /* * initscr -- * Initialize the current and standard screen. diff --git a/lib/libcurses/insch.c b/lib/libcurses/insch.c index 41b7383..36cc0de 100644 --- a/lib/libcurses/insch.c +++ b/lib/libcurses/insch.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,12 +32,13 @@ */ #ifndef lint -static char sccsid[] = "@(#)insch.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)insch.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include #include +#include "curses.h" + /* * winsch -- * Do an insert-char on the line, leaving (cury, curx) unchanged. diff --git a/lib/libcurses/insertln.c b/lib/libcurses/insertln.c index 87a61ee..c2179f0 100644 --- a/lib/libcurses/insertln.c +++ b/lib/libcurses/insertln.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,12 +32,13 @@ */ #ifndef lint -static char sccsid[] = "@(#)insertln.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)insertln.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include #include +#include "curses.h" + /* * winsertln -- * Do an insert-line on the window, leaving (cury, curx) unchanged. diff --git a/lib/libcurses/move.c b/lib/libcurses/move.c index 60a377b..1e22fb0 100644 --- a/lib/libcurses/move.c +++ b/lib/libcurses/move.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)move.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * wmove -- diff --git a/lib/libcurses/mvwin.c b/lib/libcurses/mvwin.c index 5699295..1471b27 100644 --- a/lib/libcurses/mvwin.c +++ b/lib/libcurses/mvwin.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)mvwin.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)mvwin.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * mvwin -- diff --git a/lib/libcurses/newwin.c b/lib/libcurses/newwin.c index a2f577a..8f09cbf 100644 --- a/lib/libcurses/newwin.c +++ b/lib/libcurses/newwin.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,12 +32,13 @@ */ #ifndef lint -static char sccsid[] = "@(#)newwin.c 8.1 (Berkeley) 7/20/93"; +static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94"; #endif /* not lint */ -#include #include +#include "curses.h" + #undef nl /* Don't need it here, and it interferes. */ static WINDOW *__makenew __P((int, int, int, int, int)); @@ -232,16 +233,11 @@ void __swflags(win) register WINDOW *win; { - win->flags &= - ~(__ENDLINE | __FULLLINE | __FULLWIN | __SCROLLWIN | __LEAVEOK); + win->flags &= ~(__ENDLINE | __FULLWIN | __SCROLLWIN | __LEAVEOK); if (win->begx + win->maxx == COLS) { win->flags |= __ENDLINE; - if (win->begx == 0) { - if (AL && DL) - win->flags |= __FULLLINE; - if (win->maxy == LINES && win->begy == 0) - win->flags |= __FULLWIN; - } + if (win->begx == 0 && win->maxy == LINES && win->begy == 0) + win->flags |= __FULLWIN; if (win->begy + win->maxy == LINES) win->flags |= __SCROLLWIN; } diff --git a/lib/libcurses/overlay.c b/lib/libcurses/overlay.c index 77248db..9f35c79 100644 --- a/lib/libcurses/overlay.c +++ b/lib/libcurses/overlay.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,11 +32,12 @@ */ #ifndef lint -static char sccsid[] = "@(#)overlay.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)overlay.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ #include -#include + +#include "curses.h" /* * overlay -- diff --git a/lib/libcurses/overwrite.c b/lib/libcurses/overwrite.c index 55c2b5e..e2d91bd 100644 --- a/lib/libcurses/overwrite.c +++ b/lib/libcurses/overwrite.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,13 +32,14 @@ */ #ifndef lint -static char sccsid[] = "@(#)overwrite.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)overwrite.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ #include -#include #include +#include "curses.h" + /* * overwrite -- * Writes win1 on win2 destructively. diff --git a/lib/libcurses/printw.c b/lib/libcurses/printw.c index bc34ce6..ae6ea49 100644 --- a/lib/libcurses/printw.c +++ b/lib/libcurses/printw.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,17 +32,17 @@ */ #ifndef lint -static char sccsid[] = "@(#)printw.c 8.2 (Berkeley) 10/5/93"; +static char sccsid[] = "@(#)printw.c 8.3 (Berkeley) 5/4/94"; #endif /* not lint */ -#include - #ifdef __STDC__ #include #else #include #endif +#include "curses.h" + /* * printw and friends. * diff --git a/lib/libcurses/putchar.c b/lib/libcurses/putchar.c index 7309bde..2ed5bb4 100644 --- a/lib/libcurses/putchar.c +++ b/lib/libcurses/putchar.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)putchar.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)putchar.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" void __cputchar(ch) diff --git a/lib/libcurses/refresh.c b/lib/libcurses/refresh.c index 1cd62f0..3271bd9 100644 --- a/lib/libcurses/refresh.c +++ b/lib/libcurses/refresh.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,18 +32,19 @@ */ #ifndef lint -static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 7/20/93"; +static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94"; #endif /* not lint */ -#include #include +#include "curses.h" + static int curwin; static short ly, lx; static void domvcur __P((int, int, int, int)); static int makech __P((WINDOW *, int)); -static void quickch __P((WINDOW *)); +static void quickch __P((WINDOW *)); static void scrolln __P((WINDOW *, int, int, int, int, int)); /* @@ -59,7 +60,7 @@ wrefresh(win) register int retval; register short wy; int dnum; - + /* Initialize loop parameters. */ ly = curscr->cury; lx = curscr->curx; @@ -70,8 +71,8 @@ wrefresh(win) for (wy = 0; wy < win->maxy; wy++) { wlp = win->lines[wy]; if (wlp->flags & __ISDIRTY) - wlp->hash = - __hash((char *) wlp->line, win->maxx * __LDATASIZE); + wlp->hash = __hash((char *)wlp->line, + win->maxx * __LDATASIZE); } if (win->flags & __CLEAROK || curscr->flags & __CLEAROK || curwin) { @@ -120,23 +121,23 @@ wrefresh(win) for (i = 0; i < curscr->maxy; i++) { __CTRACE("C: %d:", i); __CTRACE(" 0x%x \n", curscr->lines[i]->hash); - for (j = 0; j < curscr->maxx; j++) - __CTRACE("%c", + for (j = 0; j < curscr->maxx; j++) + __CTRACE("%c", curscr->lines[i]->line[j].ch); __CTRACE("\n"); - for (j = 0; j < curscr->maxx; j++) - __CTRACE("%x", + for (j = 0; j < curscr->maxx; j++) + __CTRACE("%x", curscr->lines[i]->line[j].attr); __CTRACE("\n"); __CTRACE("W: %d:", i); __CTRACE(" 0x%x \n", win->lines[i]->hash); __CTRACE(" 0x%x ", win->lines[i]->flags); - for (j = 0; j < win->maxx; j++) - __CTRACE("%c", + for (j = 0; j < win->maxx; j++) + __CTRACE("%c", win->lines[i]->line[j].ch); __CTRACE("\n"); - for (j = 0; j < win->maxx; j++) - __CTRACE("%x", + for (j = 0; j < win->maxx; j++) + __CTRACE("%x", win->lines[i]->line[j].attr); __CTRACE("\n"); } @@ -160,7 +161,7 @@ wrefresh(win) if (*win->lines[wy]->lastchp < win->maxx + win->ch_off) *win->lines[wy]->lastchp = win->ch_off; - if (*win->lines[wy]->lastchp < + if (*win->lines[wy]->lastchp < *win->lines[wy]->firstchp) { #ifdef DEBUG __CTRACE("wrefresh: line %d notdirty \n", wy); @@ -171,11 +172,11 @@ wrefresh(win) } #ifdef DEBUG - __CTRACE("\t%d\t%d\n", *win->lines[wy]->firstchp, + __CTRACE("\t%d\t%d\n", *win->lines[wy]->firstchp, *win->lines[wy]->lastchp); #endif } - + #ifdef DEBUG __CTRACE("refresh: ly=%d, lx=%d\n", ly, lx); #endif @@ -217,10 +218,10 @@ makech(win, wy) int wy; { static __LDATA blank = {' ', 0}; - register int nlsp, clsp; /* Last space in lines. */ - register int wx, lch, y; - register __LDATA *nsp, *csp, *cp, *cep; + __LDATA *nsp, *csp, *cp, *cep; u_int force; + int clsp, nlsp; /* Last space in lines. */ + int lch, wx, y; char *ce; /* Is the cursor still on the end of the last line? */ @@ -250,7 +251,7 @@ makech(win, wy) force = win->lines[wy]->flags & __FORCEPAINT; win->lines[wy]->flags &= ~__FORCEPAINT; if (CE && !curwin) { - for (cp = &win->lines[wy]->line[win->maxx - 1]; + for (cp = &win->lines[wy]->line[win->maxx - 1]; cp->ch == ' ' && cp->attr == 0; cp--) if (cp <= win->lines[wy]->line) break; @@ -269,16 +270,17 @@ makech(win, wy) __mvcur(0, 0, ly, lx, 1); } } + while (wx <= lch) { if (!force && memcmp(nsp, csp, sizeof(__LDATA)) == 0) { if (wx <= lch) { while (wx <= lch && - memcmp(nsp, csp, sizeof(__LDATA)) == 0) { - nsp++; - if (!curwin) - csp++; - ++wx; - } + memcmp(nsp, csp, sizeof(__LDATA)) == 0) { + nsp++; + if (!curwin) + ++csp; + ++wx; + } continue; } break; @@ -286,32 +288,34 @@ makech(win, wy) domvcur(ly, lx, y, wx + win->begx); #ifdef DEBUG - __CTRACE("makech: 1: wx = %d, ly= %d, lx = %d, newy = %d, newx = %d, force =%d\n", + __CTRACE("makech: 1: wx = %d, ly= %d, lx = %d, newy = %d, newx = %d, force =%d\n", wx, ly, lx, y, wx + win->begx, force); #endif ly = y; lx = wx + win->begx; - while ((force || memcmp(nsp, csp, sizeof(__LDATA)) != 0) + while ((force || memcmp(nsp, csp, sizeof(__LDATA)) != 0) && wx <= lch) { - if (ce != NULL && win->maxx + win->begx == - curscr->maxx && wx >= nlsp && nsp->ch == ' ') { + if (ce != NULL && + win->maxx + win->begx == curscr->maxx && + wx >= nlsp && nsp->ch == ' ' && nsp->attr == 0) { /* Check for clear to end-of-line. */ cep = &curscr->lines[wy]->line[win->maxx - 1]; while (cep->ch == ' ' && cep->attr == 0) if (cep-- <= csp) break; - clsp = cep - curscr->lines[wy]->line - + clsp = cep - curscr->lines[wy]->line - win->begx * __LDATASIZE; #ifdef DEBUG __CTRACE("makech: clsp = %d, nlsp = %d\n", clsp, nlsp); #endif - if ((clsp - nlsp >= strlen(CE) + if ((clsp - nlsp >= strlen(CE) && clsp < win->maxx * __LDATASIZE) || wy == win->maxy - 1) { -#ifdef DEBUG - __CTRACE("makech: using CE\n"); -#endif + if (curscr->flags & __WSTANDOUT) { + tputs(SE, 0, __cputchar); + curscr->flags &= ~__WSTANDOUT; + } tputs(CE, 0, __cputchar); lx = wx + win->begx; while (wx++ <= clsp) { @@ -324,17 +328,23 @@ makech(win, wy) ce = NULL; } - /* Enter/exit standout mode as appropriate. */ - if (SO && (nsp->attr & __STANDOUT) != - (curscr->flags & __WSTANDOUT)) { - if (nsp->attr & __STANDOUT) { + /* + * Enter/exit standout mode as appropriate. + * XXX + * Should use UC if SO/SE not available. + */ + if (nsp->attr & __STANDOUT) { + if (!(curscr->flags & __WSTANDOUT) && + SO != NULL && SE != NULL) { tputs(SO, 0, __cputchar); curscr->flags |= __WSTANDOUT; - } else { + } + } else + if (curscr->flags & __WSTANDOUT && + SE != NULL) { tputs(SE, 0, __cputchar); curscr->flags &= ~__WSTANDOUT; } - } wx++; if (wx >= win->maxx && wy == win->maxy - 1 && !curwin) @@ -355,21 +365,21 @@ makech(win, wy) putchar(nsp->ch); } if (wx + win->begx < curscr->maxx) { - domvcur(ly, wx + win->begx, + domvcur(ly, wx + win->begx, win->begy + win->maxy - 1, win->begx + win->maxx - 1); } ly = win->begy + win->maxy - 1; lx = win->begx + win->maxx - 1; return (OK); - } - if (wx < win->maxx || wy < win->maxy - 1 || + } + if (wx < win->maxx || wy < win->maxy - 1 || !(win->flags & __SCROLLWIN)) { if (!curwin) { csp->attr = nsp->attr; putchar(csp->ch = nsp->ch); csp++; - } else + } else putchar(nsp->ch); } #ifdef DEBUG @@ -398,6 +408,12 @@ makech(win, wy) __CTRACE("makech: 3: wx = %d, lx = %d\n", wx, lx); #endif } + + /* Don't leave the screen in standout mode. */ + if (curscr->flags & __WSTANDOUT) { + tputs(SE, 0, __cputchar); + curscr->flags &= ~__WSTANDOUT; + } return (OK); } @@ -419,7 +435,7 @@ domvcur(oy, ox, ny, nx) /* * Quickch() attempts to detect a pattern in the change of the window - * in order to optimize the change, e.g., scroll n lines as opposed to + * in order to optimize the change, e.g., scroll n lines as opposed to * repainting the screen line by line. */ @@ -435,26 +451,26 @@ quickch(win) __LDATA buf[1024]; u_int blank_hash; - /* + /* * Find how many lines from the top of the screen are unchanged. */ - for (top = 0; top < win->maxy; top++) + for (top = 0; top < win->maxy; top++) if (win->lines[top]->flags & __FORCEPAINT || - win->lines[top]->hash != curscr->lines[top]->hash - || memcmp(win->lines[top]->line, - curscr->lines[top]->line, + win->lines[top]->hash != curscr->lines[top]->hash + || memcmp(win->lines[top]->line, + curscr->lines[top]->line, win->maxx * __LDATASIZE) != 0) break; else win->lines[top]->flags &= ~__ISDIRTY; /* - * Find how many lines from bottom of screen are unchanged. + * Find how many lines from bottom of screen are unchanged. */ for (bot = win->maxy - 1; bot >= 0; bot--) if (win->lines[bot]->flags & __FORCEPAINT || - win->lines[bot]->hash != curscr->lines[bot]->hash - || memcmp(win->lines[bot]->line, - curscr->lines[bot]->line, + win->lines[bot]->hash != curscr->lines[bot]->hash + || memcmp(win->lines[bot]->line, + curscr->lines[bot]->line, win->maxx * __LDATASIZE) != 0) break; else @@ -475,16 +491,16 @@ quickch(win) * Search for the largest block of text not changed. * Invariants of the loop: * - Startw is the index of the beginning of the examined block in win. - * - Starts is the index of the beginning of the examined block in + * - Starts is the index of the beginning of the examined block in * curscr. * - Curs is the index of one past the end of the exmined block in win. - * - Curw is the index of one past the end of the exmined block in + * - Curw is the index of one past the end of the exmined block in * curscr. * - bsize is the current size of the examined block. */ for (bsize = bot - top; bsize >= THRESH; bsize--) { for (startw = top; startw <= bot - bsize; startw++) - for (starts = top; starts <= bot - bsize; + for (starts = top; starts <= bot - bsize; starts++) { for (curw = startw, curs = starts; curs < starts + bsize; curw++, curs++) @@ -492,8 +508,8 @@ quickch(win) __FORCEPAINT || (win->lines[curw]->hash != curscr->lines[curs]->hash || - memcmp(win->lines[curw]->line, - curscr->lines[curs]->line, + memcmp(win->lines[curw]->line, + curscr->lines[curs]->line, win->maxx * __LDATASIZE) != 0)) break; if (curs == starts + bsize) @@ -502,16 +518,16 @@ quickch(win) } done: /* Did not find anything */ - if (bsize < THRESH) + if (bsize < THRESH) return; #ifdef DEBUG - __CTRACE("quickch:bsize=%d,starts=%d,startw=%d,curw=%d,curs=%d,top=%d,bot=%d\n", + __CTRACE("quickch:bsize=%d,starts=%d,startw=%d,curw=%d,curs=%d,top=%d,bot=%d\n", bsize, starts, startw, curw, curs, top, bot); #endif - /* - * Make sure that there is no overlap between the bottom and top + /* + * Make sure that there is no overlap between the bottom and top * regions and the middle scrolled block. */ if (bot < curs) @@ -526,28 +542,28 @@ quickch(win) for (i = 0; i < curscr->maxy; i++) { __CTRACE("C: %d:", i); __CTRACE(" 0x%x \n", curscr->lines[i]->hash); - for (j = 0; j < curscr->maxx; j++) - __CTRACE("%c", + for (j = 0; j < curscr->maxx; j++) + __CTRACE("%c", curscr->lines[i]->line[j].ch); __CTRACE("\n"); - for (j = 0; j < curscr->maxx; j++) - __CTRACE("%x", + for (j = 0; j < curscr->maxx; j++) + __CTRACE("%x", curscr->lines[i]->line[j].attr); __CTRACE("\n"); __CTRACE("W: %d:", i); __CTRACE(" 0x%x \n", win->lines[i]->hash); __CTRACE(" 0x%x ", win->lines[i]->flags); - for (j = 0; j < win->maxx; j++) - __CTRACE("%c", + for (j = 0; j < win->maxx; j++) + __CTRACE("%c", win->lines[i]->line[j].ch); __CTRACE("\n"); - for (j = 0; j < win->maxx; j++) - __CTRACE("%x", + for (j = 0; j < win->maxx; j++) + __CTRACE("%x", win->lines[i]->line[j].attr); __CTRACE("\n"); } -#endif - +#endif + /* So we don't have to call __hash() each time */ for (i = 0; i < win->maxx; i++) { buf[i].ch = ' '; @@ -563,27 +579,27 @@ quickch(win) * - Target is the index of the target of line i. * - Tmp1 points to current line (i). * - Tmp2 and points to target line (target); - * - Cur_period is the index of the end of the current period. + * - Cur_period is the index of the end of the current period. * (see below). * * There are 2 major issues here that make this rotation non-trivial: * 1. Scrolling in a scrolling region bounded by the top * and bottom regions determined (whose size is sc_region). - * 2. As a result of the use of the mod function, there may be a + * 2. As a result of the use of the mod function, there may be a * period introduced, i.e., 2 maps to 4, 4 to 6, n-2 to 0, and * 0 to 2, which then causes all odd lines not to be rotated. - * To remedy this, an index of the end ( = beginning) of the - * current 'period' is kept, cur_period, and when it is reached, - * the next period is started from cur_period + 1 which is + * To remedy this, an index of the end ( = beginning) of the + * current 'period' is kept, cur_period, and when it is reached, + * the next period is started from cur_period + 1 which is * guaranteed not to have been reached since that would mean that * all records would have been reached. (think about it...). - * + * * Lines in the rotation can have 3 attributes which are marked on the * line so that curscr is consistent with the visual screen. * 1. Not dirty -- lines inside the scrolled block, top region or * bottom region. - * 2. Blank lines -- lines in the differential of the scrolling - * region adjacent to top and bot regions + * 2. Blank lines -- lines in the differential of the scrolling + * region adjacent to top and bot regions * depending on scrolling direction. * 3. Dirty line -- all other lines are marked dirty. */ @@ -601,7 +617,7 @@ quickch(win) __CTRACE("quickch: n=%d startw=%d curw=%d i = %d target=%d ", n, startw, curw, i, target); #endif - if ((target >= startw && target < curw) || target < top + if ((target >= startw && target < curw) || target < top || target > bot) { #ifdef DEBUG __CTRACE("-- notdirty"); @@ -609,7 +625,7 @@ quickch(win) win->lines[target]->flags &= ~__ISDIRTY; } else if ((n > 0 && target >= top && target < top + n) || (n < 0 && target <= bot && target > bot + n)) { - if (clp->hash != blank_hash || memcmp(clp->line, + if (clp->hash != blank_hash || memcmp(clp->line, buf, win->maxx * __LDATASIZE) !=0) { (void)memcpy(clp->line, buf, win->maxx * __LDATASIZE); @@ -646,14 +662,13 @@ quickch(win) __CTRACE("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); for (i = 0; i < curscr->maxy; i++) { __CTRACE("C: %d:", i); - for (j = 0; j < curscr->maxx; j++) - __CTRACE("%c", + for (j = 0; j < curscr->maxx; j++) + __CTRACE("%c", curscr->lines[i]->line[j].ch); __CTRACE("\n"); __CTRACE("W: %d:", i); - for (j = 0; j < win->maxx; j++) - __CTRACE("%c", - win->lines[i]->line[j].ch); + for (j = 0; j < win->maxx; j++) + __CTRACE("%c", win->lines[i]->line[j].ch); __CTRACE("\n"); } #endif @@ -662,7 +677,7 @@ quickch(win) scrolln(win, starts, startw, curs, bot, top); /* * Need to repoint any subwindow lines to the rotated - * line structured. + * line structured. */ for (wp = win->nextp; wp != win; wp = wp->nextp) __set_subwin(win, wp); @@ -670,7 +685,8 @@ quickch(win) } /* - * Scrolln performs the scroll by n lines, where n is starts - startw. + * scrolln -- + * Scroll n lines, where n is starts - startw. */ static void scrolln(win, starts, startw, curs, bot, top) @@ -683,41 +699,129 @@ scrolln(win, starts, startw, curs, bot, top) ox = curscr->curx; n = starts - startw; + /* + * XXX + * The initial tests that set __noqch don't let us reach here unless + * we have either CS + HO + SF/sf/SR/sr, or AL + DL. SF/sf and SR/sr + * scrolling can only shift the entire scrolling region, not just a + * part of it, which means that the quickch() routine is going to be + * sadly disappointed in us if we don't have CS as well. + * + * If CS, HO and SF/sf are set, can use the scrolling region. Because + * the cursor position after CS is undefined, we need HO which gives us + * the ability to move to somewhere without knowledge of the current + * location of the cursor. Still call __mvcur() anyway, to update its + * idea of where the cursor is. + * + * When the scrolling region has been set, the cursor has to be at the + * last line of the region to make the scroll happen. + * + * Doing SF/SR or AL/DL appears faster on the screen than either sf/sr + * or al/dl, and, some terminals have AL/DL, sf/sr, and CS, but not + * SF/SR. So, if we're scrolling almost all of the screen, try and use + * AL/DL, otherwise use the scrolling region. The "almost all" is a + * shameless hack for vi. + */ if (n > 0) { - __mvcur(oy, ox, top, 0, 1); - /* Scroll up the block */ - if (DL) - tputs(__tscroll(DL, n), 0, __cputchar); - else - for(i = 0; i < n; i++) - tputs(dl, 0, __cputchar); + if (CS != NULL && HO != NULL && (SF != NULL || + (AL == NULL || DL == NULL || + top > 3 || bot + 3 < win->maxy) && sf != NULL)) { + tputs(__tscroll(CS, top, bot + 1), 0, __cputchar); + __mvcur(oy, ox, 0, 0, 1); + tputs(HO, 0, __cputchar); + __mvcur(0, 0, bot, 0, 1); + if (SF != NULL) + tputs(__tscroll(SF, n, 0), 0, __cputchar); + else + for (i = 0; i < n; i++) + tputs(sf, 0, __cputchar); + tputs(__tscroll(CS, 0, win->maxy), 0, __cputchar); + __mvcur(bot, 0, 0, 0, 1); + tputs(HO, 0, __cputchar); + __mvcur(0, 0, oy, ox, 1); + return; + } - /* - * Push down the bottom region. - */ + /* Scroll up the block. */ + if (SF != NULL && top == 0) { + __mvcur(oy, ox, bot, 0, 1); + tputs(__tscroll(SF, n, 0), 0, __cputchar); + } else if (DL != NULL) { + __mvcur(oy, ox, top, 0, 1); + tputs(__tscroll(DL, n, 0), 0, __cputchar); + } else if (dl != NULL) { + __mvcur(oy, ox, top, 0, 1); + for (i = 0; i < n; i++) + tputs(dl, 0, __cputchar); + } else if (sf != NULL && top == 0) { + __mvcur(oy, ox, bot, 0, 1); + for (i = 0; i < n; i++) + tputs(sf, 0, __cputchar); + } else + abort(); + + /* Push down the bottom region. */ __mvcur(top, 0, bot - n + 1, 0, 1); - if (AL) - tputs(__tscroll(AL, n), 0, __cputchar); - else - for(i = 0; i < n; i++) + if (AL != NULL) + tputs(__tscroll(AL, n, 0), 0, __cputchar); + else if (al != NULL) + for (i = 0; i < n; i++) tputs(al, 0, __cputchar); + else + abort(); __mvcur(bot - n + 1, 0, oy, ox, 1); } else { - /* Preserve the bottom lines */ - __mvcur(oy, ox, bot + n + 1, 0, 1); /* n < 0 */ - if (DL) - tputs(__tscroll(DL, -n), 0, __cputchar); - else - for(i = n; i < 0; i++) - tputs(dl, 0, __cputchar); - __mvcur(bot + n + 1, 0, top, 0, 1); + /* + * !!! + * n < 0 + * + * If CS, HO and SR/sr are set, can use the scrolling region. + * See the above comments for details. + */ + if (CS != NULL && HO != NULL && (SR != NULL || + (AL == NULL || DL == NULL || + top > 3 || bot + 3 < win->maxy) && sr != NULL)) { + tputs(__tscroll(CS, top, bot + 1), 0, __cputchar); + __mvcur(oy, ox, 0, 0, 1); + tputs(HO, 0, __cputchar); + __mvcur(0, 0, top, 0, 1); + + if (SR != NULL) + tputs(__tscroll(SR, -n, 0), 0, __cputchar); + else + for (i = n; i < 0; i++) + tputs(sr, 0, __cputchar); + tputs(__tscroll(CS, 0, win->maxy), 0, __cputchar); + __mvcur(top, 0, 0, 0, 1); + tputs(HO, 0, __cputchar); + __mvcur(0, 0, oy, ox, 1); + return; + } - /* Scroll the block down */ - if (AL) - tputs(__tscroll(AL, -n), 0, __cputchar); + /* Preserve the bottom lines. */ + __mvcur(oy, ox, bot + n + 1, 0, 1); + if (SR != NULL && bot == win->maxy) + tputs(__tscroll(SR, -n, 0), 0, __cputchar); + else if (DL != NULL) + tputs(__tscroll(DL, -n, 0), 0, __cputchar); + else if (dl != NULL) + for (i = n; i < 0; i++) + tputs(dl, 0, __cputchar); + else if (sr != NULL && bot == win->maxy) + for (i = n; i < 0; i++) + tputs(sr, 0, __cputchar); else - for(i = n; i < 0; i++) + abort(); + + /* Scroll the block down. */ + __mvcur(bot + n + 1, 0, top, 0, 1); + if (AL != NULL) + tputs(__tscroll(AL, -n, 0), 0, __cputchar); + else if (al != NULL) + for (i = n; i < 0; i++) tputs(al, 0, __cputchar); + else + abort(); __mvcur(top, 0, oy, ox, 1); - } + } } diff --git a/lib/libcurses/scanw.c b/lib/libcurses/scanw.c index ddd1ba9..d8d79fd 100644 --- a/lib/libcurses/scanw.c +++ b/lib/libcurses/scanw.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,21 +32,21 @@ */ #ifndef lint -static char sccsid[] = "@(#)scanw.c 8.2 (Berkeley) 10/5/93"; +static char sccsid[] = "@(#)scanw.c 8.3 (Berkeley) 5/4/94"; #endif /* not lint */ /* * scanw and friends. */ -#include - #ifdef __STDC__ #include #else #include #endif +#include "curses.h" + /* * scanw -- * Implement a scanf on the standard screen. diff --git a/lib/libcurses/scroll.c b/lib/libcurses/scroll.c index 1b03ecc..8aad91c 100644 --- a/lib/libcurses/scroll.c +++ b/lib/libcurses/scroll.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)scroll.c 8.2 (Berkeley) 1/9/94"; +static char sccsid[] = "@(#)scroll.c 8.3 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * scroll -- diff --git a/lib/libcurses/setterm.c b/lib/libcurses/setterm.c index f611ac7..887bcb1 100644 --- a/lib/libcurses/setterm.c +++ b/lib/libcurses/setterm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,16 +32,18 @@ */ #ifndef lint -static char sccsid[] = "@(#)setterm.c 8.3 (Berkeley) 1/2/94"; +static char sccsid[] = "@(#)setterm.c 8.8 (Berkeley) 10/25/94"; #endif /* not lint */ -#include +#include /* TIOCGWINSZ on old systems. */ -#include #include #include +#include #include +#include "curses.h" + static void zap __P((void)); static char *sflags[] = { @@ -139,10 +141,11 @@ setterm(type) * Test for cursor motion capbility. * * XXX - * This is truly stupid -- tgoto returns "OOPS" if it can't - * do cursor motions. + * This is truly stupid -- historically, tgoto returns "OOPS" if it + * can't do cursor motions. Some systems have been fixed to return + * a NULL pointer. */ - if (tgoto(CM, 0, 0)[0] == 'O') { + if ((p = tgoto(CM, 0, 0)) == NULL || *p == 'O') { CA = 0; CM = 0; } else @@ -152,8 +155,11 @@ setterm(type) aoftspace = tspace; ttytype = longname(genbuf, __ttytype); - if ((!AL && !al) || (!DL && !dl)) - __noqch = 1; + /* If no scrolling commands, no quick change. */ + __noqch = + (CS == NULL || HO == NULL || + SF == NULL && sf == NULL || SR == NULL && sr == NULL) && + (AL == NULL && al == NULL || DL == NULL && dl == NULL); return (unknown ? ERR : OK); } diff --git a/lib/libcurses/standout.c b/lib/libcurses/standout.c index 907184b..8851d63 100644 --- a/lib/libcurses/standout.c +++ b/lib/libcurses/standout.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,37 +32,36 @@ */ #ifndef lint -static char sccsid[] = "@(#)standout.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)standout.c 8.3 (Berkeley) 8/10/94"; #endif /* not lint */ -#include +#include "curses.h" /* * wstandout * Enter standout mode. */ -char * +int wstandout(win) - register WINDOW *win; + WINDOW *win; { - if (!SO && !UC) - return (0); - - win->flags |= __WSTANDOUT; - return (SO ? SO : UC); + /* + * If standout/standend strings, or can underline, set the + * screen standout bit. + */ + if (SO != NULL && SE != NULL || UC != NULL) + win->flags |= __WSTANDOUT; + return (1); } /* * wstandend -- * Exit standout mode. */ -char * +int wstandend(win) - register WINDOW *win; + WINDOW *win; { - if (!SO && !UC) - return (0); - win->flags &= ~__WSTANDOUT; - return (SE ? SE : UC); + return (1); } diff --git a/lib/libcurses/toucholap.c b/lib/libcurses/toucholap.c index 8924ebe..955c204 100644 --- a/lib/libcurses/toucholap.c +++ b/lib/libcurses/toucholap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)toucholap.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)toucholap.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include +#include "curses.h" /* * touchoverlap -- diff --git a/lib/libcurses/touchwin.c b/lib/libcurses/touchwin.c index 68fa785..36f487e 100644 --- a/lib/libcurses/touchwin.c +++ b/lib/libcurses/touchwin.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,11 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)touchwin.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)touchwin.c 8.2 (Berkeley) 5/4/94"; #endif /* not lint */ -#include - +#include "curses.h" /* * touchline -- diff --git a/lib/libcurses/tscroll.c b/lib/libcurses/tscroll.c index db7eda9..359b396 100644 --- a/lib/libcurses/tscroll.c +++ b/lib/libcurses/tscroll.c @@ -32,10 +32,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)tscroll.c 8.2 (Berkeley) 4/15/94"; +static char sccsid[] = "@(#)tscroll.c 8.4 (Berkeley) 7/27/94"; #endif /* not lint */ -#include +#include "curses.h" #define MAXRETURNSIZE 64 @@ -61,17 +61,17 @@ static char sccsid[] = "@(#)tscroll.c 8.2 (Berkeley) 4/15/94"; * all other characters are ``self-inserting''. */ char * -__tscroll(cap, n) +__tscroll(cap, n1, n2) const char *cap; - int n; + int n1, n2; { static char result[MAXRETURNSIZE]; - int c; + int c, n; char *dp; if (cap == NULL) goto err; - for (dp = result; (c = *cap++) != '\0';) { + for (n = n1, dp = result; (c = *cap++) != '\0';) { if (c != '%') { *dp++ = c; continue; @@ -93,6 +93,7 @@ __tscroll(cap, n) case '2': two: *dp++ = n / 10 | '0'; one: *dp++ = n % 10 | '0'; + n = n2; continue; case '>': if (n > *cap++) diff --git a/lib/libcurses/tstp.c b/lib/libcurses/tstp.c index 3a81751..07debf4 100644 --- a/lib/libcurses/tstp.c +++ b/lib/libcurses/tstp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1981, 1993 + * Copyright (c) 1981, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,15 +32,15 @@ */ #ifndef lint -static char sccsid[] = "@(#)tstp.c 8.2 (Berkeley) 1/2/94"; +static char sccsid[] = "@(#)tstp.c 8.3 (Berkeley) 5/4/94"; #endif /* not lint */ -#include #include #include #include #include +#include "curses.h" /* * stop_signal_handler -- diff --git a/lib/libcurses/tty.c b/lib/libcurses/tty.c index e2693fb..db031d5 100644 --- a/lib/libcurses/tty.c +++ b/lib/libcurses/tty.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1992, 1993 + * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,15 +32,15 @@ */ #ifndef lint -static char sccsid[] = "@(#)tty.c 8.2 (Berkeley) 1/2/94"; +static char sccsid[] = "@(#)tty.c 8.6 (Berkeley) 1/10/95"; #endif /* not lint */ -#include - -#include +#include #include #include +#include "curses.h" + /* * In general, curses should leave tty hardware settings alone (speed, parity, * word size). This is most easily done in BSD by using TCSASOFT on all @@ -126,7 +126,7 @@ raw() useraw = __pfast = __rawmode = 1; curt = &rawt; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -135,7 +135,7 @@ noraw() useraw = __pfast = __rawmode = 0; curt = &__baset; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -145,7 +145,7 @@ cbreak() __rawmode = 1; curt = useraw ? &rawt : &cbreakt; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -155,7 +155,7 @@ nocbreak() __rawmode = 0; curt = useraw ? &rawt : &__baset; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -167,7 +167,7 @@ echo() __echoit = 1; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -179,7 +179,7 @@ noecho() __echoit = 0; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -194,7 +194,7 @@ nl() __pfast = __rawmode; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -209,14 +209,31 @@ nonl() __pfast = 1; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } void __startwin() { + static char *stdbuf; + static size_t len; + (void)fflush(stdout); - (void)setvbuf(stdout, NULL, _IOFBF, 0); + + /* + * Some C libraries default to a 1K buffer when talking to a tty. + * With a larger screen, especially across a network, we'd like + * to get it to all flush in a single write. Make it twice as big + * as just the characters (so that we have room for cursor motions + * and standout information) but no more than 8K. + */ + if (stdbuf == NULL) { + if ((len = LINES * COLS * 2) > 8192) + len = 8192; + if ((stdbuf = malloc(len)) == NULL) + len = 0; + } + (void)setvbuf(stdout, stdbuf, _IOFBF, len); tputs(TI, 0, __cputchar); tputs(VS, 0, __cputchar); @@ -232,7 +249,7 @@ endwin() tputs(SE, 0, __cputchar); curscr->flags &= ~__WSTANDOUT; } - __mvcur(curscr->cury, curscr->cury, curscr->maxy - 1, 0, 0); + __mvcur(curscr->cury, curscr->curx, curscr->maxy - 1, 0, 0); } (void)tputs(VE, 0, __cputchar); @@ -241,7 +258,7 @@ endwin() (void)setvbuf(stdout, NULL, _IOLBF, 0); return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, &__orig_termios)); + TCSASOFT | TCSADRAIN : TCSADRAIN, &__orig_termios) ? ERR : OK); } /* @@ -253,12 +270,12 @@ static struct termios savedtty; int savetty() { - return (tcgetattr(STDIN_FILENO, &savedtty)); + return (tcgetattr(STDIN_FILENO, &savedtty) ? ERR : OK); } int resetty() { return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, &savedtty)); + TCSASOFT | TCSADRAIN : TCSADRAIN, &savedtty) ? ERR : OK); } -- cgit v1.1