First libcurses commit with changes for GNO

This commit is contained in:
taubert 1998-01-26 06:09:49 +00:00
parent 4079986d8b
commit a7b5aa5c8a
49 changed files with 844 additions and 430 deletions

View File

@ -50,9 +50,9 @@ static char sccsid[] = "@(#)ex1.c 8.1 (Berkeley) 6/4/93";
#define YSIZE 10
#define XSIZE 20
int quit();
void quit(int sig, int code);
main()
int main(int argc, char *argv[])
{
int i, j, c;
size_t len;
@ -76,7 +76,7 @@ main()
c = getchar();
switch(c) {
case 'q': /* Quit on 'q' */
quit();
quit(0, 0);
break;
case 's': /* Go into standout mode on 's' */
standout();
@ -94,9 +94,9 @@ main()
}
}
int
quit()
#pragma databank 1
void
quit(int sig, int code)
{
erase(); /* Terminate by erasing the screen */
refresh();
@ -106,7 +106,17 @@ quit()
putchar('\n');
exit(0);
}
#pragma databank 0
#ifdef __GNO__
int tcsetattr(int fd, int action, const struct termios *tt)
{
return 0;
}
int tcgetattr(int fd, struct termios *tt)
{
return 0;
}
#endif

View File

@ -1,22 +1,28 @@
# From: @(#)Makefile 8.2 (Berkeley) 1/2/94
# $Id: Makefile,v 1.1 1997/10/01 02:57:00 gdr Exp $
# $Id: Makefile,v 1.2 1998/01/26 06:08:43 taubert Exp $
CFLAGS+=#-DTFILE=\"/dev/ttyp0\"
CFLAGS+=-D_CURSES_PRIVATE -I${.CURDIR}
LDADD+= -ltermcap
#CFLAGS+=#-DTFILE=\"/dev/ttyp0\"
CFLAGS+=-D_CURSES_PRIVATE -I${PWD}
#LDADD+= -ltermcap
LIB= curses
SRCS= addbytes.c addch.c addnstr.c box.c clear.c clrtobot.c clrtoeol.c \
cr_put.c ctrace.c cur_hash.c curses.c delch.c deleteln.c delwin.c \
erase.c fullname.c getch.c getstr.c id_subwins.c idlok.c initscr.c \
insch.c insertln.c longname.c move.c mvwin.c newwin.c overlay.c \
overwrite.c printw.c _putchar.c putchar.c refresh.c scanw.c scroll.c \
overwrite.c printw.c _putchar.c putchar.c refresh.c scroll.c \
setterm.c standout.c toucholap.c touchwin.c tscroll.c tstp.c tty.c \
unctrl.c
# Having trouble with this puppy
_SRCS= scanw.c
MAN3= curses.3
beforeinstall:
-cd ${.CURDIR}; cmp -s curses.h ${DESTDIR}/usr/include/curses.h || \
install -c -o ${BINOWN} -g ${BINGRP} -m 444 curses.h \
${DESTDIR}/usr/include
#beforeinstall:
# -cd ${.CURDIR}; cmp -s curses.h ${DESTDIR}/usr/include/curses.h || \
# install -c -o ${BINOWN} -g ${BINGRP} -m 444 curses.h \
# ${DESTDIR}/usr/include
.include <bsd.lib.mk>
CFLAGS+=-Slibcurses_
OPTIMIZE=79
DEBUG= 25
.INCLUDE: /src/gno/lib/lib.mk

46
lib/libcurses/_putchar.c Normal file
View File

@ -0,0 +1,46 @@
/*
* 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
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)_putchar.c 8.2 (Berkeley) 5/4/94";
#endif /* not lint */
#include "curses.h"
int
_putchar(int ch)
{
__cputchar(ch);
return 0;
}

View File

@ -45,11 +45,7 @@ static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94";
* Add the character to the current position in the given window.
*/
int
__waddbytes(win, bytes, count, so)
register WINDOW *win;
register const char *bytes;
register int count;
int so;
__waddbytes(WINDOW *win, const char *bytes, int count, int so)
{
static char blanks[] = " ";
register int c, newx, x, y;
@ -155,3 +151,4 @@ newline: if (y == win->maxy - 1) {
SYNCH_OUT;
return (OK);
}

View File

@ -43,9 +43,7 @@ static char sccsid[] = "@(#)addch.c 8.2 (Berkeley) 5/4/94";
*
*/
int
waddch(win, ch)
WINDOW *win;
int ch;
waddch(WINDOW *win, int ch)
{
__LDATA buf;
@ -55,12 +53,11 @@ waddch(win, ch)
}
int
__waddch(win, dp)
WINDOW *win;
__LDATA *dp;
__waddch(WINDOW *win, __LDATA *dp)
{
char buf[2];
buf[0] = dp->ch;
return (__waddbytes(win, buf, 1, dp->attr & __STANDOUT));
}

View File

@ -46,10 +46,7 @@ static char sccsid[] = "@(#)addnstr.c 8.2 (Berkeley) 5/4/94";
* entire string.
*/
int
waddnstr(win, s, n)
WINDOW *win;
const char *s;
int n;
waddnstr(WINDOW *win, const char *s, int n)
{
size_t len;
const char *p;
@ -60,3 +57,4 @@ waddnstr(win, s, n)
len = strlen(s);
return (waddbytes(win, s, len));
}

View File

@ -43,9 +43,7 @@ static char sccsid[] = "@(#)box.c 8.2 (Berkeley) 5/4/94";
* delimiting char, and "hor", as the horizontal one.
*/
int
box(win, vert, hor)
register WINDOW *win;
int vert, hor;
box(WINDOW *win, int vert, int hor)
{
register int endy, endx, i;
register __LDATA *fp, *lp;
@ -76,3 +74,4 @@ box(win, vert, hor)
__touchwin(win);
return (OK);
}

View File

@ -42,8 +42,7 @@ static char sccsid[] = "@(#)clear.c 8.2 (Berkeley) 5/4/94";
* Clear the window.
*/
int
wclear(win)
register WINDOW *win;
wclear(WINDOW *win)
{
if (werase(win) == OK) {
win->flags |= __CLEAROK;
@ -51,3 +50,4 @@ wclear(win)
}
return (ERR);
}

View File

@ -42,8 +42,7 @@ static char sccsid[] = "@(#)clrtobot.c 8.2 (Berkeley) 5/4/94";
* Erase everything on the window.
*/
int
wclrtobot(win)
register WINDOW *win;
wclrtobot(WINDOW *win)
{
register int minx, startx, starty, y;
register __LDATA *sp, *end, *maxx;
@ -73,3 +72,4 @@ wclrtobot(win)
}
return (OK);
}

View File

@ -42,8 +42,7 @@ static char sccsid[] = "@(#)clrtoeol.c 8.2 (Berkeley) 5/4/94";
* Clear up to the end of line.
*/
int
wclrtoeol(win)
register WINDOW *win;
wclrtoeol(WINDOW *win)
{
register int minx, x, y;
register __LDATA *end, *maxx, *sp;
@ -77,7 +76,3 @@ wclrtoeol(win)
return (__touchline(win, y, x, win->maxx - 1, 0));
}

View File

@ -49,8 +49,7 @@ static char sccsid[] = "@(#)cr_put.c 8.3 (Berkeley) 5/4/94";
/* Stub function for the users. */
int
mvcur(ly, lx, y, x)
int ly, lx, y, x;
mvcur(int ly, int lx, int y, int x)
{
return (__mvcur(ly, lx, y, x, 0));
}
@ -68,8 +67,7 @@ static int outcol, outline, destcol, destline;
* the lack thereof and rolling up the screen to get destline on the screen.
*/
int
__mvcur(ly, lx, y, x, in_refresh)
int ly, lx, y, x, in_refresh;
__mvcur(int ly, int lx, int y, int x, int in_refresh)
{
#ifdef DEBUG
__CTRACE("mvcur: moving cursor from (%d, %d) to (%d, %d)\n",
@ -85,8 +83,7 @@ __mvcur(ly, lx, y, x, in_refresh)
}
static void
fgoto(in_refresh)
int in_refresh;
fgoto(int in_refresh)
{
register int c, l;
register char *cgp;
@ -184,8 +181,7 @@ fgoto(in_refresh)
static int plodcnt, plodflg;
static void
plodput(c)
int c;
plodput(int c)
{
if (plodflg)
--plodcnt;
@ -194,8 +190,7 @@ plodput(c)
}
static int
plod(cnt, in_refresh)
int cnt, in_refresh;
plod(int cnt, int in_refresh)
{
register int i, j, k, soutcol, soutline;
@ -419,8 +414,7 @@ out: if (plodflg) {
* the case where col > COLS, even if ts does not divide COLS.
*/
static int
tabcol(col, ts)
int col, ts;
tabcol(int col, int ts)
{
int offset;
@ -431,3 +425,4 @@ tabcol(col, ts)
offset = 0;
return (col + ts - (col % ts) + offset);
}

View File

@ -50,6 +50,8 @@ static char sccsid[] = "@(#)ctrace.c 8.2 (Berkeley) 10/5/93";
static FILE *tracefp; /* Curses debugging file descriptor. */
#pragma debug 0
/* assume at least #pragma optimize 8 */
void
#ifdef __STDC__
__CTRACE(const char *fmt, ...)
@ -74,3 +76,4 @@ __CTRACE(fmt, va_alist)
(void)fflush(tracefp);
}
#endif

View File

@ -41,12 +41,10 @@ static char sccsid[] = "@(#)cur_hash.c 8.1 (Berkeley) 6/4/93";
/*
* __hash() is "hashpjw" from the Dragon Book, Aho, Sethi & Ullman, p.436.
*/
u_int
__hash(s, len)
unsigned char *s;
int len;
u_long
__hash(unsigned char *s, int len)
{
register u_int h, g, i;
u_long h, g, i;
h = 0;
i = 0;
@ -60,3 +58,4 @@ __hash(s, len)
}
return h;
}

View File

@ -31,233 +31,167 @@
.\"
.\" @(#)curses.3 8.1 (Berkeley) 6/4/93
.\"
.TH CURSES 3 "September 1997" GNO "Library Routines"
.SH NAME
.BR curses
\- screen functions with ``optimal
.SH SYNOPSIS
.BR occ
.I -flags
.B -L/usr/lib
.I files
.B -llibcurses
.B -llibtermcap
.SH DESCRIPTION
.Dd June 4, 1993
.Dt CURSES 3
.Os BSD 4
.Sh NAME
.Nm curses
.Nd screen functions with ``optimal'' cursor motion
.Sh SYNOPSIS
.Nm cc
.Op Ar flags
.Ar files
.Fl lcurses ltermcap
.Op Ar libraries
.Sh DESCRIPTION
These routines give the user a method of updating screens with reasonable
optimization. They keep an image of the current screen,
and the user sets up an image of a new one. Then the
.BR refresh
.Fn refresh
tells the routines to make the current screen look like the new one.
In order to initialize the routines, the routine
.BR initscr
.Fn initscr
must be called before any of the other routines that deal with windows and
screens are used. The routine
.BR endwin
.Fn endwin
should be called before exiting.
.SH SEE ALSO
.BR ioctl (2),
.BR getenv (3),
.BR tty (4),
.BR termcap (5)
.sp 1
.I Screen Updating and Cursor Movement Optimization: A Library Package
by Ken Arnold.
.SH AUTHOR
Ken Arnold
.SH FUNCTIONS
.\" These were originally in a table layout
.IP \fBaddch\fR(\fIch\fR)
add a character to
.IR stdscr
.IP \fBaddstr\fR(\fIstr\fR)
add a string to
.IR stdscr
.IP \fBbox\fR(\fIwin\fR,\fIvert\fR,\fIhor\fR)
draw a box around a window
.IP \fBcbreak\fR()
set cbreak mode
.IP \fBclear\fR()
clear
.IR stdscr
.IP \fBclearok\fR(\fIscr\fR,\fIboolf\fR)
set clear flag for
.IR scr
.IP \fBclrtobot\fR()
clear to bottom on
.IR stdscr
.IP \fBclrtoeol\fR()
clear to end of line on
.IR stdscr
.IP \fBdelch\fR()
delete a character
.IP \fBdeleteln\fR()
delete a line
.IP \fBdelwin\fR(\fIwin\fR)
delete
.IR stdscr
.IP \fBecho\fR()
set echo mode
.IP \fBendwin\fR()
end window modes
.IP \fBerase\fR()
erase
.IR stdscr
.IP \fBflusok\fR(\fIwin\fR,\fIboolf\fR)
set flush-on-refresh flag for
.IR win
.IP \fBgetch\fR()
get a char through
.IR stdscr
.IP \fBgetcap\fR(\fIname\fR)
get terminal capability
.IR name
.IP \fBgetstr\fR(\fIstr\fR)
get a string through
.IR stdscr
.IP \fBgettmode\fR()
get tty modes
.IP \fBgetyx\fR(\fIwin\fR,\fIy\fR,\fIx\fR)
get \fR(\fIy\fR,\fIx\fR) co-ordinates
.IP \fBinch\fR()
get char at current \fR(\fIy\fR,\fIx\fR) co-ordinates
.IP \fBinitscr\fR()
initialize screens
.IP \fBinsch\fR(\fIc\fR)
insert a char
.IP \fBinsertln\fR()
insert a line
.IP \fBleaveok\fR(\fIwin\fR,\fIboolf\fR)
set leave flag for
.IR stdscr
.IP \fBlongname\fR(\fItermbuf\fR,\fIname\fR)
get long name from
.IR termbuf
.IP \fBmove\fR(\fIy\fR,\fIx\fR)
move to \fR(\fIy\fR,\fIx\fR) on
.IR stdscr
.IP \fBmvcur\fR(\fIlasty\fR,\fIlastx\fR,\fInewy\fR,\fInewx\fR)
actually move cursor
.IP \fBnewwin\fR(\fIlines\fR,\fIcols\fR,\fIbegin_y\fR,\fIbegin_x\fR)
create a new window
.IP \fBnl\fR()
set newline mapping
.IP \fBnocbreak\fR()
unset cbreak mode
.IP \fBnoecho\fR()
unset echo mode
.IP \fBnonl\fR()
unset newline mapping
.IP \fBnoraw\fR()
unset raw mode
.IP \fBoverlay\fR(\fIwin1\fR,\fIwin2\fR)
overlay win1 on win2
.IP \fBoverwrite\fR(\fIwin1\fR,\fIwin2\fR)
overwrite win1 on top of win2
.IP \fBprintw\fR(\fIfmt\fR,\fIarg1\fR,\fIarg2\fR,...)
printf on
.IR stdscr
.IP \fBraw\fR()
set raw mode
.IP \fBrefresh\fR()
make current screen look like
.IR stdscr
.IP \fBresetty\fR()
reset tty flags to stored value
.IP \fBsavetty\fR()
stored current tty flags
.IP \fBscanw\fR(\fIfmt\fR,\fIarg1\fR,\fIarg2\fR,...)
scanf through
.IR stdscr
.IP \fBscroll\fR(\fIwin\fR)
scroll
.IR win
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr getenv 3 ,
.Xr tty 4 ,
.Xr termcap 5
.Rs
.%T Screen Updating and Cursor Movement Optimization: A Library Package
.%A Ken Arnold
.Re
.Sh AUTHOR
.An Ken Arnold
.Sh FUNCTIONS
.Bl -column "subwin(win,lines,cols,begin_y,begin_x) "
.It addch(ch) add a character to
.Em stdscr
.It addstr(str) add a string to
.Em stdscr
.It box(win,vert,hor) draw a box around a window
.It cbreak() set cbreak mode
.It clear() clear
.Em stdscr
.It clearok(scr,boolf) set clear flag for
.Em scr
.It clrtobot() clear to bottom on
.Em stdscr
.It clrtoeol() clear to end of line on
.Em stdscr
.It delch() delete a character
.It deleteln() delete a line
.It delwin(win) delete
.Em stdscr
.It echo() set echo mode
.It endwin() end window modes
.It erase() erase
.Em stdscr
.It flusok(win,boolf) set flush-on-refresh flag for
.Em win
.It getch() get a char through
.Em stdscr
.It getcap(name) get terminal capability
.Em name
.It getstr(str) get a string through
.Em stdscr
.It gettmode() get tty modes
.It getyx(win,y,x) get (y,x) co-ordinates
.It inch() get char at current (y,x) co-ordinates
.It initscr() initialize screens
.It insch(c) insert a char
.It insertln() insert a line
.It leaveok(win,boolf) set leave flag for
.Em stdscr
.It longname(termbuf,name) get long name from
.Em termbuf
.It move(y,x) move to (y,x) on
.Em stdscr
.It mvcur(lasty,lastx,newy,newx) actually move cursor
.It newwin(lines,cols,begin_y,begin_x)\ create a new window
.It nl() set newline mapping
.It nocbreak() unset cbreak mode
.It noecho() unset echo mode
.It nonl() unset newline mapping
.It noraw() unset raw mode
.It overlay(win1,win2) overlay win1 on win2
.It overwrite(win1,win2) overwrite win1 on top of win2
.It printw(fmt,arg1,arg2,...) printf on
.Em stdscr
.It raw() set raw mode
.It refresh() make current screen look like
.Em stdscr
.It resetty() reset tty flags to stored value
.It savetty() stored current tty flags
.It scanw(fmt,arg1,arg2,...) scanf through
.Em stdscr
.It scroll(win) scroll
.Em win
one line
.IP \fBscrollok\fR(\fIwin\fR,\fIboolf\fR)
set scroll flag
.IP \fBsetterm\fR(\fIname\fR)
set term variables for name
.IP \fBstandend\fR()
end standout mode
.IP \fBstandout\fR()
start standout mode
.IP \fBsubwin\fR(\fIwin\fR,\fIlines\fR,\fIcols\fR,\fIbegin_y\fR,\fIbegin_x\fR)
create a subwindow
.IP \fBtouchline\fR(\fIwin\fR,\fIy\fR,\fIsx\fR,\fIex\fR)
mark line
.IR y
.IR sx
.It scrollok(win,boolf) set scroll flag
.It setterm(name) set term variables for name
.It standend() end standout mode
.It standout() start standout mode
.It subwin(win,lines,cols,begin_y,begin_x)\ create a subwindow
.It touchline(win,y,sx,ex) mark line
.Em y
.Em sx
through
.IR sy
.Em sy
as changed
.IP \fBtouchoverlap\fR(\fIwin1\fR,\fIwin2\fR)
mark overlap of
.IR win1
.It touchoverlap(win1,win2) mark overlap of
.Em win1
on
.IR win2
.Em win2
as changed
.IP \fBtouchwin\fR(\fIwin\fR)
change all of
.IR win
.IP \fBunctrl\fR(\fIch\fR)
printable version of
.IR ch
.IP \fBwaddch\fR(\fIwin\fR,\fIch\fR)
add char to
.IR win
.IP \fBwaddstr\fR(\fIwin\fR,\fIstr\fR)
add string to
.IR win
.IP \fBwclear\fR(\fIwin\fR)
clear
.IR win
.IP \fBwclrtobot\fR(\fIwin\fR)
clear to bottom of
.IR win
.IP \fBwclrtoeol\fR(\fIwin\fR)
clear to end of line on
.IR win
.IP \fBwdelch\fR(\fIwin\fR,\fIc\fR)
delete char from
.IR win
.IP \fBwdeleteln\fR(\fIwin\fR)
delete line from
.IR win
.IP \fBwerase\fR(\fIwin\fR)
erase
.IR win
.IP \fBwgetch\fR(\fIwin\fR)
get a char through
.IR win
.IP \fBwgetstr\fR(\fIwin\fR,\fIstr\fR)
get a string through
.IR win
.IP \fBwinch\fR(\fIwin\fR)
get char at current \fR(\fIy\fR,\fIx\fR) in
.IR win
.IP \fBwinsch\fR(\fIwin\fR,\fIc\fR)
insert char into
.IR win
.IP \fBwinsertln\fR(\fIwin\fR)
insert line into
.IR win
.IP \fBwmove\fR(\fIwin\fR,\fIy\fR,\fIx\fR)
set current \fR(\fIy\fR,\fIx\fR) co-ordinates on
.IR win
.IP \fBwprintw\fR(\fIwin\fR,\fIfmt\fR,\fIarg1\fR,\fIarg2\fR,...)
printf on
.IR win
.IP \fBwrefresh\fR(\fIwin\fR)
make screen look like
.IR win
.IP \fBwscanw\fR(\fIwin\fR,\fIfmt\fR,\fIarg1\fR,\fIarg2\fR,...)
scanf through
.IR win
.IP \fBwstandend\fR(\fIwin\fR)
end standout mode on
.IR win
.IP \fBwstandout\fR(\fIwin\fR)
start standout mode on
.IR win
.RE
.SH HISTORY
This package first appeared in 4.0BSD.
.It touchwin(win) \*(lqchange\*(rq all of
.Em win
.It unctrl(ch) printable version of
.Em ch
.It waddch(win,ch) add char to
.Em win
.It waddstr(win,str) add string to
.Em win
.It wclear(win) clear
.Em win
.It wclrtobot(win) clear to bottom of
.Em win
.It wclrtoeol(win) clear to end of line on
.Em win
.It wdelch(win,c) delete char from
.Em win
.It wdeleteln(win) delete line from
.Em win
.It werase(win) erase
.Em win
.It wgetch(win) get a char through
.Em win
.It wgetstr(win,str) get a string through
.Em win
.It winch(win) get char at current (y,x) in
.Em win
.It winsch(win,c) insert char into
.Em win
.It winsertln(win) insert line into
.Em win
.It wmove(win,y,x) set current (y,x) co-ordinates on
.Em win
.It wprintw(win,fmt,arg1,arg2,...)\ printf on
.Em win
.It wrefresh(win) make screen look like
.Em win
.It wscanw(win,fmt,arg1,arg2,...)\ scanf through
.Em win
.It wstandend(win) end standout mode on
.Em win
.It wstandout(win) start standout mode on
.Em win
.El
.Sh HISTORY
The
.Nm
package appeared in
.Bx 4.0 .

263
lib/libcurses/curses.3G Normal file
View File

@ -0,0 +1,263 @@
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)curses.3 8.1 (Berkeley) 6/4/93
.\"
.TH CURSES 3 "September 1997" GNO "Library Routines"
.SH NAME
.BR curses
\- screen functions with ``optimal
.SH SYNOPSIS
.BR occ
.I -flags
.B -L/usr/lib
.I files
.B -llibcurses
.B -llibtermcap
.SH DESCRIPTION
These routines give the user a method of updating screens with reasonable
optimization. They keep an image of the current screen,
and the user sets up an image of a new one. Then the
.BR refresh
tells the routines to make the current screen look like the new one.
In order to initialize the routines, the routine
.BR initscr
must be called before any of the other routines that deal with windows and
screens are used. The routine
.BR endwin
should be called before exiting.
.SH SEE ALSO
.BR ioctl (2),
.BR getenv (3),
.BR tty (4),
.BR termcap (5)
.sp 1
.I Screen Updating and Cursor Movement Optimization: A Library Package
by Ken Arnold.
.SH AUTHOR
Ken Arnold
.SH FUNCTIONS
.\" These were originally in a table layout
.IP \fBaddch\fR(\fIch\fR)
add a character to
.IR stdscr
.IP \fBaddstr\fR(\fIstr\fR)
add a string to
.IR stdscr
.IP \fBbox\fR(\fIwin\fR,\fIvert\fR,\fIhor\fR)
draw a box around a window
.IP \fBcbreak\fR()
set cbreak mode
.IP \fBclear\fR()
clear
.IR stdscr
.IP \fBclearok\fR(\fIscr\fR,\fIboolf\fR)
set clear flag for
.IR scr
.IP \fBclrtobot\fR()
clear to bottom on
.IR stdscr
.IP \fBclrtoeol\fR()
clear to end of line on
.IR stdscr
.IP \fBdelch\fR()
delete a character
.IP \fBdeleteln\fR()
delete a line
.IP \fBdelwin\fR(\fIwin\fR)
delete
.IR stdscr
.IP \fBecho\fR()
set echo mode
.IP \fBendwin\fR()
end window modes
.IP \fBerase\fR()
erase
.IR stdscr
.IP \fBflusok\fR(\fIwin\fR,\fIboolf\fR)
set flush-on-refresh flag for
.IR win
.IP \fBgetch\fR()
get a char through
.IR stdscr
.IP \fBgetcap\fR(\fIname\fR)
get terminal capability
.IR name
.IP \fBgetstr\fR(\fIstr\fR)
get a string through
.IR stdscr
.IP \fBgettmode\fR()
get tty modes
.IP \fBgetyx\fR(\fIwin\fR,\fIy\fR,\fIx\fR)
get \fR(\fIy\fR,\fIx\fR) co-ordinates
.IP \fBinch\fR()
get char at current \fR(\fIy\fR,\fIx\fR) co-ordinates
.IP \fBinitscr\fR()
initialize screens
.IP \fBinsch\fR(\fIc\fR)
insert a char
.IP \fBinsertln\fR()
insert a line
.IP \fBleaveok\fR(\fIwin\fR,\fIboolf\fR)
set leave flag for
.IR stdscr
.IP \fBlongname\fR(\fItermbuf\fR,\fIname\fR)
get long name from
.IR termbuf
.IP \fBmove\fR(\fIy\fR,\fIx\fR)
move to \fR(\fIy\fR,\fIx\fR) on
.IR stdscr
.IP \fBmvcur\fR(\fIlasty\fR,\fIlastx\fR,\fInewy\fR,\fInewx\fR)
actually move cursor
.IP \fBnewwin\fR(\fIlines\fR,\fIcols\fR,\fIbegin_y\fR,\fIbegin_x\fR)
create a new window
.IP \fBnl\fR()
set newline mapping
.IP \fBnocbreak\fR()
unset cbreak mode
.IP \fBnoecho\fR()
unset echo mode
.IP \fBnonl\fR()
unset newline mapping
.IP \fBnoraw\fR()
unset raw mode
.IP \fBoverlay\fR(\fIwin1\fR,\fIwin2\fR)
overlay win1 on win2
.IP \fBoverwrite\fR(\fIwin1\fR,\fIwin2\fR)
overwrite win1 on top of win2
.IP \fBprintw\fR(\fIfmt\fR,\fIarg1\fR,\fIarg2\fR,...)
printf on
.IR stdscr
.IP \fBraw\fR()
set raw mode
.IP \fBrefresh\fR()
make current screen look like
.IR stdscr
.IP \fBresetty\fR()
reset tty flags to stored value
.IP \fBsavetty\fR()
stored current tty flags
.IP \fBscanw\fR(\fIfmt\fR,\fIarg1\fR,\fIarg2\fR,...)
scanf through
.IR stdscr
.IP \fBscroll\fR(\fIwin\fR)
scroll
.IR win
one line
.IP \fBscrollok\fR(\fIwin\fR,\fIboolf\fR)
set scroll flag
.IP \fBsetterm\fR(\fIname\fR)
set term variables for name
.IP \fBstandend\fR()
end standout mode
.IP \fBstandout\fR()
start standout mode
.IP \fBsubwin\fR(\fIwin\fR,\fIlines\fR,\fIcols\fR,\fIbegin_y\fR,\fIbegin_x\fR)
create a subwindow
.IP \fBtouchline\fR(\fIwin\fR,\fIy\fR,\fIsx\fR,\fIex\fR)
mark line
.IR y
.IR sx
through
.IR sy
as changed
.IP \fBtouchoverlap\fR(\fIwin1\fR,\fIwin2\fR)
mark overlap of
.IR win1
on
.IR win2
as changed
.IP \fBtouchwin\fR(\fIwin\fR)
change all of
.IR win
.IP \fBunctrl\fR(\fIch\fR)
printable version of
.IR ch
.IP \fBwaddch\fR(\fIwin\fR,\fIch\fR)
add char to
.IR win
.IP \fBwaddstr\fR(\fIwin\fR,\fIstr\fR)
add string to
.IR win
.IP \fBwclear\fR(\fIwin\fR)
clear
.IR win
.IP \fBwclrtobot\fR(\fIwin\fR)
clear to bottom of
.IR win
.IP \fBwclrtoeol\fR(\fIwin\fR)
clear to end of line on
.IR win
.IP \fBwdelch\fR(\fIwin\fR,\fIc\fR)
delete char from
.IR win
.IP \fBwdeleteln\fR(\fIwin\fR)
delete line from
.IR win
.IP \fBwerase\fR(\fIwin\fR)
erase
.IR win
.IP \fBwgetch\fR(\fIwin\fR)
get a char through
.IR win
.IP \fBwgetstr\fR(\fIwin\fR,\fIstr\fR)
get a string through
.IR win
.IP \fBwinch\fR(\fIwin\fR)
get char at current \fR(\fIy\fR,\fIx\fR) in
.IR win
.IP \fBwinsch\fR(\fIwin\fR,\fIc\fR)
insert char into
.IR win
.IP \fBwinsertln\fR(\fIwin\fR)
insert line into
.IR win
.IP \fBwmove\fR(\fIwin\fR,\fIy\fR,\fIx\fR)
set current \fR(\fIy\fR,\fIx\fR) co-ordinates on
.IR win
.IP \fBwprintw\fR(\fIwin\fR,\fIfmt\fR,\fIarg1\fR,\fIarg2\fR,...)
printf on
.IR win
.IP \fBwrefresh\fR(\fIwin\fR)
make screen look like
.IR win
.IP \fBwscanw\fR(\fIwin\fR,\fIfmt\fR,\fIarg1\fR,\fIarg2\fR,...)
scanf through
.IR win
.IP \fBwstandend\fR(\fIwin\fR)
end standout mode on
.IR win
.IP \fBwstandout\fR(\fIwin\fR)
start standout mode on
.IR win
.RE
.SH HISTORY
This package first appeared in 4.0BSD.

View File

@ -52,6 +52,7 @@ int __usecs = 0; /*
* region (used only if insert/delete
* line capabilities absent)
*/
#ifndef __GNO__
char AM, BS, CA, DA, DB, EO, HC, IN, MI, MS, NC, NS, OS, PC,
UL, XB, XN, XT, XS, XX;
char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
@ -62,6 +63,18 @@ char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
*VE, *al, *dl, *sf, *sr,
*AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
*RIGHT_PARM;
#else
char AM, BS, CA, DA, DB, EO, HC, IN, MI, MS, NC, NS, OS,
UL, XB, XN, XT, XS, XX;
char *AL, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
*DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
*K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
*KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
*SO, *SR, *TA, *TE, *TI, *UC, *UE, *US, *VB, *VS,
*VE, *al, *dl, *sf, *sr,
*AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
*RIGHT_PARM;
#endif
/*
* Public.
*
@ -78,3 +91,4 @@ char *Def_term = "unknown"; /* Default terminal type. */
char GT; /* Gtty indicates tabs. */
char NONL; /* Term can't hack LF doing a CR. */
char UPPERCASE; /* Terminal is uppercase only. */

View File

@ -76,9 +76,11 @@
#undef B57600
#undef B115200
#include <termios.h>
#include <sys/ioctl.h>
#include <termios.h>
#ifndef __GNO__
#include <sys/ioctl_compat.h> /* For sgttyb and related */
#endif
#define bool char
#define reg register
@ -163,7 +165,7 @@ typedef struct {
#define __ISPASTEOL 0x02 /* Cursor is past end of line */
#define __FORCEPAINT 0x04 /* Force a repaint of the line */
u_int flags;
u_int hash; /* Hash value for the line. */
u_long hash; /* Hash value for the line. */
size_t *firstchp, *lastchp; /* First and last chngd columns ptrs */
size_t firstch, lastch; /* First and last changed columns. */
__LDATA *line; /* Pointer to the line text. */
@ -346,7 +348,7 @@ int __waddbytes __P((WINDOW *, const char *, int, int));
/* Private functions. */
#ifdef _CURSES_PRIVATE
void __CTRACE __P((const char *, ...));
u_int __hash __P((char *, int));
u_long __hash __P((char *, int));
void __id_subwins __P((WINDOW *));
int __mvcur __P((int, int, int, int, int));
void __restore_stophandler __P((void));
@ -354,7 +356,7 @@ void __set_stophandler __P((void));
void __set_subwin __P((WINDOW *, WINDOW *));
void __set_scroll_region __P((int, int, int, int));
void __startwin __P((void));
void __stop_signal_handler __P((int));
void __stop_signal_handler __P((int, int));
void __swflags __P((WINDOW *));
int __touchline __P((WINDOW *, int, int, int, int));
int __touchwin __P((WINDOW *));

View File

@ -44,8 +44,7 @@ static char sccsid[] = "@(#)delch.c 8.2 (Berkeley) 5/4/94";
* Do an insert-char on the line, leaving (cury, curx) unchanged.
*/
int
wdelch(win)
register WINDOW *win;
wdelch(WINDOW *win)
{
register __LDATA *end, *temp1, *temp2;
@ -61,3 +60,4 @@ wdelch(win)
__touchline(win, win->cury, win->curx, win->maxx - 1, 0);
return (OK);
}

View File

@ -44,8 +44,7 @@ static char sccsid[] = "@(#)deleteln.c 8.2 (Berkeley) 5/4/94";
* Delete a line from the screen. It leaves (cury, curx) unchanged.
*/
int
wdeleteln(win)
register WINDOW *win;
wdeleteln(WINDOW *win)
{
register int y, i;
register __LINE *temp;
@ -80,3 +79,4 @@ wdeleteln(win)
__id_subwins(win);
return (OK);
}

View File

@ -44,10 +44,8 @@ static char sccsid[] = "@(#)delwin.c 8.2 (Berkeley) 5/4/94";
* Delete a window and release it back to the system.
*/
int
delwin(win)
register WINDOW *win;
delwin(WINDOW *win)
{
register WINDOW *wp, *np;
if (win->orig == NULL) {
@ -78,3 +76,4 @@ delwin(win)
free(win);
return (OK);
}

View File

@ -42,10 +42,8 @@ static char sccsid[] = "@(#)erase.c 8.2 (Berkeley) 5/4/94";
* Erases everything on the window.
*/
int
werase(win)
register WINDOW *win;
werase(WINDOW *win)
{
register int minx, y;
register __LDATA *sp, *end, *start, *maxx;
@ -70,3 +68,4 @@ werase(win)
}
return (OK);
}

View File

@ -41,8 +41,7 @@ static char sccsid[] = "@(#)fullname.c 8.1 (Berkeley) 6/4/93";
* This is assumed to be the last name in the list of aliases.
*/
char *
fullname(bp, def)
register char *bp, *def;
fullname(char *bp, char *def)
{
register char *cp;
@ -58,3 +57,4 @@ fullname(bp, def)
}
return (def);
}

View File

@ -42,8 +42,7 @@ static char sccsid[] = "@(#)getch.c 8.2 (Berkeley) 5/4/94";
* Read in a character from the window.
*/
int
wgetch(win)
register WINDOW *win;
wgetch(WINDOW *win)
{
register int inp, weset;
@ -75,3 +74,4 @@ wgetch(win)
nocbreak();
return (inp);
}

View File

@ -42,9 +42,7 @@ static char sccsid[] = "@(#)getstr.c 8.2 (Berkeley) 5/4/94";
* Get a string starting at (cury, curx).
*/
int
wgetstr(win, str)
register WINDOW *win;
register char *str;
wgetstr(WINDOW *win, char *str)
{
int c;
@ -55,3 +53,4 @@ wgetstr(win, str)
return (ERR);
return (OK);
}

View File

@ -42,8 +42,7 @@ static char sccsid[] = "@(#)id_subwins.c 8.2 (Berkeley) 5/4/94";
* Re-sync the pointers to lines for all the subwindows.
*/
void
__id_subwins(orig)
register WINDOW *orig;
__id_subwins(WINDOW *orig)
{
register WINDOW *win;
register int oy, realy, y;
@ -63,3 +62,4 @@ __id_subwins(orig)
&orig->lines[oy]->line[win->ch_off];
}
}

View File

@ -43,9 +43,7 @@ static char sccsid[] = "@(#)idlok.c 8.2 (Berkeley) 5/4/94";
* given window.
*/
void
idlok(win, bf)
WINDOW *win;
int bf;
idlok(WINDOW *win, int bf)
{
if (bf)
win->flags |= __IDLINE;

View File

@ -45,7 +45,7 @@ static char sccsid[] = "@(#)initscr.c 8.2 (Berkeley) 5/4/94";
* Initialize the current and standard screen.
*/
WINDOW *
initscr()
initscr(void)
{
register char *sp;
@ -93,3 +93,4 @@ initscr()
return (stdscr);
}

View File

@ -44,11 +44,8 @@ static char sccsid[] = "@(#)insch.c 8.2 (Berkeley) 5/4/94";
* Do an insert-char on the line, leaving (cury, curx) unchanged.
*/
int
winsch(win, ch)
register WINDOW *win;
int ch;
winsch(WINDOW *win, int ch)
{
register __LDATA *end, *temp1, *temp2;
end = &win->lines[win->cury]->line[win->curx];
@ -72,3 +69,4 @@ winsch(win, ch)
return (ERR);
return (OK);
}

View File

@ -44,10 +44,8 @@ static char sccsid[] = "@(#)insertln.c 8.2 (Berkeley) 5/4/94";
* Do an insert-line on the window, leaving (cury, curx) unchanged.
*/
int
winsertln(win)
register WINDOW *win;
winsertln(WINDOW *win)
{
register int y, i;
register __LINE *temp;
@ -80,3 +78,4 @@ winsertln(win)
__id_subwins(win);
return (OK);
}

View File

@ -40,8 +40,7 @@ static char sccsid[] = "@(#)longname.c 8.1 (Berkeley) 6/4/93";
* Fill in "def" with the long name of the terminal.
*/
char *
longname(bp, def)
register char *bp, *def;
longname(char *bp, char *def)
{
register char *cp;
@ -54,3 +53,4 @@ longname(bp, def)
}
return (def);
}

View File

@ -42,11 +42,8 @@ static char sccsid[] = "@(#)move.c 8.2 (Berkeley) 5/4/94";
* Moves the cursor to the given point.
*/
int
wmove(win, y, x)
register WINDOW *win;
register int y, x;
wmove(WINDOW *win, int y, int x)
{
#ifdef DEBUG
__CTRACE("wmove: (%d, %d)\n", y, x);
#endif
@ -60,3 +57,4 @@ wmove(win, y, x)
win->lines[y]->flags &= ~__ISPASTEOL;
return (OK);
}

View File

@ -42,9 +42,7 @@ static char sccsid[] = "@(#)mvwin.c 8.2 (Berkeley) 5/4/94";
* Relocate the starting position of a window.
*/
int
mvwin(win, by, bx)
register WINDOW *win;
register int by, bx;
mvwin(WINDOW *win, int by, int bx)
{
register WINDOW *orig;
register int dy, dx;
@ -75,3 +73,4 @@ mvwin(win, by, bx)
__touchwin(win);
return (OK);
}

View File

@ -50,8 +50,7 @@ void __set_subwin __P((WINDOW *, WINDOW *));
* Allocate space for and set up defaults for a new window.
*/
WINDOW *
newwin(nl, nc, by, bx)
register int nl, nc, by, bx;
newwin