Brought the 2.0 libcurses up-to-date with the current 4.4 stuff, as

distributed in keith bostic's nvi (got his permission first).  Most changes
are cosmetic, but a few errors (mostly in tty..c) were cleared up.

Reviewed by:	Sean Eric Fagan
This commit is contained in:
Sean Eric Fagan 1994-08-13 23:15:38 +00:00
parent 3540f0e14a
commit 6c8ac72df7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=2062
38 changed files with 277 additions and 179 deletions

View File

@ -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 <curses.h>
#include "curses.h"
#define SYNCH_IN {y = win->cury; x = win->curx;}
#define SYNCH_OUT {win->cury = y; win->curx = x;}

View File

@ -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 <curses.h>
#include "curses.h"
/*
* waddch --

View File

@ -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 <curses.h>
#include <string.h>
#include "curses.h"
/*
* waddnstr --
* Add a string (at most n characters) to the given window

View File

@ -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 <curses.h>
#include "curses.h"
/*
* box --

View File

@ -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 <curses.h>
#include "curses.h"
/*
* wclear --

View File

@ -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 <curses.h>
#include "curses.h"
/*
* wclrtobot --

View File

@ -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 <curses.h>
#include "curses.h"
/*
* wclrtoeol --

View File

@ -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 <curses.h>
#include <string.h>
#include "curses.h"
#define HARDTABS 8
/*

View File

@ -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 <curses.h>
#include "curses.h"
/* Private. */
int __echoit = 1; /* If stty indicates ECHO. */

View File

@ -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,12 +30,15 @@
* 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.3 (Berkeley) 7/27/94
*/
#ifndef _CURSES_H_
#define _CURSES_H_
#include <sys/types.h>
#include <sys/cdefs.h>
#include <stdio.h>
/*
@ -137,14 +140,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;
@ -309,7 +311,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. */

View File

@ -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 <curses.h>
#include <string.h>
#include "curses.h"
/*
* wdelch --
* Do an insert-char on the line, leaving (cury, curx) unchanged.

View File

@ -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 <curses.h>
#include <string.h>
#include "curses.h"
/*
* wdeleteln --
* Delete a line from the screen. It leaves (cury, curx) unchanged.

View File

@ -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 <curses.h>
#include <stdlib.h>
#include "curses.h"
/*
* delwin --
* Delete a window and release it back to the system.

View File

@ -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 <curses.h>
#include "curses.h"
/*
* werase --

View File

@ -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 <curses.h>
#include "curses.h"
/*
* wgetch --

View File

@ -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 <curses.h>
#include "curses.h"
/*
* wgetstr --

View File

@ -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 <curses.h>
#include "curses.h"
/*
* __id_subwins --

View File

@ -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 <curses.h>
#include "curses.h"
/*
* idlok --

View File

@ -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 <curses.h>
#include <signal.h>
#include <stdlib.h>
#include "curses.h"
/*
* initscr --
* Initialize the current and standard screen.

View File

@ -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 <curses.h>
#include <string.h>
#include "curses.h"
/*
* winsch --
* Do an insert-char on the line, leaving (cury, curx) unchanged.

View File

@ -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 <curses.h>
#include <string.h>
#include "curses.h"
/*
* winsertln --
* Do an insert-line on the window, leaving (cury, curx) unchanged.

View File

@ -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 <curses.h>
#include "curses.h"
/*
* wmove --

View File

@ -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 <curses.h>
#include "curses.h"
/*
* mvwin --

View File

@ -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 <curses.h>
#include <stdlib.h>
#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)
if (win->begx == 0 && win->maxy == LINES && win->begy == 0)
win->flags |= __FULLWIN;
}
if (win->begy + win->maxy == LINES)
win->flags |= __SCROLLWIN;
}

View File

@ -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 <ctype.h>
#include <curses.h>
#include "curses.h"
/*
* overlay --

View File

@ -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 <ctype.h>
#include <curses.h>
#include <string.h>
#include "curses.h"
/*
* overwrite --
* Writes win1 on win2 destructively.

View File

@ -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 <curses.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "curses.h"
/*
* printw and friends.
*

View File

@ -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 <curses.h>
#include "curses.h"
void
__cputchar(ch)

View File

@ -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[] = "@(#)refresh.c 8.1 (Berkeley) 7/20/93";
static char sccsid[] = "@(#)refresh.c 8.4 (Berkeley) 8/4/94";
#endif /* not lint */
#include <curses.h>
#include <string.h>
#include "curses.h"
static int curwin;
static short ly, lx;
@ -652,8 +653,7 @@ quickch(win)
__CTRACE("\n");
__CTRACE("W: %d:", i);
for (j = 0; j < win->maxx; j++)
__CTRACE("%c",
win->lines[i]->line[j].ch);
__CTRACE("%c", win->lines[i]->line[j].ch);
__CTRACE("\n");
}
#endif
@ -670,7 +670,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 +684,126 @@ 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);
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(dl, 0, __cputchar);
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.
*/
__mvcur(top, 0, bot - n + 1, 0, 1);
if (AL)
tputs(__tscroll(AL, n), 0, __cputchar);
/* Scroll up the block. */
__mvcur(oy, ox, top, 0, 1);
if (SF != NULL && top == 0)
tputs(__tscroll(SF, n, 0), 0, __cputchar);
else if (DL != NULL)
tputs(__tscroll(DL, n, 0), 0, __cputchar);
else if (dl != NULL)
for (i = 0; i < n; i++)
tputs(dl, 0, __cputchar);
else if (sf != NULL && top == 0)
for (i = 0; i < n; i++)
tputs(sf, 0, __cputchar);
else
for(i = 0; i < n; i++)
abort();
/* Push down the bottom region. */
__mvcur(top, 0, bot - n + 1, 0, 1);
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);
/* Scroll the block down */
if (AL)
tputs(__tscroll(AL, -n), 0, __cputchar);
if (SR != NULL)
tputs(__tscroll(SR, -n, 0), 0, __cputchar);
else
for(i = n; i < 0; i++)
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;
}
/* 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
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);
}
}

View File

@ -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 <curses.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "curses.h"
/*
* scanw --
* Implement a scanf on the standard screen.

View File

@ -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 <curses.h>
#include "curses.h"
/*
* scroll --

View File

@ -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.7 (Berkeley) 7/27/94";
#endif /* not lint */
#include <sys/ioctl.h>
#include <sys/ioctl.h> /* TIOCGWINSZ on old systems. */
#include <curses.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include "curses.h"
static void zap __P((void));
static char *sflags[] = {
@ -152,8 +154,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);
}

View File

@ -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[] = "@(#)standout.c 8.1 (Berkeley) 6/4/93";
static char sccsid[] = "@(#)standout.c 8.2 (Berkeley) 5/4/94";
#endif /* not lint */
#include <curses.h>
#include "curses.h"
/*
* wstandout

View File

@ -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 <curses.h>
#include "curses.h"
/*
* touchoverlap --

View File

@ -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 <curses.h>
#include "curses.h"
/*
* touchline --

View File

@ -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 <curses.h>
#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++)

View File

@ -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 <curses.h>
#include <errno.h>
#include <signal.h>
#include <termios.h>
#include <unistd.h>
#include "curses.h"
/*
* stop_signal_handler --

View File

@ -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,14 @@
*/
#ifndef lint
static char sccsid[] = "@(#)tty.c 8.2 (Berkeley) 1/2/94";
static char sccsid[] = "@(#)tty.c 8.4 (Berkeley) 5/18/94";
#endif /* not lint */
#include <sys/ioctl.h>
#include <curses.h>
#include <termios.h>
#include <unistd.h>
#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 +125,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 +134,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 +144,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 +154,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 +166,7 @@ echo()
__echoit = 1;
return (tcsetattr(STDIN_FILENO, __tcaction ?
TCSASOFT | TCSADRAIN : TCSADRAIN, curt));
TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
}
int
@ -179,7 +178,7 @@ noecho()
__echoit = 0;
return (tcsetattr(STDIN_FILENO, __tcaction ?
TCSASOFT | TCSADRAIN : TCSADRAIN, curt));
TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
}
int
@ -194,7 +193,7 @@ nl()
__pfast = __rawmode;
return (tcsetattr(STDIN_FILENO, __tcaction ?
TCSASOFT | TCSADRAIN : TCSADRAIN, curt));
TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
}
int
@ -209,7 +208,7 @@ nonl()
__pfast = 1;
return (tcsetattr(STDIN_FILENO, __tcaction ?
TCSASOFT | TCSADRAIN : TCSADRAIN, curt));
TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK);
}
void
@ -241,7 +240,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 +252,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);
}